libzypp  10.5.0
CountryCode.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_COUNTRYCODE_H
00013 #define ZYPP_COUNTRYCODE_H
00014 
00015 #include <iosfwd>
00016 #include <string>
00017 
00018 #include "zypp/base/PtrTypes.h"
00019 
00021 namespace zypp
00022 { 
00023 
00024   class CountryCode;
00025   inline bool operator==( const CountryCode & lhs, const CountryCode & rhs );
00026   inline bool operator!=( const CountryCode & lhs, const CountryCode & rhs );
00027 
00029   //
00030   //    CLASS NAME : CountryCode
00031   //
00037   class CountryCode
00038   {
00039     friend std::ostream & operator<<( std::ostream & str, const CountryCode & obj );
00040 
00041   public:
00043     class Impl;
00044 
00045   public:
00047     CountryCode();
00048 
00050     explicit
00051     CountryCode( const std::string & code_r );
00052 
00054     ~CountryCode();
00055 
00056   public:
00057 
00061     static const CountryCode noCode;
00063 
00064   public:
00066     std::string code() const;
00067 
00069     std::string name() const;
00070 
00072     bool hasCode() const
00073     { return *this != noCode; }
00074 
00075   private:
00077     RW_pointer<Impl> _pimpl;
00078   };
00080 
00082   inline std::ostream & operator<<( std::ostream & str, const CountryCode & obj )
00083   { return str << obj.code(); }
00084 
00088   inline bool operator==( const CountryCode & lhs, const CountryCode & rhs ) {
00089     return( lhs.code() == rhs.code() );
00090   }
00092   inline bool operator==( const std::string & lhs, const CountryCode & rhs ) {
00093     return( lhs == rhs.code() );
00094   }
00096   inline bool operator==( const CountryCode & lhs, const std::string & rhs ) {
00097     return( lhs.code() == rhs );
00098   }
00099 
00101   inline bool operator!=( const CountryCode & lhs, const CountryCode & rhs ) {
00102     return( ! operator==( lhs, rhs ) );
00103   }
00105   inline bool operator!=( const std::string & lhs, const CountryCode & rhs ) {
00106     return( ! operator==( lhs, rhs ) );
00107   }
00109   inline bool operator!=( const CountryCode & lhs, const std::string & rhs ) {
00110     return( ! operator==( lhs, rhs ) );
00111   }
00113 
00115 } // namespace zypp
00117 
00119 namespace std
00120 { 
00121 
00122   template<>
00123     inline bool less<zypp::CountryCode>::operator()( const zypp::CountryCode & lhs, const zypp::CountryCode & rhs ) const
00124     { return lhs.code() < rhs.code(); }
00126 } // namespace std
00128 #endif // ZYPP_COUNTRYCODE_H