libzypp  17.14.0
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 
25 namespace 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