libzypp
10.5.0
|
Base class for creating IdString based types. More...
#include <IdStringType.h>
Public Types | |
typedef IdString::IdType | IdType |
Public Member Functions | |
const IdString & | idStr () const |
bool | empty () const |
unsigned | size () const |
const char * | c_str () const |
std::string | asString () const |
IdType | id () const |
int | compare (const Derived &rhs) const |
int | compare (const IdStringType &rhs) const |
int | compare (const IdString &rhs) const |
int | compare (const std::string &rhs) const |
int | compare (const char *rhs) const |
Static Public Member Functions | |
static int | compare (const Derived &lhs, const Derived &rhs) |
static int | compare (const Derived &lhs, const IdString &rhs) |
static int | compare (const Derived &lhs, const std::string &rhs) |
static int | compare (const Derived &lhs, const char *rhs) |
static int | compare (const IdString &lhs, const Derived &rhs) |
static int | compare (const IdString &lhs, const IdString &rhs) |
static int | compare (const IdString &lhs, const std::string &rhs) |
static int | compare (const IdString &lhs, const char *rhs) |
static int | compare (const std::string &lhs, const Derived &rhs) |
static int | compare (const std::string &lhs, const IdString &rhs) |
static int | compare (const std::string &lhs, const std::string &rhs) |
static int | compare (const std::string &lhs, const char *rhs) |
static int | compare (const char *lhs, const Derived &rhs) |
static int | compare (const char *lhs, const IdString &rhs) |
static int | compare (const char *lhs, const std::string &rhs) |
static int | compare (const char *lhs, const char *rhs) |
Protected Member Functions | |
IdStringType () | |
IdStringType (const IdStringType &) | |
void | operator= (const IdStringType &) |
~IdStringType () | |
Private Types | |
typedef base::SafeBool < Derived >::bool_type | bool_type |
Private Member Functions | |
const Derived & | self () const |
friend | base::SafeBool () const |
bool | boolTest () const |
Static Private Member Functions | |
static int | _doCompare (const char *lhs, const char *rhs) |
Related Functions | |
(Note that these are not member functions.) | |
template<class Derived > | |
std::ostream & | operator<< (std::ostream &str, const IdStringType< Derived > &obj) |
template<class Derived > | |
bool | operator== (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs) |
template<class Derived > | |
bool | operator!= (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs) |
template<class Derived > | |
bool | operator< (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs) |
template<class Derived > | |
bool | operator<= (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs) |
template<class Derived > | |
bool | operator> (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs) |
template<class Derived > | |
bool | operator>= (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs) |
Base class for creating IdString based types.
Just by deriving from IdStringType a class provides all the operations an IdString does. (incl. conversion to string types, comparison of string types and stream output).
To disable any comparison, declare (but do not define) _doCompare in your class.
class NoCompare : public IdStringType<NoCompare> { private: static int _doCompare( const char * lhs, const char * rhs ); };
If you need a different than the default lexicographical order, write your own _doCompare.
// 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
Definition at line 86 of file IdStringType.h.
typedef base::SafeBool<Derived>::bool_type zypp::IdStringType< Derived >::bool_type [private] |
Reimplemented from zypp::base::SafeBool< Derived >.
Definition at line 89 of file IdStringType.h.
typedef IdString::IdType zypp::IdStringType< Derived >::IdType |
Definition at line 91 of file IdStringType.h.
zypp::IdStringType< Derived >::IdStringType | ( | ) | [inline, protected] |
Definition at line 94 of file IdStringType.h.
zypp::IdStringType< Derived >::IdStringType | ( | const IdStringType< Derived > & | ) | [inline, protected] |
Definition at line 95 of file IdStringType.h.
zypp::IdStringType< Derived >::~IdStringType | ( | ) | [inline, protected] |
Definition at line 97 of file IdStringType.h.
void zypp::IdStringType< Derived >::operator= | ( | const IdStringType< Derived > & | ) | [inline, protected] |
Definition at line 96 of file IdStringType.h.
const Derived& zypp::IdStringType< Derived >::self | ( | ) | const [inline, private] |
Definition at line 100 of file IdStringType.h.
const IdString& zypp::IdStringType< Derived >::idStr | ( | ) | const [inline] |
Definition at line 103 of file IdStringType.h.
bool zypp::IdStringType< Derived >::empty | ( | ) | const [inline] |
Definition at line 105 of file IdStringType.h.
unsigned zypp::IdStringType< Derived >::size | ( | ) | const [inline] |
Definition at line 106 of file IdStringType.h.
const char* zypp::IdStringType< Derived >::c_str | ( | ) | const [inline] |
Definition at line 107 of file IdStringType.h.
std::string zypp::IdStringType< Derived >::asString | ( | ) | const [inline] |
Definition at line 108 of file IdStringType.h.
IdType zypp::IdStringType< Derived >::id | ( | ) | const [inline] |
Definition at line 110 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const Derived & | lhs, |
const Derived & | rhs | ||
) | [inline, static] |
Definition at line 121 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const Derived & | lhs, |
const IdString & | rhs | ||
) | [inline, static] |
Definition at line 122 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const Derived & | lhs, |
const std::string & | rhs | ||
) | [inline, static] |
Definition at line 123 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const Derived & | lhs, |
const char * | rhs | ||
) | [inline, static] |
Definition at line 124 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const IdString & | lhs, |
const Derived & | rhs | ||
) | [inline, static] |
Definition at line 126 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const IdString & | lhs, |
const IdString & | rhs | ||
) | [inline, static] |
Definition at line 127 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const IdString & | lhs, |
const std::string & | rhs | ||
) | [inline, static] |
Definition at line 129 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const IdString & | lhs, |
const char * | rhs | ||
) | [inline, static] |
Definition at line 130 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const std::string & | lhs, |
const Derived & | rhs | ||
) | [inline, static] |
Definition at line 132 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const std::string & | lhs, |
const IdString & | rhs | ||
) | [inline, static] |
Definition at line 133 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const std::string & | lhs, |
const std::string & | rhs | ||
) | [inline, static] |
Definition at line 134 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const std::string & | lhs, |
const char * | rhs | ||
) | [inline, static] |
Definition at line 135 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const char * | lhs, |
const Derived & | rhs | ||
) | [inline, static] |
Definition at line 137 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const char * | lhs, |
const IdString & | rhs | ||
) | [inline, static] |
Definition at line 138 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const char * | lhs, |
const std::string & | rhs | ||
) | [inline, static] |
Definition at line 139 of file IdStringType.h.
static int zypp::IdStringType< Derived >::compare | ( | const char * | lhs, |
const char * | rhs | ||
) | [inline, static] |
Definition at line 140 of file IdStringType.h.
int zypp::IdStringType< Derived >::compare | ( | const Derived & | rhs | ) | const [inline] |
Definition at line 143 of file IdStringType.h.
int zypp::IdStringType< Derived >::compare | ( | const IdStringType< Derived > & | rhs | ) | const [inline] |
Definition at line 144 of file IdStringType.h.
int zypp::IdStringType< Derived >::compare | ( | const IdString & | rhs | ) | const [inline] |
Definition at line 145 of file IdStringType.h.
int zypp::IdStringType< Derived >::compare | ( | const std::string & | rhs | ) | const [inline] |
Definition at line 146 of file IdStringType.h.
int zypp::IdStringType< Derived >::compare | ( | const char * | rhs | ) | const [inline] |
Definition at line 147 of file IdStringType.h.
static int zypp::IdStringType< Derived >::_doCompare | ( | const char * | lhs, |
const char * | rhs | ||
) | [inline, static, private] |
Reimplemented in zypp::Edition, and zypp::ResKind.
Definition at line 150 of file IdStringType.h.
zypp::IdStringType< Derived >::base::SafeBool | ( | ) | const [private] |
bool zypp::IdStringType< Derived >::boolTest | ( | ) | const [inline, private] |
Definition at line 160 of file IdStringType.h.
std::ostream & operator<< | ( | std::ostream & | str, |
const IdStringType< Derived > & | obj | ||
) | [related] |
Stream output
Definition at line 166 of file IdStringType.h.
bool operator== | ( | const IdStringType< Derived > & | lhs, |
const IdStringType< Derived > & | rhs | ||
) | [related] |
Equal
Definition at line 171 of file IdStringType.h.
bool operator!= | ( | const IdStringType< Derived > & | lhs, |
const IdStringType< Derived > & | rhs | ||
) | [related] |
NotEqual
Definition at line 200 of file IdStringType.h.
bool operator< | ( | const IdStringType< Derived > & | lhs, |
const IdStringType< Derived > & | rhs | ||
) | [related] |
Less
Definition at line 229 of file IdStringType.h.
bool operator<= | ( | const IdStringType< Derived > & | lhs, |
const IdStringType< Derived > & | rhs | ||
) | [related] |
LessEqual
Definition at line 258 of file IdStringType.h.
bool operator> | ( | const IdStringType< Derived > & | lhs, |
const IdStringType< Derived > & | rhs | ||
) | [related] |
Greater
Definition at line 287 of file IdStringType.h.
bool operator>= | ( | const IdStringType< Derived > & | lhs, |
const IdStringType< Derived > & | rhs | ||
) | [related] |
GreaterEqual
Definition at line 316 of file IdStringType.h.