libzypp 17.31.23
Locale.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_LOCALE_H
13#define ZYPP_LOCALE_H
14
15#include <iosfwd>
16#include <string>
17
18#include <zypp/base/Hash.h>
19
20#include <zypp/IdStringType.h>
21#include <zypp/LanguageCode.h>
22#include <zypp/CountryCode.h>
23
25namespace zypp
26{
27 class Locale;
28 typedef std::unordered_set<Locale> LocaleSet;
29
49 class Locale : public IdStringType<Locale>
50 {
51 public:
53 Locale();
54
56 explicit Locale( IdString str_r );
57
59 explicit Locale( const std::string & str_r );
60
62 explicit Locale( const char * str_r );
63
65 Locale( LanguageCode language_r, CountryCode country_r = CountryCode() );
66
68 ~Locale();
69
70 public:
74 static const Locale noCode;
75
77 static const Locale enCode;
79
80 public:
82 LanguageCode language() const;
83
85 CountryCode country() const;
86
88 std::string code() const
89 { return std::string(_str); }
90
92 std::string name() const;
93
94 public:
99 Locale fallback() const;
100
108 static Locale bestMatch( const LocaleSet & avLocales_r, Locale requested_r = Locale() );
109
110 private:
111 friend class IdStringType<Locale>;
113 };
114} // namespace zypp
116
118
119#endif // ZYPP_LOCALE_H
Country codes (iso3166-1-alpha-2).
Definition: CountryCode.h:31
Base class for creating IdString based types.
Definition: IdStringType.h:87
Access to the sat-pools string space.
Definition: IdString.h:43
Language codes (iso639_2/iso639_1).
Definition: LanguageCode.h:31
'Language[_Country]' codes.
Definition: Locale.h:50
Locale fallback() const
Return the fallback locale for this locale, if no fallback exists the empty Locale::noCode.
Definition: Locale.cc:208
CountryCode country() const
The county part.
Definition: Locale.cc:202
static const Locale enCode
Last resort "en".
Definition: Locale.h:77
std::string name() const
Return the translated locale name.
Definition: Locale.cc:205
std::string code() const
Return the locale code asString.
Definition: Locale.h:88
LanguageCode language() const
The language part.
Definition: Locale.cc:199
static const Locale noCode
Empty code.
Definition: Locale.h:74
Locale()
Default Ctor: noCode.
Definition: Locale.cc:177
IdString _str
Definition: Locale.h:112
~Locale()
Dtor.
Definition: Locale.cc:196
static Locale bestMatch(const LocaleSet &avLocales_r, Locale requested_r=Locale())
Return the best match for Locale requested_r within the available avLocales_r.
Definition: Locale.cc:213
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
#define ZYPP_DEFINE_ID_HASHABLE(C)
Define hash function for id based classes.
Definition: Hash.h:26