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

libzypp 17.38.8

zyppng::IdStringType< Derived > Class Template Reference

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

`#include <zypp/IdStringType.h>`

## 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 (IdStringType &&) noexcept=default
IdStringType & | operator= (const IdStringType &)=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

## Detailed Description

template<class Derived>
class zyppng::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::_doCompare
static int _doCompare(const char *lhs, const char *rhs) ZYPP_API
Definition IdStringType.h:171
zyppng::IdStringType::IdStringType
IdStringType()=default

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
DBG
#define DBG
Definition Logger.h:102
zypp::IdStringType::IdStringType
IdStringType()=default
zyppng::IdString
zypp::IdString IdString
Definition idstring.h:16

Todo
  allow redefinition of order vis _doCompare not only for char* but on any level

Definition at line 91 of file IdStringType.h.

## Member Typedef Documentation

## ◆ IdType

template<class Derived>

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

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

## ◆ idStr()

template<class Derived>

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

Definition at line 111 of file IdStringType.h.

## ◆ empty()

template<class Derived>

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

Definition at line 113 of file IdStringType.h.

## ◆ size()

template<class Derived>

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

Definition at line 114 of file IdStringType.h.

## ◆ c_str()

template<class Derived>

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

Definition at line 115 of file IdStringType.h.

## ◆ asString()

template<class Derived>

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

Definition at line 116 of file IdStringType.h.

## ◆ id()

template<class Derived>

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

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

## ◆ operator IdString()

template<class Derived>

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

Explicit conversion to IdString.

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

## ◆ compare() [1/21]

template<class Derived>

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

Definition at line 142 of file IdStringType.h.

## ◆ compare() [2/21]

template<class Derived>

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

Definition at line 143 of file IdStringType.h.

## ◆ compare() [3/21]

template<class Derived>

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

Definition at line 144 of file IdStringType.h.

## ◆ compare() [4/21]

template<class Derived>

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

Definition at line 145 of file IdStringType.h.

## ◆ compare() [5/21]

template<class Derived>

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

Definition at line 147 of file IdStringType.h.

## ◆ compare() [6/21]

template<class Derived>

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

Definition at line 148 of file IdStringType.h.

## ◆ compare() [7/21]

template<class Derived>

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

Definition at line 150 of file IdStringType.h.

## ◆ compare() [8/21]

template<class Derived>

int zypp::IdStringType< Derived >::compare | ( | const IdString & | lhs,
|  | const char * | rhs )
| inlinestatic

Definition at line 151 of file IdStringType.h.

## ◆ compare() [9/21]

template<class Derived>

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

Definition at line 153 of file IdStringType.h.

## ◆ compare() [10/21]

template<class Derived>

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

Definition at line 154 of file IdStringType.h.

## ◆ compare() [11/21]

template<class Derived>

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

Definition at line 155 of file IdStringType.h.

## ◆ compare() [12/21]

template<class Derived>

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

Definition at line 156 of file IdStringType.h.

## ◆ compare() [13/21]

template<class Derived>

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

Definition at line 158 of file IdStringType.h.

## ◆ compare() [14/21]

template<class Derived>

int zypp::IdStringType< Derived >::compare | ( | const char * | lhs,
|  | const IdString & | rhs )
| inlinestatic

Definition at line 159 of file IdStringType.h.

## ◆ compare() [15/21]

template<class Derived>

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

Definition at line 160 of file IdStringType.h.

## ◆ compare() [16/21]

template<class Derived>

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

Definition at line 161 of file IdStringType.h.

## ◆ compare() [17/21]

template<class Derived>

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

Definition at line 164 of file IdStringType.h.

## ◆ compare() [18/21]

template<class Derived>

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

Definition at line 165 of file IdStringType.h.

## ◆ compare() [19/21]

template<class Derived>

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

Definition at line 166 of file IdStringType.h.

## ◆ compare() [20/21]

template<class Derived>

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

Definition at line 167 of file IdStringType.h.

## ◆ compare() [21/21]

template<class Derived>

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

Definition at line 168 of file IdStringType.h.

## ◆ _doCompare()

template<class Derived>

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

Definition at line 171 of file IdStringType.h.

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

- zypp/IdStringType.h