00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_LOCALE_H
00013 #define ZYPP_LOCALE_H
00014
00015 #include <iosfwd>
00016
00017 #include "zypp/base/PtrTypes.h"
00018
00019 #include "zypp/LanguageCode.h"
00020 #include "zypp/CountryCode.h"
00021
00023 namespace zypp
00024 {
00025
00027
00028
00029
00031 class Locale
00032 {
00033 friend std::ostream & operator<<( std::ostream & str, const Locale & obj );
00034
00035 public:
00037 class Impl;
00038
00039 public:
00041 Locale();
00042
00044 explicit
00045 Locale( const std::string & code_r );
00046
00048 Locale( const LanguageCode & language_r,
00049 const CountryCode & country_r = CountryCode() );
00050
00052 ~Locale();
00053
00054 public:
00058 static const Locale noCode;
00060
00061 public:
00063 const LanguageCode & language() const;
00065 const CountryCode & country() const;
00066
00068 std::string code() const;
00069
00071 std::string name() const;
00072
00074 Locale fallback() const;
00075
00076 private:
00078 RW_pointer<Impl> _pimpl;
00079 };
00081
00083 inline std::ostream & operator<<( std::ostream & str, const Locale & obj )
00084 { return str << obj.code(); }
00085
00089 inline bool operator==( const Locale & lhs, const Locale & rhs ) {
00090 return( lhs.code() == rhs.code() );
00091 }
00093 inline bool operator==( const std::string & lhs, const Locale & rhs ) {
00094 return( lhs == rhs.code() );
00095 }
00097 inline bool operator==( const Locale & lhs, const std::string & rhs ) {
00098 return( lhs.code() == rhs );
00099 }
00100
00102 inline bool operator!=( const Locale & lhs, const Locale & rhs ) {
00103 return( ! operator==( lhs, rhs ) );
00104 }
00106 inline bool operator!=( const std::string & lhs, const Locale & rhs ) {
00107 return( ! operator==( lhs, rhs ) );
00108 }
00110 inline bool operator!=( const Locale & lhs, const std::string & rhs ) {
00111 return( ! operator==( lhs, rhs ) );
00112 }
00114
00116 }
00118
00120 namespace std
00121 {
00122
00123 template<>
00124 inline bool less<zypp::Locale>::operator()( const zypp::Locale & lhs, const zypp::Locale & rhs ) const
00125 { return lhs.code() < rhs.code(); }
00127 }
00129 #endif // ZYPP_LOCALE_H