libzypp  10.5.0
LanguageCode.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_LANGUAGECODE_H
00013 #define ZYPP_LANGUAGECODE_H
00014 
00015 #include <iosfwd>
00016 #include <string>
00017 
00018 #include "zypp/base/PtrTypes.h"
00019 
00021 namespace zypp
00022 { 
00023 
00024   class LanguageCode;
00025   inline bool operator==( const LanguageCode & lhs, const LanguageCode & rhs );
00026   inline bool operator!=( const LanguageCode & lhs, const LanguageCode & rhs );
00027 
00029   //
00030   //    CLASS NAME : LanguageCode
00031   //
00037   class LanguageCode
00038   {
00039     friend std::ostream & operator<<( std::ostream & str, const LanguageCode & obj );
00040 
00041   public:
00043     class Impl;
00044 
00045   public:
00047     LanguageCode();
00048 
00050     explicit
00051     LanguageCode( const std::string & code_r );
00052 
00054     ~LanguageCode();
00055 
00056   public:
00060     static const LanguageCode noCode;
00062 
00063   public:
00065     std::string code() const;
00066 
00068     std::string name() const;
00069 
00071     inline bool hasCode() const
00072     { return *this != noCode; }
00073 
00074   private:
00076     RW_pointer<Impl> _pimpl;
00077   };
00079 
00081   inline std::ostream & operator<<( std::ostream & str, const LanguageCode & obj )
00082   { return str << obj.code(); }
00083 
00087   inline bool operator==( const LanguageCode & lhs, const LanguageCode & rhs ) {
00088     return( lhs.code() == rhs.code() );
00089   }
00091   inline bool operator==( const std::string & lhs, const LanguageCode & rhs ) {
00092     return( lhs == rhs.code() );
00093   }
00095   inline bool operator==( const LanguageCode & lhs, const std::string & rhs ) {
00096     return( lhs.code() == rhs );
00097   }
00098 
00100   inline bool operator!=( const LanguageCode & lhs, const LanguageCode & rhs ) {
00101     return( ! operator==( lhs, rhs ) );
00102   }
00104   inline bool operator!=( const std::string & lhs, const LanguageCode & rhs ) {
00105     return( ! operator==( lhs, rhs ) );
00106   }
00108   inline bool operator!=( const LanguageCode & lhs, const std::string & rhs ) {
00109     return( ! operator==( lhs, rhs ) );
00110   }
00112 
00114 } // namespace zypp
00116 
00118 namespace std
00119 { 
00120 
00121   template<>
00122     inline bool less<zypp::LanguageCode>::operator()( const zypp::LanguageCode & lhs, const zypp::LanguageCode & rhs ) const
00123     { return lhs.code() < rhs.code(); }
00125 } // namespace std
00127 #endif // ZYPP_LANGUAGECODE_H