libzypp  17.35.19
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:
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
static const Locale noCode
Empty code.
Definition: Locale.h:75
std::string code() const
Return the locale code asString.
Definition: Locale.h:89
static const Locale enCode
Last resort "en".
Definition: Locale.h:78
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:29
IdString _str
Definition: Locale.h:113
Access to the sat-pools string space.
Definition: IdString.h:43
Base class for creating IdString based types.
Definition: IdStringType.h:86
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition: ResTraits.h:93
&#39;Language[_Country]&#39; codes.
Definition: Locale.h:50
ZYPP_DEFINE_ID_HASHABLE(::zypp::Locale)
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
Language codes (iso639_2/iso639_1).
Definition: LanguageCode.h:30
Country codes (iso3166-1-alpha-2).
Definition: CountryCode.h:30