///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : IdString
- //
- /** Access to the sat-pools string space.
- *
- * Construction from string will place a copy of the string in the
- * string space, if it is not already present.
- *
- * While comparison differs between \ref IdString::Null and \ref IdString::Empty
- * ( \c NULL and \c "" ), both are represented by an empty string \c "".
- */
- class IdString: protected sat::detail::PoolMember,
- private base::SafeBool<IdString>
- {
- public:
- /** Default ctor, empty string. */
- IdString() : _id( 1 ) {}
-
- /** Ctor from id. */
- explicit IdString( sat::detail::IdType id_r ) : _id( id_r ) {}
-
- /** Ctor from string. */
- explicit IdString( const char * str_r );
-
- /** Ctor from string. */
- explicit IdString( const std::string & str_r );
-
- public:
- /** No or Null string ( Id \c 0 ). */
- static const IdString Null;
-
- /** Empty string. */
- static const IdString Empty;
-
- public:
- /** Evaluate in a boolean context <tt>( != \c Null )</tt>. */
- using base::SafeBool<IdString>::operator bool_type;
-
- /** Whether the string is empty.
- * This is true for \ref Null and \ref Empty.
- */
- bool empty() const
- { return( _id == 1 || _id == 0 ); }
-
- /** The strings size. */
- unsigned size() const;
-
- public:
- /** Conversion to <tt>const char *</tt> */
- const char * c_str() const;
-
- /** Conversion to <tt>std::string</tt> */
- std::string string() const
- { return c_str(); }
-
- /** \overload */
- std::string asString() const
- { return c_str(); }
-
- public:
- /** Fast compare equal. */
- bool compareEQ( const IdString & rhs ) const
- { return( _id == rhs.id() ); }
-
- /** Compare IdString returning <tt>-1,0,1</tt>. */
- int compare( const IdString & rhs ) const;
-
- /** \overload */
- int compare( const char * rhs ) const;
-
- /** \overload */
- int compare( const std::string & rhs ) const
- { return compare( rhs.c_str() ); }
-
- public:
- /** Expert backdoor. */
- sat::detail::IdType id() const
- { return _id; }
- private:
- friend base::SafeBool<IdString>::operator bool_type() const;
- bool boolTest() const { return _id; }
- private:
- sat::detail::IdType _id;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates IdString Stream output */
- std::ostream & operator<<( std::ostream & str, const IdString & obj );
-
- /** \relates IdString Equal */
- inline bool operator==( const IdString & lhs, const IdString & rhs )
- { return lhs.compareEQ( rhs ); }
- /** \overload */
- inline bool operator==( const IdString & lhs, const char * rhs )
- { return lhs.compare( rhs ) == 0; }
- /** \overload */
- inline bool operator==( const IdString & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) == 0; }
- /** \overload */
- inline bool operator==( const char * lhs, const IdString & rhs )
- { return rhs.compare( lhs ) == 0; }
- /** \overload */
- inline bool operator==( const std::string & lhs, const IdString & rhs )
- { return rhs.compare( lhs ) == 0; }
-
- /** \relates IdString NotEqual */
- inline bool operator!=( const IdString & lhs, const IdString & rhs )
- { return ! lhs.compareEQ( rhs ); }
- /** \overload */
- inline bool operator!=( const IdString & lhs, const char * rhs )
- { return lhs.compare( rhs ) != 0; }
- /** \overload */
- inline bool operator!=( const IdString & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) != 0; }
- /** \overload */
- inline bool operator!=( const char * lhs, const IdString & rhs )
- { return rhs.compare( lhs ) != 0; }
- /** \overload */
- inline bool operator!=( const std::string & lhs, const IdString & rhs )
- { return rhs.compare( lhs ) != 0; }
-
- /** \relates IdString Less */
- inline bool operator<( const IdString & lhs, const IdString & rhs )
- { return lhs.compare( rhs ) < 0; }
- /** \overload */
- inline bool operator<( const IdString & lhs, const char * rhs )
- { return lhs.compare( rhs ) < 0; }
- /** \overload */
- inline bool operator<( const IdString & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) < 0; }
- /** \overload */
- inline bool operator<( const char * lhs, const IdString & rhs )
- { return rhs.compare( lhs ) >= 0; }
- /** \overload */
- inline bool operator<( const std::string & lhs, const IdString & rhs )
- { return rhs.compare( lhs ) >= 0; }
-
- /** \relates IdString LessEqual*/
- inline bool operator<=( const IdString & lhs, const IdString & rhs )
- { return lhs.compare( rhs ) <= 0; }
- /** \overload */
- inline bool operator<=( const IdString & lhs, const char * rhs )
- { return lhs.compare( rhs ) <= 0; }
- /** \overload */
- inline bool operator<=( const IdString & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) <= 0; }
- /** \overload */
- inline bool operator<=( const char * lhs, const IdString & rhs )
- { return rhs.compare( lhs ) > 0; }
- /** \overload */
- inline bool operator<=( const std::string & lhs, const IdString & rhs )
- { return rhs.compare( lhs ) > 0; }
-
- /** \relates IdString Greater */
- inline bool operator>( const IdString & lhs, const IdString & rhs )
- { return lhs.compare( rhs ) > 0; }
- /** \overload */
- inline bool operator>( const IdString & lhs, const char * rhs )
- { return lhs.compare( rhs ) > 0; }
- /** \overload */
- inline bool operator>( const IdString & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) > 0; }
- /** \overload */
- inline bool operator>( const char * lhs, const IdString & rhs )
- { return rhs.compare( lhs ) <= 0; }
- /** \overload */
- inline bool operator>( const std::string & lhs, const IdString & rhs )
- { return rhs.compare( lhs ) <= 0; }
-
- /** \relates IdString GreaterEqual */
- inline bool operator>=( const IdString & lhs, const IdString & rhs )
- { return lhs.compare( rhs ) >= 0; }
- /** \overload */
- inline bool operator>=( const IdString & lhs, const char * rhs )
- { return lhs.compare( rhs ) >= 0; }
- /** \overload */
- inline bool operator>=( const IdString & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) >= 0; }
- /** \overload */
- inline bool operator>=( const char * lhs, const IdString & rhs )
- { return rhs.compare( lhs ) < 0; }
- /** \overload */
- inline bool operator>=( const std::string & lhs, const IdString & rhs )
- { return rhs.compare( lhs ) < 0; }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : IdString
+ //
+ /** Access to the sat-pools string space.
+ *
+ * Construction from string will place a copy of the string in the
+ * string space, if it is not already present.
+ *
+ * While comparison differs between \ref IdString::Null and \ref IdString::Empty
+ * ( \c NULL and \c "" ), both are represented by an empty string \c "".
+ */
+ class IdString: protected sat::detail::PoolMember,
+ private base::SafeBool<IdString>
+ {
+ public:
+ /** Default ctor, empty string. */
+ IdString() : _id( 1 ) {}
+
+ /** Ctor from id. */
+ explicit IdString( sat::detail::IdType id_r ) : _id( id_r ) {}
+
+ /** Ctor from string. */
+ explicit IdString( const char * str_r );
+
+ /** Ctor from string. */
+ explicit IdString( const std::string & str_r );
+
+ public:
+ /** No or Null string ( Id \c 0 ). */
+ static const IdString Null;
+
+ /** Empty string. */
+ static const IdString Empty;
+
+ public:
+ /** Evaluate in a boolean context <tt>( != \c Null )</tt>. */
+ using base::SafeBool<IdString>::operator bool_type;
+
+ /** Whether the string is empty.
+ * This is true for \ref Null and \ref Empty.
+ */
+ bool empty() const
+ { return( _id == 1 || _id == 0 ); }
+
+ /** The strings size. */
+ unsigned size() const;
+
+ public:
+ /** Conversion to <tt>const char *</tt> */
+ const char * c_str() const;
+
+ /** Conversion to <tt>std::string</tt> */
+ std::string string() const
+ { return c_str(); }
+
+ /** \overload */
+ std::string asString() const
+ { return c_str(); }
+
+ public:
+ /** Fast compare equal. */
+ bool compareEQ( const IdString & rhs ) const
+ { return( _id == rhs.id() ); }
+
+ /** Compare IdString returning <tt>-1,0,1</tt>. */
+ int compare( const IdString & rhs ) const;
+
+ /** \overload */
+ int compare( const char * rhs ) const;
+
+ /** \overload */
+ int compare( const std::string & rhs ) const
+ { return compare( rhs.c_str() ); }
+
+ public:
+ /** Expert backdoor. */
+ sat::detail::IdType id() const
+ { return _id; }
+ private:
+ friend base::SafeBool<IdString>::operator bool_type() const;
+ bool boolTest() const { return _id; }
+ private:
+ sat::detail::IdType _id;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates IdString Stream output */
+ std::ostream & operator<<( std::ostream & str, const IdString & obj );
+
+ /** \relates IdString Equal */
+ inline bool operator==( const IdString & lhs, const IdString & rhs )
+ { return lhs.compareEQ( rhs ); }
+ /** \overload */
+ inline bool operator==( const IdString & lhs, const char * rhs )
+ { return lhs.compare( rhs ) == 0; }
+ /** \overload */
+ inline bool operator==( const IdString & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) == 0; }
+ /** \overload */
+ inline bool operator==( const char * lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) == 0; }
+ /** \overload */
+ inline bool operator==( const std::string & lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) == 0; }
+
+ /** \relates IdString NotEqual */
+ inline bool operator!=( const IdString & lhs, const IdString & rhs )
+ { return ! lhs.compareEQ( rhs ); }
+ /** \overload */
+ inline bool operator!=( const IdString & lhs, const char * rhs )
+ { return lhs.compare( rhs ) != 0; }
+ /** \overload */
+ inline bool operator!=( const IdString & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) != 0; }
+ /** \overload */
+ inline bool operator!=( const char * lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) != 0; }
+ /** \overload */
+ inline bool operator!=( const std::string & lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) != 0; }
+
+ /** \relates IdString Less */
+ inline bool operator<( const IdString & lhs, const IdString & rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ inline bool operator<( const IdString & lhs, const char * rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ inline bool operator<( const IdString & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ inline bool operator<( const char * lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) >= 0; }
+ /** \overload */
+ inline bool operator<( const std::string & lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) >= 0; }
+
+ /** \relates IdString LessEqual*/
+ inline bool operator<=( const IdString & lhs, const IdString & rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ inline bool operator<=( const IdString & lhs, const char * rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ inline bool operator<=( const IdString & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ inline bool operator<=( const char * lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) > 0; }
+ /** \overload */
+ inline bool operator<=( const std::string & lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) > 0; }
+
+ /** \relates IdString Greater */
+ inline bool operator>( const IdString & lhs, const IdString & rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ inline bool operator>( const IdString & lhs, const char * rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ inline bool operator>( const IdString & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ inline bool operator>( const char * lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) <= 0; }
+ /** \overload */
+ inline bool operator>( const std::string & lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) <= 0; }
+
+ /** \relates IdString GreaterEqual */
+ inline bool operator>=( const IdString & lhs, const IdString & rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ inline bool operator>=( const IdString & lhs, const char * rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ inline bool operator>=( const IdString & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ inline bool operator>=( const char * lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) < 0; }
+ /** \overload */
+ inline bool operator>=( const std::string & lhs, const IdString & rhs )
+ { return rhs.compare( lhs ) < 0; }
/////////////////////////////////////////////////////////////////
} // namespace zypp
namespace zypp
{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : IdStringType<Derived>
- //
- /** Base class for creating \ref IdString based types.
- *
- * Just by deriving from \ref IdStringType a class provides all
- * the operations an \ref IdString does. (incl. conversion to string types,
- * comparison of string types and stream output).
- *
- * To disable any comparison, declare (but do not define) \ref _doCompare
- * in your class.
- * \code
- * class NoCompare : public IdStringType<NoCompare>
- * {
- * private:
- * static int _doCompare( const char * lhs, const char * rhs );
- *
- * };
- * \endcode
- *
- * If you need a different than the default lexicographical
- * order, write your own \ref _doCompare.
- *
- * \code
- * // uses default lexicographical order
- * class CaseCmp : public IdStringType<CaseCmp>
- * {
- * public:
- * CaseCmp() {}
- * explicit CaseCmp( const char * cstr_r ) : _str( cstr_r ) {}
- * private:
- * friend class IdStringType<CaseCmp>;
- * IdString _str;
- * };
- *
- * // uses case insensitive comparison order
- * class NoCaseCmp : public IdStringType<NoCaseCmp>
- * {
- * public:
- * NoCaseCmp() {}
- * explicit NoCaseCmp( const char * cstr_r ) : _str( cstr_r ) {}
- * private:
- * static int _doCompare( const char * lhs, const char * rhs )
- * {
- * if ( lhs == rhs ) return 0;
- * if ( lhs && rhs ) return ::strcasecmp( lhs, rhs );
- * return( lhs ? 1 : -1 );
- * }
- * private:
- * friend class IdStringType<NoCaseCmp>;
- * IdString _str;
- * };
- *
- * CaseCmp ca( "a" );
- * NoCaseCmp na( "a" );
- * DBG << "ca == a ? " << (ca == "a") << endl; // ca == a ? 1
- * DBG << "ca == A ? " << (ca == "A") << endl; // ca == A ? 0
- * DBG << "na == a ? " << (na == "a") << endl; // na == a ? 1
- * DBG << "na == A ? " << (na == "A") << endl; // na == A ? 1
- * \endcode
- * \ingroup g_CRTP
- */
- template <class Derived>
- class IdStringType : private base::SafeBool<Derived>
- {
- typedef typename base::SafeBool<Derived>::bool_type bool_type;
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : IdStringType<Derived>
+ //
+ /** Base class for creating \ref IdString based types.
+ *
+ * Just by deriving from \ref IdStringType a class provides all
+ * the operations an \ref IdString does. (incl. conversion to string types,
+ * comparison of string types and stream output).
+ *
+ * To disable any comparison, declare (but do not define) \ref _doCompare
+ * in your class.
+ * \code
+ * class NoCompare : public IdStringType<NoCompare>
+ * {
+ * private:
+ * static int _doCompare( const char * lhs, const char * rhs );
+ *
+ * };
+ * \endcode
+ *
+ * If you need a different than the default lexicographical
+ * order, write your own \ref _doCompare.
+ *
+ * \code
+ * // uses default lexicographical order
+ * class CaseCmp : public IdStringType<CaseCmp>
+ * {
+ * public:
+ * CaseCmp() {}
+ * explicit CaseCmp( const char * cstr_r ) : _str( cstr_r ) {}
+ * private:
+ * friend class IdStringType<CaseCmp>;
+ * IdString _str;
+ * };
+ *
+ * // uses case insensitive comparison order
+ * class NoCaseCmp : public IdStringType<NoCaseCmp>
+ * {
+ * public:
+ * NoCaseCmp() {}
+ * explicit NoCaseCmp( const char * cstr_r ) : _str( cstr_r ) {}
+ * private:
+ * static int _doCompare( const char * lhs, const char * rhs )
+ * {
+ * if ( lhs == rhs ) return 0;
+ * if ( lhs && rhs ) return ::strcasecmp( lhs, rhs );
+ * return( lhs ? 1 : -1 );
+ * }
+ * private:
+ * friend class IdStringType<NoCaseCmp>;
+ * IdString _str;
+ * };
+ *
+ * CaseCmp ca( "a" );
+ * NoCaseCmp na( "a" );
+ * DBG << "ca == a ? " << (ca == "a") << endl; // ca == a ? 1
+ * DBG << "ca == A ? " << (ca == "A") << endl; // ca == A ? 0
+ * DBG << "na == a ? " << (na == "a") << endl; // na == a ? 1
+ * DBG << "na == A ? " << (na == "A") << endl; // na == A ? 1
+ * \endcode
+ * \ingroup g_CRTP
+ */
+ template <class Derived>
+ class IdStringType : private base::SafeBool<Derived>
+ {
+ typedef typename base::SafeBool<Derived>::bool_type bool_type;
- protected:
- IdStringType() {}
- IdStringType(const IdStringType &) {}
- void operator=(const IdStringType &) {}
+ protected:
+ IdStringType() {}
+ IdStringType(const IdStringType &) {}
+ void operator=(const IdStringType &) {}
- private:
- const Derived & self() const { return *static_cast<const Derived*>( this ); }
+ private:
+ const Derived & self() const { return *static_cast<const Derived*>( this ); }
- public:
- const IdString & idStr() const { return self()._str; }
+ public:
+ const IdString & idStr() const { return self()._str; }
- bool empty() const { return idStr().empty(); }
- unsigned size() const { return idStr().size(); }
- const char * c_str() const { return idStr().c_str(); }
- std::string string() const { return idStr().string(); }
- std::string asString() const { return idStr().asString(); }
+ bool empty() const { return idStr().empty(); }
+ unsigned size() const { return idStr().size(); }
+ const char * c_str() const { return idStr().c_str(); }
+ std::string string() const { return idStr().string(); }
+ std::string asString() const { return idStr().asString(); }
- public:
- /** Evaluate in a boolean context <tt>( ! empty() )</tt>. */
- using base::SafeBool<Derived>::operator bool_type;
+ public:
+ /** Evaluate in a boolean context <tt>( ! empty() )</tt>. */
+ using base::SafeBool<Derived>::operator bool_type;
- public:
- static int compare( const Derived & lhs, const Derived & rhs ) { return compare( lhs.idStr(), rhs.idStr() ); }
- static int compare( const Derived & lhs, const IdString & rhs ) { return compare( lhs.idStr(), rhs ); }
- static int compare( const Derived & lhs, const std::string & rhs ) { return Derived::_doCompare( lhs.c_str(), rhs.c_str() ); }
- static int compare( const Derived & lhs, const char * rhs ) { return Derived::_doCompare( lhs.c_str(), rhs );}
+ public:
+ static int compare( const Derived & lhs, const Derived & rhs ) { return compare( lhs.idStr(), rhs.idStr() ); }
+ static int compare( const Derived & lhs, const IdString & rhs ) { return compare( lhs.idStr(), rhs ); }
+ static int compare( const Derived & lhs, const std::string & rhs ) { return Derived::_doCompare( lhs.c_str(), rhs.c_str() ); }
+ static int compare( const Derived & lhs, const char * rhs ) { return Derived::_doCompare( lhs.c_str(), rhs );}
- static int compare( const IdString & lhs, const Derived & rhs ) { return compare( lhs, rhs.idStr() ); }
- static int compare( const IdString & lhs, const IdString & rhs ) { return lhs.compareEQ( rhs ) ? 0 :
- Derived::_doCompare( lhs.c_str(), rhs.c_str() ); }
- static int compare( const IdString & lhs, const std::string & rhs ) { return Derived::_doCompare( lhs.c_str(), rhs.c_str() ); }
- static int compare( const IdString & lhs, const char * rhs ) { return Derived::_doCompare( lhs.c_str(), rhs ); }
+ static int compare( const IdString & lhs, const Derived & rhs ) { return compare( lhs, rhs.idStr() ); }
+ static int compare( const IdString & lhs, const IdString & rhs ) { return lhs.compareEQ( rhs ) ? 0 :
+ Derived::_doCompare( lhs.c_str(), rhs.c_str() ); }
+ static int compare( const IdString & lhs, const std::string & rhs ) { return Derived::_doCompare( lhs.c_str(), rhs.c_str() ); }
+ static int compare( const IdString & lhs, const char * rhs ) { return Derived::_doCompare( lhs.c_str(), rhs ); }
- static int compare( const std::string & lhs, const Derived & rhs ) { return Derived::_doCompare( lhs.c_str(), rhs.c_str() );}
- static int compare( const std::string & lhs, const IdString & rhs ) { return Derived::_doCompare( lhs.c_str(), rhs.c_str() ); }
- static int compare( const std::string & lhs, const std::string & rhs ) { return Derived::_doCompare( lhs.c_str(), rhs.c_str() ); }
- static int compare( const std::string & lhs, const char * rhs ) { return Derived::_doCompare( lhs.c_str(), rhs ); }
+ static int compare( const std::string & lhs, const Derived & rhs ) { return Derived::_doCompare( lhs.c_str(), rhs.c_str() );}
+ static int compare( const std::string & lhs, const IdString & rhs ) { return Derived::_doCompare( lhs.c_str(), rhs.c_str() ); }
+ static int compare( const std::string & lhs, const std::string & rhs ) { return Derived::_doCompare( lhs.c_str(), rhs.c_str() ); }
+ static int compare( const std::string & lhs, const char * rhs ) { return Derived::_doCompare( lhs.c_str(), rhs ); }
- static int compare( const char * lhs, const Derived & rhs ) { return Derived::_doCompare( lhs, rhs.c_str() );}
- static int compare( const char * lhs, const IdString & rhs ) { return Derived::_doCompare( lhs, rhs.c_str() ); }
- static int compare( const char * lhs, const std::string & rhs ) { return Derived::_doCompare( lhs, rhs.c_str() ); }
- static int compare( const char * lhs, const char * rhs ) { return Derived::_doCompare( lhs, rhs ); }
+ static int compare( const char * lhs, const Derived & rhs ) { return Derived::_doCompare( lhs, rhs.c_str() );}
+ static int compare( const char * lhs, const IdString & rhs ) { return Derived::_doCompare( lhs, rhs.c_str() ); }
+ static int compare( const char * lhs, const std::string & rhs ) { return Derived::_doCompare( lhs, rhs.c_str() ); }
+ static int compare( const char * lhs, const char * rhs ) { return Derived::_doCompare( lhs, rhs ); }
- public:
- int compare( const Derived & rhs ) const { return compare( idStr(), rhs.idStr() ); }
- int compare( const IdStringType & rhs ) const { return compare( idStr(), rhs.idStr() ); }
- int compare( const IdString & rhs ) const { return compare( idStr(), rhs ); }
- int compare( const std::string & rhs ) const { return Derived::_doCompare( c_str(), rhs.c_str() ); }
- int compare( const char * rhs ) const { return Derived::_doCompare( c_str(), rhs ); }
+ public:
+ int compare( const Derived & rhs ) const { return compare( idStr(), rhs.idStr() ); }
+ int compare( const IdStringType & rhs ) const { return compare( idStr(), rhs.idStr() ); }
+ int compare( const IdString & rhs ) const { return compare( idStr(), rhs ); }
+ int compare( const std::string & rhs ) const { return Derived::_doCompare( c_str(), rhs.c_str() ); }
+ int compare( const char * rhs ) const { return Derived::_doCompare( c_str(), rhs ); }
- private:
- static int _doCompare( const char * lhs, const char * rhs )
- {
- if ( lhs == rhs ) return 0;
- if ( lhs && rhs ) return ::strcmp( lhs, rhs );
- return( lhs ? 1 : -1 );
- }
+ private:
+ static int _doCompare( const char * lhs, const char * rhs )
+ {
+ if ( lhs == rhs ) return 0;
+ if ( lhs && rhs ) return ::strcmp( lhs, rhs );
+ return( lhs ? 1 : -1 );
+ }
- private:
+ private:
- friend base::SafeBool<Derived>::operator bool_type() const;
- bool boolTest() const { return ! empty(); }
- };
- ///////////////////////////////////////////////////////////////////
+ friend base::SafeBool<Derived>::operator bool_type() const;
+ bool boolTest() const { return ! empty(); }
+ };
+ ///////////////////////////////////////////////////////////////////
- /** \relates IdStringType Stream output */
- template <class Derived>
- inline std::ostream & operator<<( std::ostream & str, const IdStringType<Derived> & obj )
- { return str << obj.c_str(); }
+ /** \relates IdStringType Stream output */
+ template <class Derived>
+ inline std::ostream & operator<<( std::ostream & str, const IdStringType<Derived> & obj )
+ { return str << obj.c_str(); }
- /** \relates IdStringType Equal */
- template <class Derived>
- inline bool operator==( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
- { return lhs.idStr().compareEQ( rhs.idStr() ); }
- /** \overload */
- template <class Derived>
- inline bool operator==( const IdStringType<Derived> & lhs, const IdString & rhs )
- { return lhs.compare( rhs ) == 0; }
- /** \overload */
- template <class Derived>
- inline bool operator==( const IdStringType<Derived> & lhs, const char * rhs )
- { return lhs.compare( rhs ) == 0; }
- /** \overload */
- template <class Derived>
- inline bool operator==( const IdStringType<Derived> & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) == 0; }
- /** \overload */
- template <class Derived>
- inline bool operator==( const IdString & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) == 0; }
- /** \overload */
- template <class Derived>
- inline bool operator==( const char * lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) == 0; }
- /** \overload */
- template <class Derived>
- inline bool operator==( const std::string & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) == 0; }
+ /** \relates IdStringType Equal */
+ template <class Derived>
+ inline bool operator==( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
+ { return lhs.idStr().compareEQ( rhs.idStr() ); }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const IdStringType<Derived> & lhs, const IdString & rhs )
+ { return lhs.compare( rhs ) == 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const IdStringType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) == 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const IdStringType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) == 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const IdString & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) == 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const char * lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) == 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const std::string & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) == 0; }
- /** \relates IdStringType NotEqual */
- template <class Derived>
- inline bool operator!=( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
- { return lhs.idStr().compareEQ( rhs.idStr() ); }
- /** \overload */
- template <class Derived>
- inline bool operator!=( const IdStringType<Derived> & lhs, const IdString & rhs )
- { return lhs.compare( rhs ) != 0; }
- /** \overload */
- template <class Derived>
- inline bool operator!=( const IdStringType<Derived> & lhs, const char * rhs )
- { return lhs.compare( rhs ) != 0; }
- /** \overload */
- template <class Derived>
- inline bool operator!=( const IdStringType<Derived> & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) != 0; }
- /** \overload */
- template <class Derived>
- inline bool operator!=( const IdString & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) != 0; }
- /** \overload */
- template <class Derived>
- inline bool operator!=( const char * lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) != 0; }
- /** \overload */
- template <class Derived>
- inline bool operator!=( const std::string & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) != 0; }
+ /** \relates IdStringType NotEqual */
+ template <class Derived>
+ inline bool operator!=( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
+ { return lhs.idStr().compareEQ( rhs.idStr() ); }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const IdStringType<Derived> & lhs, const IdString & rhs )
+ { return lhs.compare( rhs ) != 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const IdStringType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) != 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const IdStringType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) != 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const IdString & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) != 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const char * lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) != 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const std::string & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) != 0; }
- /** \relates IdStringType Less */
- template <class Derived>
- inline bool operator<( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
- { return lhs.compare( rhs ) < 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<( const IdStringType<Derived> & lhs, const IdString & rhs )
- { return lhs.compare( rhs ) < 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<( const IdStringType<Derived> & lhs, const char * rhs )
- { return lhs.compare( rhs ) < 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<( const IdStringType<Derived> & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) < 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<( const IdString & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) >= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<( const char * lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) >= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<( const std::string & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) >= 0; }
+ /** \relates IdStringType Less */
+ template <class Derived>
+ inline bool operator<( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const IdStringType<Derived> & lhs, const IdString & rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const IdStringType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const IdStringType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const IdString & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const char * lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const std::string & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) >= 0; }
- /** \relates IdStringType LessEqual */
- template <class Derived>
- inline bool operator<=( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
- { return lhs.compare( rhs ) <= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<=( const IdStringType<Derived> & lhs, const IdString & rhs )
- { return lhs.compare( rhs ) <= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<=( const IdStringType<Derived> & lhs, const char * rhs )
- { return lhs.compare( rhs ) <= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<=( const IdStringType<Derived> & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) <= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<=( const IdString & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) > 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<=( const char * lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) > 0; }
- /** \overload */
- template <class Derived>
- inline bool operator<=( const std::string & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) > 0; }
+ /** \relates IdStringType LessEqual */
+ template <class Derived>
+ inline bool operator<=( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const IdStringType<Derived> & lhs, const IdString & rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const IdStringType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const IdStringType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const IdString & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const char * lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<=( const std::string & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) > 0; }
- /** \relates IdStringType Greater */
- template <class Derived>
- inline bool operator>( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
- { return lhs.compare( rhs ) > 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>( const IdStringType<Derived> & lhs, const IdString & rhs )
- { return lhs.compare( rhs ) > 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>( const IdStringType<Derived> & lhs, const char * rhs )
- { return lhs.compare( rhs ) > 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>( const IdStringType<Derived> & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) > 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>( const IdString & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) <= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>( const char * lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) <= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>( const std::string & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) <= 0; }
+ /** \relates IdStringType Greater */
+ template <class Derived>
+ inline bool operator>( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const IdStringType<Derived> & lhs, const IdString & rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const IdStringType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const IdStringType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) > 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const IdString & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const char * lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) <= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>( const std::string & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) <= 0; }
- /** \relates IdStringType GreaterEqual */
- template <class Derived>
- inline bool operator>=( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
- { return lhs.compare( rhs ) >= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>=( const IdStringType<Derived> & lhs, const IdString & rhs )
- { return lhs.compare( rhs ) >= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>=( const IdStringType<Derived> & lhs, const char * rhs )
- { return lhs.compare( rhs ) >= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>=( const IdStringType<Derived> & lhs, const std::string & rhs )
- { return lhs.compare( rhs ) >= 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>=( const IdString & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) < 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>=( const char * lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) < 0; }
- /** \overload */
- template <class Derived>
- inline bool operator>=( const std::string & lhs, const IdStringType<Derived> & rhs )
- { return rhs.compare( lhs ) < 0; }
+ /** \relates IdStringType GreaterEqual */
+ template <class Derived>
+ inline bool operator>=( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const IdStringType<Derived> & lhs, const IdString & rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const IdStringType<Derived> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const IdStringType<Derived> & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ) >= 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const IdString & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const char * lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) < 0; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator>=( const std::string & lhs, const IdStringType<Derived> & rhs )
+ { return rhs.compare( lhs ) < 0; }
/////////////////////////////////////////////////////////////////
} // namespace zypp