libzypp  17.3.0
zypp::IdStringType< Derived > Class Template Reference

Base class for creating IdString based types. More...

#include <IdStringType.h>

Inheritance diagram for zypp::IdStringType< Derived >:

Public Types

typedef IdString::IdType IdType
 

Public Member Functions

IdString idStr () const
 
bool empty () const
 
unsigned size () const
 
const char * c_str () const
 
std::string asString () const
 
IdType id () const
 
 operator bool () const
 Evaluate in a boolean context ( ! empty() ). More...
 
 operator IdString () const
 Explicit conversion to IdString. More...
 
 operator std::string () const
 Explicit conversion to std::string. More...
 
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 Member Functions

const Derived & self () 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)
 

Additional Inherited Members

- Static Protected Member Functions inherited from zypp::sat::detail::PoolMember
static PoolImplmyPool ()
 

Detailed Description

template<class Derived>
class zypp::IdStringType< Derived >

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
Todo:
allow redefinition of order vis _doCompare not only for char* but on any level

Definition at line 86 of file IdStringType.h.

Member Typedef Documentation

◆ IdType

template<class Derived>
typedef IdString::IdType zypp::IdStringType< Derived >::IdType

Definition at line 89 of file IdStringType.h.

Constructor & Destructor Documentation

◆ IdStringType() [1/2]

template<class Derived>
zypp::IdStringType< Derived >::IdStringType ( )
inlineprotected

Definition at line 92 of file IdStringType.h.

◆ IdStringType() [2/2]

template<class Derived>
zypp::IdStringType< Derived >::IdStringType ( const IdStringType< Derived > &  )
inlineprotected

Definition at line 93 of file IdStringType.h.

◆ ~IdStringType()

template<class Derived>
zypp::IdStringType< Derived >::~IdStringType ( )
inlineprotected

Definition at line 95 of file IdStringType.h.

Member Function Documentation

◆ operator=()

template<class Derived>
void zypp::IdStringType< Derived >::operator= ( const IdStringType< Derived > &  )
inlineprotected

Definition at line 94 of file IdStringType.h.

◆ self()

template<class Derived>
const Derived& zypp::IdStringType< Derived >::self ( ) const
inlineprivate

Definition at line 98 of file IdStringType.h.

◆ idStr()

template<class Derived>
IdString zypp::IdStringType< Derived >::idStr ( ) const
inline

Definition at line 101 of file IdStringType.h.

◆ empty()

template<class Derived>
bool zypp::IdStringType< Derived >::empty ( ) const
inline

Definition at line 103 of file IdStringType.h.

◆ size()

template<class Derived>
unsigned zypp::IdStringType< Derived >::size ( ) const
inline

Definition at line 104 of file IdStringType.h.

◆ c_str()

template<class Derived>
const char* zypp::IdStringType< Derived >::c_str ( ) const
inline

Definition at line 105 of file IdStringType.h.

◆ asString()

template<class Derived>
std::string zypp::IdStringType< Derived >::asString ( ) const
inline

Definition at line 106 of file IdStringType.h.

◆ id()

template<class Derived>
IdType zypp::IdStringType< Derived >::id ( ) const
inline

Definition at line 108 of file IdStringType.h.

◆ operator bool()

template<class Derived>
zypp::IdStringType< Derived >::operator bool ( ) const
inlineexplicit

Evaluate in a boolean context ( ! empty() ).

Definition at line 112 of file IdStringType.h.

◆ operator IdString()

template<class Derived>
zypp::IdStringType< Derived >::operator IdString ( ) const
inlineexplicit

Explicit conversion to IdString.

Definition at line 116 of file IdStringType.h.

◆ operator std::string()

template<class Derived>
zypp::IdStringType< Derived >::operator std::string ( ) const
inlineexplicit

Explicit conversion to std::string.

Definition at line 120 of file IdStringType.h.

◆ compare() [1/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const Derived &  lhs,
const Derived &  rhs 
)
inlinestatic

Definition at line 127 of file IdStringType.h.

◆ compare() [2/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const Derived &  lhs,
const IdString rhs 
)
inlinestatic

Definition at line 128 of file IdStringType.h.

◆ compare() [3/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const Derived &  lhs,
const std::string &  rhs 
)
inlinestatic

Definition at line 129 of file IdStringType.h.

◆ compare() [4/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const Derived &  lhs,
const char *  rhs 
)
inlinestatic

Definition at line 130 of file IdStringType.h.

◆ compare() [5/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const IdString lhs,
const Derived &  rhs 
)
inlinestatic

Definition at line 132 of file IdStringType.h.

◆ compare() [6/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const IdString lhs,
const IdString rhs 
)
inlinestatic

Definition at line 133 of file IdStringType.h.

◆ compare() [7/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const IdString lhs,
const std::string &  rhs 
)
inlinestatic

Definition at line 135 of file IdStringType.h.

◆ compare() [8/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const IdString lhs,
const char *  rhs 
)
inlinestatic

Definition at line 136 of file IdStringType.h.

◆ compare() [9/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const std::string &  lhs,
const Derived &  rhs 
)
inlinestatic

Definition at line 138 of file IdStringType.h.

◆ compare() [10/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const std::string &  lhs,
const IdString rhs 
)
inlinestatic

Definition at line 139 of file IdStringType.h.

◆ compare() [11/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const std::string &  lhs,
const std::string &  rhs 
)
inlinestatic

Definition at line 140 of file IdStringType.h.

◆ compare() [12/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const std::string &  lhs,
const char *  rhs 
)
inlinestatic

Definition at line 141 of file IdStringType.h.

◆ compare() [13/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const char *  lhs,
const Derived &  rhs 
)
inlinestatic

Definition at line 143 of file IdStringType.h.

◆ compare() [14/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const char *  lhs,
const IdString rhs 
)
inlinestatic

Definition at line 144 of file IdStringType.h.

◆ compare() [15/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const char *  lhs,
const std::string &  rhs 
)
inlinestatic

Definition at line 145 of file IdStringType.h.

◆ compare() [16/21]

template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const char *  lhs,
const char *  rhs 
)
inlinestatic

Definition at line 146 of file IdStringType.h.

◆ compare() [17/21]

template<class Derived>
int zypp::IdStringType< Derived >::compare ( const Derived &  rhs) const
inline

Definition at line 149 of file IdStringType.h.

◆ compare() [18/21]

template<class Derived>
int zypp::IdStringType< Derived >::compare ( const IdStringType< Derived > &  rhs) const
inline

Definition at line 150 of file IdStringType.h.

◆ compare() [19/21]

template<class Derived>
int zypp::IdStringType< Derived >::compare ( const IdString rhs) const
inline

Definition at line 151 of file IdStringType.h.

◆ compare() [20/21]

template<class Derived>
int zypp::IdStringType< Derived >::compare ( const std::string &  rhs) const
inline

Definition at line 152 of file IdStringType.h.

◆ compare() [21/21]

template<class Derived>
int zypp::IdStringType< Derived >::compare ( const char *  rhs) const
inline

Definition at line 153 of file IdStringType.h.

◆ _doCompare()

template<class Derived>
static int zypp::IdStringType< Derived >::_doCompare ( const char *  lhs,
const char *  rhs 
)
inlinestaticprivate

Definition at line 156 of file IdStringType.h.

Friends And Related Function Documentation

◆ operator<<()

template<class Derived >
std::ostream & operator<< ( std::ostream &  str,
const IdStringType< Derived > &  obj 
)
related

Stream output

Definition at line 166 of file IdStringType.h.

◆ operator==()

template<class Derived >
bool operator== ( const IdStringType< Derived > &  lhs,
const IdStringType< Derived > &  rhs 
)
related

Equal

Definition at line 171 of file IdStringType.h.

◆ operator!=()

template<class Derived >
bool operator!= ( const IdStringType< Derived > &  lhs,
const IdStringType< Derived > &  rhs 
)
related

NotEqual

Definition at line 200 of file IdStringType.h.

◆ operator<()

template<class Derived >
bool operator< ( const IdStringType< Derived > &  lhs,
const IdStringType< Derived > &  rhs 
)
related

Less

Definition at line 229 of file IdStringType.h.

◆ operator<=()

template<class Derived >
bool operator<= ( const IdStringType< Derived > &  lhs,
const IdStringType< Derived > &  rhs 
)
related

LessEqual

Definition at line 258 of file IdStringType.h.

◆ operator>()

template<class Derived >
bool operator> ( const IdStringType< Derived > &  lhs,
const IdStringType< Derived > &  rhs 
)
related

Greater

Definition at line 287 of file IdStringType.h.

◆ operator>=()

template<class Derived >
bool operator>= ( const IdStringType< Derived > &  lhs,
const IdStringType< Derived > &  rhs 
)
related

GreaterEqual

Definition at line 316 of file IdStringType.h.


The documentation for this class was generated from the following file: