#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);
}
