libzypp 17.37.17
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#include <zypp/Globals.h>
20
21#include <zypp/IdStringType.h>
22#include <zypp/LanguageCode.h>
23#include <zypp/CountryCode.h>
24
26namespace zypp
27{
28 class Locale;
29 using LocaleSet = std::unordered_set<Locale>;
30
50 class ZYPP_API Locale : public IdStringType<Locale>
51 {
52 public:
54 Locale();
55
57 explicit Locale( IdString str_r );
58
60 explicit Locale( const std::string & str_r );
61
63 explicit Locale( const char * str_r );
64
66 Locale( const LanguageCode& language_r, const CountryCode& country_r = CountryCode() );
67
69 ~Locale();
70
71 public:
74
75 static const Locale noCode;
76
78 static const Locale enCode;
80
81 public:
83 LanguageCode language() const;
84
86 CountryCode country() const;
87
89 std::string code() const
90 { return std::string(_str); }
91
93 std::string name() const;
94
95 public:
100 Locale fallback() const;
101
109 static Locale bestMatch( const LocaleSet & avLocales_r, Locale requested_r = Locale() );
110
111 private:
112 friend class IdStringType<Locale>;
114 };
115} // namespace zypp
117
119
120#endif // ZYPP_LOCALE_H
Country codes (iso3166-1-alpha-2).
Definition CountryCode.h:31
Access to the sat-pools string space.
Definition IdString.h:44
Language codes (iso639_2/iso639_1).
'Language[_Country]' codes.
Definition Locale.h:51
CountryCode country() const
The county part.
Definition Locale.cc:202
static const Locale enCode
Last resort "en".
Definition Locale.h:78
std::string code() const
Return the locale code asString.
Definition Locale.h:89
static const Locale noCode
Empty code.
Definition Locale.h:75
Locale()
Default Ctor: noCode.
Definition Locale.cc:177
IdString _str
Definition Locale.h:113
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.
@ language
language support
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
#define ZYPP_DEFINE_ID_HASHABLE(C)
Define hash function for id based classes.
Definition Hash.h:26