13 #include <unordered_map> 22 explicit CLocale(
const std::string& language);
23 CLocale(
const std::string& language,
const std::string& territory);
24 CLocale(
const std::string& language,
const std::string& territory,
const std::string& codeset);
25 CLocale(
const std::string& language,
const std::string& territory,
const std::string& codeset,
const std::string& modifier);
40 bool operator==(
const CLocale& other)
const;
41 inline bool operator!=(
const CLocale& other)
const {
return !(*
this == other); }
61 const std::string&
GetCodeset()
const {
return m_codeset; }
111 bool Equals(
const std::string& locale)
const;
123 bool Matches(
const std::string& locale)
const;
132 std::string
FindBestMatch(
const std::set<std::string>& locales)
const;
145 std::string
FindBestMatch(
const std::unordered_map<std::string, std::string>& locales)
const;
148 static bool CheckValidity(
const std::string& language,
const std::string& territory,
const std::string& codeset,
const std::string& modifier);
149 static bool ParseLocale(
const std::string &locale, std::string &language, std::string &territory, std::string &codeset, std::string &modifier);
153 int GetMatchRank(
const std::string& locale)
const;
155 bool m_valid =
false;
156 std::string m_language;
157 std::string m_territory;
158 std::string m_codeset;
159 std::string m_modifier;
std::string FindBestMatch(const std::set< std::string > &locales) const
Tries to find the locale in the given list that matches this locale best.
Definition: Locale.cpp:156
const std::string & GetModifier() const
Returns the modifier of the locale.
Definition: Locale.h:65
static const CLocale Empty
Empty (and invalid) CLocale instance.
Definition: Locale.h:31
static CLocale FromString(const std::string &locale)
Parses the given string representation and turns it into a locale.
Definition: Locale.cpp:60
const std::string & GetLanguageCode() const
Returns the (lower-case) ISO 639-1 language code of the locale.
Definition: Locale.h:53
const std::string & GetCodeset() const
Returns the codeset of the locale.
Definition: Locale.h:61
std::string ToString() const
Returns the full string representation of the locale.
Definition: Locale.cpp:77
bool Equals(const std::string &locale) const
Checks if the given string representation of a locale exactly matches the locale. ...
Definition: Locale.cpp:128
std::string ToStringLC() const
Returns the full string representation of the locale in lowercase.
Definition: Locale.cpp:93
const std::string & GetTerritoryCode() const
Returns the (upper-case) ISO 3166-1 Alpha-2 territory code of the locale.
Definition: Locale.h:57
bool Matches(const std::string &locale) const
Checks if the given string representation of a locale partly matches the locale.
Definition: Locale.cpp:135
std::string ToShortStringLC() const
Returns the short string representation of the locale in lowercase.
Definition: Locale.cpp:117
bool IsValid() const
Whether the locale is valid or not.
Definition: Locale.h:48
Class representing a full locale of the form [language[_territory][.codeset][@modifier]].
Definition: Locale.h:18
std::string ToShortString() const
Returns the short string representation of the locale.
Definition: Locale.cpp:104