doxygen fixes
[platform/upstream/libzypp.git] / zypp / Locale.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/Locale.h
10  *
11 */
12 #ifndef ZYPP_LOCALE_H
13 #define ZYPP_LOCALE_H
14
15 #include <iosfwd>
16
17 #include "zypp/base/PtrTypes.h"
18
19 #include "zypp/LanguageCode.h"
20 #include "zypp/CountryCode.h"
21
22 ///////////////////////////////////////////////////////////////////
23 namespace zypp
24 { /////////////////////////////////////////////////////////////////
25
26   ///////////////////////////////////////////////////////////////////
27   //
28   //    CLASS NAME : Locale
29   //
30   /** */
31   class Locale
32   {
33     friend std::ostream & operator<<( std::ostream & str, const Locale & obj );
34
35   public:
36     /** Implementation  */
37     class Impl;
38
39   public:
40     /** Default ctor */
41     Locale();
42
43     /** Ctor taking a string. */
44     explicit
45     Locale( const std::string & code_r );
46
47     /** Ctor taking LanguageCode and optional CountryCode. */
48     Locale( const LanguageCode & language_r,
49             const CountryCode & country_r = CountryCode() );
50
51     /** Dtor */
52     ~Locale();
53
54   public:
55     /** \name Locale constants. */
56     //@{
57     /** No or empty code. */
58     static const Locale noCode;
59     //@}
60
61   public:
62     /** */
63     const LanguageCode & language() const;
64     /** */
65     const CountryCode & country() const;
66
67     /** Return the locale code. */
68     std::string code() const;
69
70     /** Return the name made of language and country name. */
71     std::string name() const;
72
73     /** Return a fallback locale for this locale, when giving up, returns empty Locale() */
74     Locale fallback() const;
75
76   private:
77     /** Pointer to implementation */
78     RW_pointer<Impl> _pimpl;
79   };
80   ///////////////////////////////////////////////////////////////////
81
82   /** \relates Locale Stream output */
83   inline std::ostream & operator<<( std::ostream & str, const Locale & obj )
84   { return str << obj.code(); }
85
86   /** Comparison based on string value. */
87   //@{
88   /** \relates Locale */
89   inline bool operator==( const Locale & lhs, const Locale & rhs ) {
90     return( lhs.code() == rhs.code() );
91   }
92   /** \relates Locale */
93   inline bool operator==( const std::string & lhs, const Locale & rhs ) {
94     return( lhs == rhs.code() );
95   }
96   /** \relates Locale */
97   inline bool operator==( const Locale & lhs, const std::string & rhs ) {
98     return( lhs.code() == rhs );
99   }
100
101   /** \relates Locale */
102   inline bool operator!=( const Locale & lhs, const Locale & rhs ) {
103     return( ! operator==( lhs, rhs ) );
104   }
105   /** \relates Locale */
106   inline bool operator!=( const std::string & lhs, const Locale & rhs ) {
107     return( ! operator==( lhs, rhs ) );
108   }
109   /** \relates Locale */
110   inline bool operator!=( const Locale & lhs, const std::string & rhs ) {
111     return( ! operator==( lhs, rhs ) );
112   }
113   //@}
114
115   /////////////////////////////////////////////////////////////////
116 } // namespace zypp
117 ///////////////////////////////////////////////////////////////////
118
119 ///////////////////////////////////////////////////////////////////
120 namespace std
121 { /////////////////////////////////////////////////////////////////
122   /** \relates zypp::Locale Default order for std::container based on code string value.*/
123   template<>
124     inline bool less<zypp::Locale>::operator()( const zypp::Locale & lhs, const zypp::Locale & rhs ) const
125     { return lhs.code() < rhs.code(); }
126   /////////////////////////////////////////////////////////////////
127 } // namespace std
128 ///////////////////////////////////////////////////////////////////
129 #endif // ZYPP_LOCALE_H