From 7fe47a9d5b1727a61dc724523b530762f6d6ba19 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Thu, 30 Jun 2022 21:38:53 -0700 Subject: Restructure project --- .../Cplt/Model/Workflow/Values/Dictionary.cpp | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 app/source/Cplt/Model/Workflow/Values/Dictionary.cpp (limited to 'app/source/Cplt/Model/Workflow/Values/Dictionary.cpp') 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 + +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& 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 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)); +} -- cgit v1.2.3-70-g09d2