From b64e3db8d02ba4668a3175163fe438c57cff16e4 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Fri, 3 Jul 2015 16:51:34 +0200 Subject: Implement at and operator[] for value --- include/value.h | 1 - src/value.cpp | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/value.h b/include/value.h index 3b03cc0d43..a46d79e7c5 100644 --- a/include/value.h +++ b/include/value.h @@ -120,7 +120,6 @@ public: * @sa tag_compound::operator[] */ value& operator[](const std::string& key); - const value& operator[](const std::string& key) const; std::unique_ptr& get_ptr(); const std::unique_ptr& get_ptr() const; diff --git a/src/value.cpp b/src/value.cpp index 90a67b79f3..8196ce16e2 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -314,6 +314,21 @@ value::operator bool() const return tag_ != nullptr; } +value& value::at(const std::string& key) +{ + return dynamic_cast(*tag_).at(key); +} + +const value& value::at(const std::string& key) const +{ + return dynamic_cast(*tag_).at(key); +} + +value& value::operator[](const std::string& key) +{ + return dynamic_cast(*tag_)[key]; +} + std::unique_ptr& value::get_ptr() { return tag_; -- cgit 0.0.5-2-1-g0f52