libzypp 8.13.6
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Related Functions

zypp::IdStringType< Derived > Class Template Reference

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

#include <IdStringType.h>

Inheritance diagram for zypp::IdStringType< Derived >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef IdString::IdType IdType

Public Member Functions

const IdStringidStr () 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)

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

template<class Derived>
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.

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

Definition at line 91 of file IdStringType.h.


Constructor & Destructor Documentation

template<class Derived>
zypp::IdStringType< Derived >::IdStringType ( ) [inline, protected]

Definition at line 94 of file IdStringType.h.

template<class Derived>
zypp::IdStringType< Derived >::IdStringType ( const IdStringType< Derived > &  ) [inline, protected]

Definition at line 95 of file IdStringType.h.

template<class Derived>
zypp::IdStringType< Derived >::~IdStringType ( ) [inline, protected]

Definition at line 97 of file IdStringType.h.


Member Function Documentation

template<class Derived>
void zypp::IdStringType< Derived >::operator= ( const IdStringType< Derived > &  ) [inline, protected]

Definition at line 96 of file IdStringType.h.

template<class Derived>
const Derived& zypp::IdStringType< Derived >::self ( ) const [inline, private]

Definition at line 100 of file IdStringType.h.

template<class Derived>
const IdString& zypp::IdStringType< Derived >::idStr ( ) const [inline]
template<class Derived>
bool zypp::IdStringType< Derived >::empty ( ) const [inline]

Definition at line 105 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::boolTest().

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

Definition at line 106 of file IdStringType.h.

template<class Derived>
const char* zypp::IdStringType< Derived >::c_str ( ) const [inline]
template<class Derived>
std::string zypp::IdStringType< Derived >::asString ( ) const [inline]
template<class Derived>
IdType zypp::IdStringType< Derived >::id ( ) const [inline]
template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const Derived &  lhs,
const Derived &  rhs 
) [inline, static]
template<class Derived>
static int zypp::IdStringType< Derived >::compare ( const Derived &  lhs,
const IdString rhs 
) [inline, static]

Definition at line 122 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 123 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 124 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 126 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 127 of file IdStringType.h.

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

Definition at line 129 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 130 of file IdStringType.h.

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

Definition at line 132 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 133 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 134 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 135 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 137 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 138 of file IdStringType.h.

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

Definition at line 139 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 140 of file IdStringType.h.

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

Definition at line 143 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 144 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 145 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 146 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

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

Definition at line 147 of file IdStringType.h.

Referenced by zypp::IdStringType< SolvAttr >::compare().

template<class Derived>
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.

Referenced by zypp::IdStringType< SolvAttr >::compare().

template<class Derived>
zypp::IdStringType< Derived >::base::SafeBool ( ) const [private]
template<class Derived>
bool zypp::IdStringType< Derived >::boolTest ( ) const [inline, private]

Definition at line 160 of file IdStringType.h.


Friends And Related Function Documentation

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

Stream output

Definition at line 166 of file IdStringType.h.

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

Equal

Definition at line 171 of file IdStringType.h.

References zypp::IdStringType< Derived >::compare().

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

NotEqual

Definition at line 200 of file IdStringType.h.

References zypp::IdStringType< Derived >::compare().

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

Less

Definition at line 229 of file IdStringType.h.

References zypp::IdStringType< Derived >::compare().

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

LessEqual

Definition at line 258 of file IdStringType.h.

References zypp::IdStringType< Derived >::compare().

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

Greater

Definition at line 287 of file IdStringType.h.

References zypp::IdStringType< Derived >::compare().

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

GreaterEqual

Definition at line 316 of file IdStringType.h.

References zypp::IdStringType< Derived >::compare().


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