From 26a08e6eeabec972cf57c6eb4e8f91516ad07f0c Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Tue, 30 Jun 2015 19:28:35 +0200 Subject: Create move_clone method --- include/tag.h | 3 +++ include/tag_compound.h | 2 ++ include/tag_primitive.h | 8 ++++++++ include/tag_string.h | 2 ++ 4 files changed, 15 insertions(+) (limited to 'include') diff --git a/include/tag.h b/include/tag.h index 29e63a9c54..acc537500f 100644 --- a/include/tag.h +++ b/include/tag.h @@ -21,6 +21,7 @@ #define TAG_H_INCLUDED #include +#include namespace nbt { @@ -52,6 +53,8 @@ public: ///Returns the type of the tag virtual tag_type get_type() const noexcept = 0; + virtual std::unique_ptr move_clone() && = 0; + friend bool operator==(const tag& lhs, const tag& rhs); friend bool operator!=(const tag& lhs, const tag& rhs); diff --git a/include/tag_compound.h b/include/tag_compound.h index e1d5218a9a..435fdbdff6 100644 --- a/include/tag_compound.h +++ b/include/tag_compound.h @@ -109,6 +109,8 @@ public: tag_type get_type() const noexcept override; + std::unique_ptr move_clone() && override; + private: std::map tags; diff --git a/include/tag_primitive.h b/include/tag_primitive.h index bf8600c9f1..e35d462c48 100644 --- a/include/tag_primitive.h +++ b/include/tag_primitive.h @@ -53,6 +53,8 @@ public: tag_type get_type() const noexcept override; + std::unique_ptr move_clone() && override; + private: T value; @@ -109,6 +111,12 @@ tag_type tag_primitive::get_type() const noexcept return type; } +template +std::unique_ptr tag_primitive::move_clone() && +{ + return std::unique_ptr(new tag_primitive(std::move(*this))); +} + template bool tag_primitive::equals(const tag& rhs) const { diff --git a/include/tag_string.h b/include/tag_string.h index 05a2e1cb4d..456fa8ad08 100644 --- a/include/tag_string.h +++ b/include/tag_string.h @@ -47,6 +47,8 @@ public: tag_type get_type() const noexcept override; + std::unique_ptr move_clone() && override; + private: std::string value; -- cgit 0.0.5-2-1-g0f52