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

libzypp 17.36.6

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Related Symbols | List of all members
zypp::IdStringType< Derived > Class Template Reference

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

`#include <zypp/IdStringType.h>`

Inheritance diagram for zypp::IdStringType< Derived >:

## Public Types
using | IdType = IdString::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 `( !`
| operator IdString () const
| Explicit conversion to IdString.
| operator std::string () const
| Explicit conversion to std::string.
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 ()=default
| IdStringType (const IdStringType &)=default
IdStringType & | operator= (const IdStringType &)=default
| IdStringType (IdStringType &&) noexcept=default
IdStringType & | operator= (IdStringType &&) noexcept=default
| ~IdStringType ()=default

## Private Member Functions
const Derived & | self () const

## Static Private Member Functions
static int | _doCompare (const char *lhs, const char *rhs) ZYPP_API

## Related Symbols
(Note that these are not member symbols.)
template<class Derived>
std::ostream & | operator<< (std::ostream &str, const IdStringType< Derived > &obj)
| Stream output.
template<class Derived>
bool | operator== (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs)
| Equal.
template<class Derived>
bool | operator!= (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs)
| NotEqual.
template<class Derived>
bool | operator< (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs)
| Less.
template<class Derived>
bool | operator<= (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs)
| LessEqual.
template<class Derived>
bool | operator> (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs)
| Greater.
template<class Derived>
bool | operator>= (const IdStringType< Derived > &lhs, const IdStringType< Derived > &rhs)
| GreaterEqual.

## Additional Inherited Members
Static Protected Member Functions inherited from zypp::sat::detail::PoolMember
static PoolImpl & | myPool ()

## 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 );
};
zypp::IdStringType::IdStringType
IdStringType()=default
zypp::IdStringType::_doCompare
static int _doCompare(const char *lhs, const char *rhs) ZYPP_API
Definition IdStringType.h:163

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
zyppng::IdString
zypp::IdString IdString
Definition idstring.h:16
DBG
#define DBG
Definition Logger.h:99

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>

using zypp::IdStringType< Derived >::IdType = IdString::IdType

Definition at line 89 of file IdStringType.h.

## Constructor & Destructor Documentation

## ◆ IdStringType() [1/3]

template<class Derived>

zypp::IdStringType< Derived >::IdStringType | ( |  | ) |
| protecteddefault

## ◆ IdStringType() [2/3]

template<class Derived>

zypp::IdStringType< Derived >::IdStringType | ( | const IdStringType< Derived > & |  | ) |
| protecteddefault

## ◆ IdStringType() [3/3]

template<class Derived>

zypp::IdStringType< Derived >::IdStringType | ( | IdStringType< Derived > && |  | ) |
| protecteddefaultnoexcept

## ◆ ~IdStringType()

template<class Derived>

zypp::IdStringType< Derived >::~IdStringType | ( |  | ) |
| protecteddefault

## Member Function Documentation

## ◆ operator=() [1/2]

template<class Derived>

IdStringType & zypp::IdStringType< Derived >::operator= | ( | const IdStringType< Derived > & |  | ) |
| protecteddefault

## ◆ operator=() [2/2]

template<class Derived>

IdStringType & zypp::IdStringType< Derived >::operator= | ( | IdStringType< Derived > && |  | ) |
| protecteddefaultnoexcept

## ◆ self()

template<class Derived>

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

Definition at line 100 of file IdStringType.h.

## ◆ idStr()

template<class Derived>

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

Definition at line 103 of file IdStringType.h.

## ◆ empty()

template<class Derived>

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

Definition at line 105 of file IdStringType.h.

## ◆ size()

template<class Derived>

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

Definition at line 106 of file IdStringType.h.

## ◆ c_str()

template<class Derived>

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

Definition at line 107 of file IdStringType.h.

## ◆ asString()

template<class Derived>

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

Definition at line 108 of file IdStringType.h.

## ◆ id()

template<class Derived>

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

Definition at line 115 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 119 of file IdStringType.h.

## ◆ operator IdString()

template<class Derived>

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

Explicit conversion to IdString.

Definition at line 123 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 127 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 134 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 135 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 136 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 137 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 139 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 140 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 142 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 143 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 145 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 146 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 147 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 148 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 150 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 151 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 152 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 153 of file IdStringType.h.

## ◆ compare() [17/21]

template<class Derived>

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

Definition at line 156 of file IdStringType.h.

## ◆ compare() [18/21]

template<class Derived>

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

Definition at line 157 of file IdStringType.h.

## ◆ compare() [19/21]

template<class Derived>

int zypp::IdStringType< Derived >::compare | ( | const IdString & | rhs | ) | const
| inline

Definition at line 158 of file IdStringType.h.

## ◆ compare() [20/21]

template<class Derived>

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

Definition at line 159 of file IdStringType.h.

## ◆ compare() [21/21]

template<class Derived>

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

Definition at line 160 of file IdStringType.h.

## ◆ _doCompare()

template<class Derived>

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

Definition at line 163 of file IdStringType.h.

## Friends And Related Symbol Documentation

## ◆ operator<<()

template<class Derived>

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

Stream output.

Definition at line 173 of file IdStringType.h.

## ◆ operator==()

template<class Derived>

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

Equal.

Definition at line 178 of file IdStringType.h.

## ◆ operator!=()

template<class Derived>

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

NotEqual.

Definition at line 207 of file IdStringType.h.

## ◆ operator<()

template<class Derived>

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

Less.

Definition at line 236 of file IdStringType.h.

## ◆ operator<=()

template<class Derived>

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

LessEqual.

Definition at line 265 of file IdStringType.h.

## ◆ operator>()

template<class Derived>

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

Greater.

Definition at line 294 of file IdStringType.h.

## ◆ operator>=()

template<class Derived>

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

GreaterEqual.

Definition at line 323 of file IdStringType.h.

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

- zypp/IdStringType.h