summaryrefslogtreecommitdiff
path: root/include/value.h
diff options
context:
space:
mode:
authorljfa-ag <ljfa-ag@web.de>2015-07-02 09:04:06 +0200
committerljfa-ag <ljfa-ag@web.de>2015-07-02 09:04:06 +0200
commitba86b862d679b358c52aa925044365c8d6057e08 (patch)
tree97179b40a97d70c352cc55301e6460e020f1c009 /include/value.h
parent452a495e3c8cc09525dca777f0ead6f24b904a1c (diff)
downloadProject-Tick-ba86b862d679b358c52aa925044365c8d6057e08.tar.gz
Project-Tick-ba86b862d679b358c52aa925044365c8d6057e08.zip
Add get/set_ptr and operator bool to value
Diffstat (limited to 'include/value.h')
-rw-r--r--include/value.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/include/value.h b/include/value.h
index 491a92b2a0..a4ccf22873 100644
--- a/include/value.h
+++ b/include/value.h
@@ -34,13 +34,14 @@ class tag_list;
/**
* @brief Contains an NBT value of fixed type
*
- * A wrapper class that contains a dynamically allocated tag of a fixed type.
- * Casting or assigning incompatible types will throw a exceptions.
+ * A convenience wrapper around @c std::unique_ptr<tag>, contains a tag of
+ * fixed type.
*/
class value
{
public:
explicit value() {}
+ explicit value(std::unique_ptr<tag>&& t);
//Movable but not (implicitly) copyable
value(const value&) = delete;
@@ -48,9 +49,6 @@ public:
value& operator=(const value&) = delete;
value& operator=(value&&) = default;
- explicit value(std::unique_ptr<tag>&& t);
- value& operator=(std::unique_ptr<tag>&& t);
-
/**
* @brief Assigns the given value to the tag if the type matches
* @throw std::bad_cast if the type of @c t is not the same as the type
@@ -90,6 +88,9 @@ public:
operator double() const;
operator const std::string&() const;
+ ///Returns true if the contained tag is not @c nullptr
+ explicit operator bool() const;
+
/**
* @brief In case of a tag_compound, accesses a tag by key with bounds checking
* @throw std::bad_cast if the tag type is not tag_compound
@@ -107,6 +108,10 @@ public:
value& operator[](const std::string& key);
const value& operator[](const std::string& key) const;
+ std::unique_ptr<tag>& get_ptr();
+ const std::unique_ptr<tag>& get_ptr() const;
+ void set_ptr(std::unique_ptr<tag>&& t);
+
///@sa tag::get_type
tag_type get_type() const;