libzypp 17.37.10

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
26 namespace 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>;
113 IdString _str;
114 };
115} // namespace zypp
117
118 ZYPP_DEFINE_ID_HASHABLE( ::zypp::Locale );
119
120#endif // ZYPP_LOCALE_H
CountryCode.h
IdStringType.h
LanguageCode.h
zypp::CountryCode
Country codes (iso3166-1-alpha-2).
Definition CountryCode.h:31
zypp::IdStringType< Locale >::IdStringType
IdStringType()=default
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:44
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:202
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:177
zypp::Locale::_str
IdString _str
Definition Locale.h:113
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:213
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
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_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
ZYPP_DEFINE_ID_HASHABLE
#define ZYPP_DEFINE_ID_HASHABLE(C)
Define hash function for id based classes.
Definition Hash.h:26
Globals.h
Hash.h