#include <UniqueString.h>
Public Types | |
| typedef hash_set < std::string > ::size_type | size_type |
| typedef hash_set < std::string > ::const_iterator | const_iterator |
Public Member Functions | |
| const std::string & | asString () const |
| Explicit conversion to string. | |
| const std::string & | str () const |
| Explicit conversion to string (convenience). | |
| operator const std::string & () const | |
| Implicit conversion to string. | |
| std::string::size_type | size () const |
Short for str().size(). | |
| bool | empty () const |
Short for str().empty(). | |
| int | compare (const std::string &rhs) const |
Short for str().compare( s ). | |
Static Public Member Functions | |
| static bool | allEmpty () |
| Whether there are known UniqueStrings. | |
| static size_type | allSize () |
| Number of known UniqueStrings. | |
| static const_iterator | allBegin () |
| Iterator to the 1st UniqueString. | |
| static const_iterator | allEnd () |
| Iterator behind the last UniqueString. | |
Protected Member Functions | |
| UniqueString () | |
| Default ctor provides an empty string. | |
| UniqueString (const std::string &name_r) | |
| Ctor taking a name to store. | |
| virtual | ~UniqueString () |
| Dtor. | |
Static Private Member Functions | |
| static hash_set < std::string > & | hash () |
| Provides the static hash to unify the strings. | |
Private Attributes | |
| std::string | _name |
| Immutable string. | |
Related Functions | |
| (Note that these are not member functions.) | |
| template<class _Derived> | |
| bool | operator== (const UniqueString< _Derived > &lhs, const UniqueString< _Derived > &rhs) |
| operator == | |
| template<class _Derived> | |
| bool | operator== (const UniqueString< _Derived > &lhs, const std::string &rhs) |
| operator == | |
| template<class _Derived> | |
| bool | operator== (const std::string &lhs, const UniqueString< _Derived > &rhs) |
| operator == | |
| template<class _Derived> | |
| bool | operator!= (const UniqueString< _Derived > &lhs, const UniqueString< _Derived > &rhs) |
| operator != | |
| template<class _Derived> | |
| bool | operator!= (const UniqueString< _Derived > &lhs, const std::string &rhs) |
| operator != | |
| template<class _Derived> | |
| bool | operator!= (const std::string &lhs, const UniqueString< _Derived > &rhs) |
| operator != | |
| template<class _Derived> | |
| bool | operator< (const UniqueString< _Derived > &lhs, const UniqueString< _Derived > &rhs) |
| operator < | |
| template<class _Derived> | |
| bool | operator< (const UniqueString< _Derived > &lhs, const std::string &rhs) |
| operator < | |
| template<class _Derived> | |
| bool | operator< (const std::string &lhs, const UniqueString< _Derived > &rhs) |
| operator < | |
| template<class _Derived> | |
| bool | operator> (const UniqueString< _Derived > &lhs, const UniqueString< _Derived > &rhs) |
| operator > | |
| template<class _Derived> | |
| bool | operator> (const UniqueString< _Derived > &lhs, const std::string &rhs) |
| operator > | |
| template<class _Derived> | |
| bool | operator> (const std::string &lhs, const UniqueString< _Derived > &rhs) |
| operator > | |
| template<class _Derived> | |
| bool | operator<= (const UniqueString< _Derived > &lhs, const UniqueString< _Derived > &rhs) |
| operator <= | |
| template<class _Derived> | |
| bool | operator<= (const UniqueString< _Derived > &lhs, const std::string &rhs) |
| operator <= | |
| template<class _Derived> | |
| bool | operator<= (const std::string &lhs, const UniqueString< _Derived > &rhs) |
| operator <= | |
| template<class _Derived> | |
| bool | operator>= (const UniqueString< _Derived > &lhs, const UniqueString< _Derived > &rhs) |
| operator >= | |
| template<class _Derived> | |
| bool | operator>= (const UniqueString< _Derived > &lhs, const std::string &rhs) |
| operator >= | |
| template<class _Derived> | |
| bool | operator>= (const std::string &lhs, const UniqueString< _Derived > &rhs) |
| operator >= | |
| template<class _Derived> | |
| std::ostream & | operator<< (std::ostream &str, const UniqueString< _Derived > &obj) |
| Stream output. | |
Each UniqueString provides a const std::string. This string is stored in a unifying hash, that way equal UniqueStrings share their string representation in memory.
At the same time the unifying hash contains all the string values created so far. Static methods are provided to query the hash contents.
Uses CRTP to provide the unifying hash.
struct KeyWord : public base::UniqueString<KeyWord> { KeyWord() {} KeyWord( const std::string & name_r ) :base::UniqueString<KeyWord>( name_r ) {} }; int main( int argc, char * argv[] ) { KeyWord(); KeyWord( "a" ); KeyWord( "b" ); KeyWord( "c" ); KeyWord( "a" ); KeyWord( "c" ); DBG << "Known KeyWords: " << KeyWord::allSize() << endl; for ( KeyWord::const_iterator it = KeyWord::allBegin(); it != KeyWord::allEnd(); ++it ) { DBG << *it << endl; } return 0; }
Known KeyWords: 3 a b c
Definition at line 79 of file UniqueString.h.
| typedef hash_set<std::string>::size_type zypp::base::UniqueString< _Derived >::size_type |
Definition at line 125 of file UniqueString.h.
| typedef hash_set<std::string>::const_iterator zypp::base::UniqueString< _Derived >::const_iterator |
Definition at line 126 of file UniqueString.h.
| zypp::base::UniqueString< _Derived >::UniqueString | ( | ) | [inline, protected] |
| zypp::base::UniqueString< _Derived >::UniqueString | ( | const std::string & | name_r | ) | [inline, protected] |
| virtual zypp::base::UniqueString< _Derived >::~UniqueString | ( | ) | [inline, protected, virtual] |
| const std::string& zypp::base::UniqueString< _Derived >::asString | ( | ) | const [inline] |
Explicit conversion to string.
Definition at line 101 of file UniqueString.h.
Referenced by zypp::base::UniqueString< zypp::PackageKeyword >::operator const std::string &(), and zypp::base::UniqueString< zypp::PackageKeyword >::str().
| const std::string& zypp::base::UniqueString< _Derived >::str | ( | ) | const [inline] |
Explicit conversion to string (convenience).
Definition at line 105 of file UniqueString.h.
Referenced by zypp::base::UniqueString< _Derived >::operator!=(), zypp::base::UniqueString< _Derived >::operator==(), zypp::base::UniqueString< _Derived >::operator>(), and zypp::base::UniqueString< _Derived >::operator>=().
| zypp::base::UniqueString< _Derived >::operator const std::string & | ( | ) | const [inline] |
| std::string::size_type zypp::base::UniqueString< _Derived >::size | ( | ) | const [inline] |
| bool zypp::base::UniqueString< _Derived >::empty | ( | ) | const [inline] |
| int zypp::base::UniqueString< _Derived >::compare | ( | const std::string & | rhs | ) | const [inline] |
| static bool zypp::base::UniqueString< _Derived >::allEmpty | ( | ) | [inline, static] |
| static size_type zypp::base::UniqueString< _Derived >::allSize | ( | ) | [inline, static] |
| static const_iterator zypp::base::UniqueString< _Derived >::allBegin | ( | ) | [inline, static] |
| static const_iterator zypp::base::UniqueString< _Derived >::allEnd | ( | ) | [inline, static] |
| static hash_set<std::string>& zypp::base::UniqueString< _Derived >::hash | ( | ) | [inline, static, private] |
Provides the static hash to unify the strings.
Definition at line 146 of file UniqueString.h.
Referenced by zypp::base::UniqueString< zypp::PackageKeyword >::UniqueString().
| bool operator== | ( | const UniqueString< _Derived > & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
operator ==
Definition at line 160 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator== | ( | const UniqueString< _Derived > & | lhs, | |
| const std::string & | rhs | |||
| ) | [related] |
operator ==
Definition at line 164 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator== | ( | const std::string & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
operator ==
Definition at line 168 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator!= | ( | const UniqueString< _Derived > & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
operator !=
Definition at line 174 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator!= | ( | const UniqueString< _Derived > & | lhs, | |
| const std::string & | rhs | |||
| ) | [related] |
operator !=
Definition at line 178 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator!= | ( | const std::string & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
operator !=
Definition at line 182 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator< | ( | const UniqueString< _Derived > & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
| bool operator< | ( | const UniqueString< _Derived > & | lhs, | |
| const std::string & | rhs | |||
| ) | [related] |
| bool operator< | ( | const std::string & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
| bool operator> | ( | const UniqueString< _Derived > & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
operator >
Definition at line 202 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator> | ( | const UniqueString< _Derived > & | lhs, | |
| const std::string & | rhs | |||
| ) | [related] |
operator >
Definition at line 206 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator> | ( | const std::string & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
operator >
Definition at line 210 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator<= | ( | const UniqueString< _Derived > & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
| bool operator<= | ( | const UniqueString< _Derived > & | lhs, | |
| const std::string & | rhs | |||
| ) | [related] |
| bool operator<= | ( | const std::string & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
| bool operator>= | ( | const UniqueString< _Derived > & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
operator >=
Definition at line 230 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator>= | ( | const UniqueString< _Derived > & | lhs, | |
| const std::string & | rhs | |||
| ) | [related] |
operator >=
Definition at line 234 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| bool operator>= | ( | const std::string & | lhs, | |
| const UniqueString< _Derived > & | rhs | |||
| ) | [related] |
operator >=
Definition at line 238 of file UniqueString.h.
References zypp::base::UniqueString< _Derived >::str().
| std::ostream & operator<< | ( | std::ostream & | str, | |
| const UniqueString< _Derived > & | obj | |||
| ) | [related] |
std::string zypp::base::UniqueString< _Derived >::_name [private] |
Immutable string.
Definition at line 154 of file UniqueString.h.
Referenced by zypp::base::UniqueString< zypp::PackageKeyword >::asString(), and zypp::base::UniqueString< zypp::PackageKeyword >::UniqueString().
1.5.3