From ba86b862d679b358c52aa925044365c8d6057e08 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Thu, 2 Jul 2015 09:04:06 +0200 Subject: Add get/set_ptr and operator bool to value --- src/tag_compound.cpp | 2 +- src/value.cpp | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/tag_compound.cpp b/src/tag_compound.cpp index 6bc83301e2..94dc2dd6f1 100644 --- a/src/tag_compound.cpp +++ b/src/tag_compound.cpp @@ -42,7 +42,7 @@ bool tag_compound::put(const std::string& key, std::unique_ptr&& t) auto it = tags.find(key); if(it != tags.end()) { - it->second = std::move(t); + it->second.set_ptr(std::move(t)); return false; } else diff --git a/src/value.cpp b/src/value.cpp index a5f8e3c894..f062e08a09 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -28,16 +28,30 @@ value::value(std::unique_ptr&& t): tag_(std::move(t)) {} -value& value::operator=(std::unique_ptr&& t) +value& value::operator=(tag&& t) { - tag_ = std::move(t); + tag_->assign(std::move(t)); return *this; } -value& value::operator=(tag&& t) +value::operator bool() const { - tag_->assign(std::move(t)); - return *this; + return tag_ != nullptr; +} + +std::unique_ptr& value::get_ptr() +{ + return tag_; +} + +const std::unique_ptr& value::get_ptr() const +{ + return tag_; +} + +void value::set_ptr(std::unique_ptr&& t) +{ + tag_ = std::move(t); } tag_type value::get_type() const -- cgit 0.0.5-2-1-g0f52