diff options
Diffstat (limited to 'include/value.h')
| -rw-r--r-- | include/value.h | 15 |
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; |
