#include "Dictionary.h"

bool Dictionary::HasKey(const std::string& key) const
{
    return HasStringKey(key) || HasDictKey(key);
}

bool Dictionary::HasStringKey(const std::string& key) const
{
    return mStringData.count(key) > 0;
}

bool Dictionary::HasDictKey(const std::string& key) const
{
    return mDictData.count(key) > 0;
}

std::vector<std::string> Dictionary::GetStringKeys() const
{
    std::vector<std::string> keys;
    for (const auto& item : mStringData)
    {
        keys.push_back(item.first);
    }
    return keys;
}

std::vector<std::string> Dictionary::GetDictKeys() const
{
    std::vector<std::string> keys;
    for (const auto& item : mDictData)
    {
        keys.push_back(item.first);
    }
    return keys;
}

Dictionary* Dictionary::GetDict(const std::string& key) const
{
    return mDictData.at(key).get();
}

std::string Dictionary::GetItem(const std::string& key) const
{
    return mStringData.at(key);
}

void Dictionary::AddStringItem(const std::string& key, const std::string& item)
{
    mStringData[key] = item;
}

void Dictionary::AddDictItem(const std::string& key, std::unique_ptr<Dictionary> dict)
{
    mDictData[key] = std::move(dict);
}
