diff options
| author | ljfa-ag <ljfa-ag@web.de> | 2015-07-03 16:51:34 +0200 |
|---|---|---|
| committer | ljfa-ag <ljfa-ag@web.de> | 2015-07-03 16:51:34 +0200 |
| commit | b64e3db8d02ba4668a3175163fe438c57cff16e4 (patch) | |
| tree | 9ff72a1d683cf33f34edbb2568c68dce978e575c | |
| parent | 33c26a33d1cf30f36c1d9c641f6ffc4dd77a5861 (diff) | |
| download | Project-Tick-b64e3db8d02ba4668a3175163fe438c57cff16e4.tar.gz Project-Tick-b64e3db8d02ba4668a3175163fe438c57cff16e4.zip | |
Implement at and operator[] for value
| -rw-r--r-- | include/value.h | 1 | ||||
| -rw-r--r-- | src/value.cpp | 15 |
2 files changed, 15 insertions, 1 deletions
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<tag>& get_ptr(); const std::unique_ptr<tag>& 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_compound&>(*tag_).at(key); +} + +const value& value::at(const std::string& key) const +{ + return dynamic_cast<const tag_compound&>(*tag_).at(key); +} + +value& value::operator[](const std::string& key) +{ + return dynamic_cast<tag_compound&>(*tag_)[key]; +} + std::unique_ptr<tag>& value::get_ptr() { return tag_; |
