#include "FileFormats.h"

#include "StringUtils.h"

FileFormat::ExtensionMap FileFormat::mExtensions = []
{
    ExtensionMap ret;
    ret[Format::Markdown] = ".md";
    ret[Format::Html] = ".html";
    ret[Format::Wav] = ".wav";
    return ret;
}();

bool FileFormat::isFormat(const std::string& extension, Format format)
{
    return StringUtils::toLower(extension) == mExtensions[format];
}

FileFormat::Format FileFormat::inferFormat(const std::string& query)
{
    for(const auto& extension : mExtensions)
    {
        if(extension.second == query)
        {
            return extension.first;
        }
    }
    return Format::Unknown;
}

std::string FileFormat::getExtension(Format format)
{
    return mExtensions[format];
}
