aboutsummaryrefslogtreecommitdiff
path: root/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'app/source/Cplt/Model/Workflow/Values/Dictionary.cpp')
-rw-r--r--app/source/Cplt/Model/Workflow/Values/Dictionary.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp b/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp
new file mode 100644
index 0000000..97bf509
--- /dev/null
+++ b/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp
@@ -0,0 +1,49 @@
+#include "Dictionary.hpp"
+
+#include <Cplt/Utils/Macros.hpp>
+
+bool DictionaryValue::IsInstance(const BaseValue* value)
+{
+ return value->GetKind() == KD_Dictionary;
+}
+
+DictionaryValue::DictionaryValue()
+ : BaseValue(KD_Dictionary)
+{
+}
+
+int DictionaryValue::GetCount() const
+{
+ return mElements.size();
+}
+
+BaseValue* DictionaryValue::Find(std::string_view key)
+{
+ auto iter = mElements.find(key);
+ if (iter != mElements.end()) {
+ return iter.value().get();
+ } else {
+ return nullptr;
+ }
+}
+
+BaseValue* DictionaryValue::Insert(std::string_view key, std::unique_ptr<BaseValue>& value)
+{
+ auto [iter, success] = mElements.insert(key, std::move(value));
+ if (success) {
+ return iter.value().get();
+ } else {
+ return nullptr;
+ }
+}
+
+BaseValue& DictionaryValue::InsertOrReplace(std::string_view key, std::unique_ptr<BaseValue> value)
+{
+ auto [iter, DISCARD] = mElements.emplace(key, std::move(value));
+ return *iter.value();
+}
+
+void DictionaryValue::Remove(std::string_view key)
+{
+ mElements.erase(mElements.find(key));
+}