1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Locale.h
17 #include "zypp/base/PtrTypes.h"
19 #include "zypp/LanguageCode.h"
20 #include "zypp/CountryCode.h"
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////
28 // CLASS NAME : Locale
33 friend std::ostream & operator<<( std::ostream & str, const Locale & obj );
43 /** Ctor taking a string. */
45 Locale( const std::string & code_r );
47 /** Ctor taking LanguageCode and optional CountryCode. */
48 Locale( const LanguageCode & language_r,
49 const CountryCode & country_r = CountryCode() );
55 /** \name Locale constants. */
57 /** No or empty code. */
58 // static const Locale noCode;
63 const LanguageCode & language() const;
65 const CountryCode & country() const;
67 /** Return the locale code. */
68 std::string code() const;
70 /** Return the name made of language and country name. */
71 std::string name() const;
74 /** Pointer to implementation */
75 RW_pointer<Impl> _pimpl;
77 ///////////////////////////////////////////////////////////////////
79 /** \relates Locale Stream output */
80 inline std::ostream & operator<<( std::ostream & str, const Locale & obj )
81 { return str << obj.code(); }
83 /** Comparison based on string value. */
85 /** \relates Locale */
86 inline bool operator==( const Locale & lhs, const Locale & rhs ) {
87 return( lhs.code() == rhs.code() );
89 /** \relates Locale */
90 inline bool operator==( const std::string & lhs, const Locale & rhs ) {
91 return( lhs == rhs.code() );
93 /** \relates Locale */
94 inline bool operator==( const Locale & lhs, const std::string & rhs ) {
95 return( lhs.code() == rhs );
98 /** \relates Locale */
99 inline bool operator!=( const Locale & lhs, const Locale & rhs ) {
100 return( ! operator==( lhs, rhs ) );
102 /** \relates Locale */
103 inline bool operator!=( const std::string & lhs, const Locale & rhs ) {
104 return( ! operator==( lhs, rhs ) );
106 /** \relates Locale */
107 inline bool operator!=( const Locale & lhs, const std::string & rhs ) {
108 return( ! operator==( lhs, rhs ) );
112 /////////////////////////////////////////////////////////////////
114 ///////////////////////////////////////////////////////////////////
116 ///////////////////////////////////////////////////////////////////
118 { /////////////////////////////////////////////////////////////////
119 /** \relates Locale Default order for std::container based on code string value.*/
121 inline bool less<zypp::Locale>::operator()( const zypp::Locale & lhs, const zypp::Locale & rhs ) const
122 { return lhs.code() < rhs.code(); }
123 /////////////////////////////////////////////////////////////////
125 ///////////////////////////////////////////////////////////////////
126 #endif // ZYPP_LOCALE_H