Cluedo Solver v1.0
Cluedo game solver making deductions.
Loading...
Searching...
No Matches
LanguageStrings.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <nlohmann/json.hpp>
5
8
9namespace Cluedo {
10
13class LanguageStrings {
14public:
16 struct Language {
17 std::string_view id;
18 std::string_view name;
19 std::string_view data;
20 };
21
25 static LanguageStrings& the();
26
30 static std::vector<Language> const& languages() { return s_languages; }
34 std::string_view current_language_id() const { return m_current_language_id; }
38 void set_language(std::string_view id);
39
44 std::string_view get_string(std::string_view key) const;
45
46private:
47 static std::unique_ptr<LanguageStrings> s_instance;
48 static std::vector<Language> s_languages;
49
50 LanguageStrings() = default;
51
52 LanguageStrings(LanguageStrings const&) = delete;
53 LanguageStrings& operator=(LanguageStrings const&) = delete;
54
56 LanguageStrings& operator=(LanguageStrings&&) = delete;
57
58 std::string_view m_current_language_id;
59 nlohmann::json m_strings;
60};
61
66#define LS(key) (Cluedo::LanguageStrings::the().get_string((key)))
75#define CSTR(s) (std::string { (s) }.c_str())
76
77};
Definition LanguageStrings.hpp:13
static LanguageStrings & the()
Definition LanguageStrings.cpp:22
std::string_view current_language_id() const
Definition LanguageStrings.hpp:34
void set_language(std::string_view id)
Definition LanguageStrings.cpp:31
static std::vector< Language > const & languages()
Definition LanguageStrings.hpp:30
std::string_view get_string(std::string_view key) const
Definition LanguageStrings.cpp:47
A struct that contains the data of a language.
Definition LanguageStrings.hpp:16
std::string_view id
An identifier used for the language.
Definition LanguageStrings.hpp:17
std::string_view data
The JSON data of the language.
Definition LanguageStrings.hpp:19
std::string_view name
The name of the language.
Definition LanguageStrings.hpp:18