-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalization.hpp
106 lines (88 loc) · 2.98 KB
/
Localization.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once
#include <string>
#include <map>
#include <tinyxml2.h>
#include "AbstractSerializable.hpp"
namespace nejlika
{
/**
* @brief Represents a localization.
*
* A map of language codes to localized strings.
*/
class Localization : public AbstractSerializable
{
public:
/**
* @brief Constructs a new Localization object.
*/
Localization();
/**
* @brief Gets the localized string for the specified language code.
*
* @param languageCode The language code to get the localized string for.
* @return The localized string for the specified language code or an empty string if the language code is not found.
*/
const std::string& Get(const std::string& languageCode) const;
/**
* @brief Sets the localized string for the specified language code.
*
* @param languageCode The language code to set the localized string for.
* @param value The localized string to set.
*/
void Set(const std::string& languageCode, const std::string& value);
/**
* @brief Get the map of language codes to localized strings.
*
* @return The map of language codes to localized strings.
*/
const std::map<std::string, std::string>& GetMap() const;
/**
* @brief Gets weather or not any localized strings exist.
*
* @return Weather or not any localized strings exist.
*/
bool IsEmpty() const;
/**
* @brief Gets the localized string for the specified language code.
*
* @param languageCode The language code to get the localized string for.
* @return The localized string for the specified language code or an empty string if the language code is not found.
*/
const std::string& operator[](const std::string& languageCode) const;
/**
* @brief Gets the localized string for the specified language code.
*
* @param languageCode The language code to get the localized string for.
* @return The localized string for the specified language code or an empty string if the language code is not found.
*/
std::string& operator[](const std::string& languageCode);
/**
* @brief Serializes the object into a JSON object.
*
* @return The serialized JSON object.
*/
boost::json::object Serialize() const override;
/**
* @brief Deserializes the specified JSON object into the object.
*
* @param json The JSON object to deserialize.
*/
void Deserialize(const boost::json::object& json) override;
/**
* @brief Serializes the object into a XML object.
*
* @return The serialized XML object.
*/
tinyxml2::XMLElement* Serialize(tinyxml2::XMLDocument& document) const;
/**
* @brief Deserializes the specified XML object into the object.
*
* @param xml The XML object to deserialize.
*/
void Deserialize(const tinyxml2::XMLElement* xml);
private:
static const std::string m_EmptyString;
std::map<std::string, std::string> m_Strings;
};
}