mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-21 20:39:32 -05:00
32 lines
986 B
C++
32 lines
986 B
C++
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <optional>
|
|
#include <filesystem>
|
|
#include <json11.hpp>
|
|
|
|
namespace utils
|
|
{
|
|
class LanguageMetadata
|
|
{
|
|
public:
|
|
static std::optional<LanguageMetadata> get(const std::filesystem::path &path, const json11::Json &contents)
|
|
{
|
|
if (contents[metadataKey].is_null() || contents[metadataKey][metadataDisplayKey].is_null()) {
|
|
return {};
|
|
}
|
|
|
|
return LanguageMetadata{.displayName = contents[metadataKey][metadataDisplayKey].string_value(),
|
|
.path = path};
|
|
}
|
|
const std::string displayName;
|
|
const std::filesystem::path path;
|
|
|
|
private:
|
|
static constexpr auto metadataKey = "metadata";
|
|
static constexpr auto metadataDisplayKey = "display_name";
|
|
};
|
|
} // namespace utils
|