libzypp: zypp/Locale.h Source File

libzypp 17.38.14

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-core/base/Hash.h>
19#include <zypp-core/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
102#ifndef ZYPPNG
110 static Locale bestMatch( const LocaleSet & avLocales_r, Locale requested_r = Locale() );
111#endif
112
113 private:
114 friend class IdStringType<Locale>;
115 IdString _str;
116 };
117} // namespace zypp
119
120 ZYPP_DEFINE_ID_HASHABLE( ::zypp::Locale );
121
122#endif // ZYPP_LOCALE_H
CountryCode.h
Globals.h
Provides API related macros.
Hash.h
ZYPP_DEFINE_ID_HASHABLE
#define ZYPP_DEFINE_ID_HASHABLE(C)
Define hash function for id based classes.
Definition Hash.h:26
IdStringType.h
LanguageCode.h
zypp::CountryCode
Country codes (iso3166-1-alpha-2).
Definition CountryCode.h:31
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:55
zypp::LanguageCode
Language codes (iso639_2/iso639_1).
Definition LanguageCode.h:31
zypp::Locale
'Language[_Country]' codes.
Definition Locale.h:51
zypp::Locale::country
CountryCode country() const
The county part.
Definition Locale.cc:205
zypp::Locale::enCode
static const Locale enCode
Last resort "en".
Definition Locale.h:78
zypp::Locale::code
std::string code() const
Return the locale code asString.
Definition Locale.h:89
zypp::Locale::noCode
static const Locale noCode
Empty code.
Definition Locale.h:75
zypp::Locale::Locale
Locale()
Default Ctor: noCode.
Definition Locale.cc:180
zypp::Locale::_str
IdString _str
Definition Locale.h:115
zypp::Locale::bestMatch
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:215
zypp::IdStringType< Locale >::IdStringType
IdStringType()=default
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::ResolverNamespace::language
@ language
language support
Definition ResolverNamespace.h:26
zypp::LocaleSet
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173