Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Ustring Class Reference

Unique strings. More...

#include <Ustring.h>

Inheritance diagram for Ustring:

LangCode Vendor List of all members.

Public Member Functions

 Ustring (UstringHash &nameHash_r, const std::string &n)
 operator const std::string & () const
const std::string & asString () const
const std::string * operator-> () const

Private Attributes

std::string _name

Friends

bool operator== (const Ustring &lhs, const Ustring &rhs)
bool operator== (const Ustring &lhs, const std::string &rhs)
bool operator== (const std::string &lhs, const Ustring &rhs)
bool operator!= (const Ustring &lhs, const Ustring &rhs)
bool operator!= (const Ustring &lhs, const std::string &rhs)
bool operator!= (const std::string &lhs, const Ustring &rhs)
bool operator< (const Ustring &lhs, const Ustring &rhs)
bool operator< (const Ustring &lhs, const std::string &rhs)
bool operator< (const std::string &lhs, const Ustring &rhs)
bool operator> (const Ustring &lhs, const Ustring &rhs)
bool operator> (const Ustring &lhs, const std::string &rhs)
bool operator> (const std::string &lhs, const Ustring &rhs)
bool operator>= (const Ustring &lhs, const Ustring &rhs)
bool operator>= (const Ustring &lhs, const std::string &rhs)
bool operator>= (const std::string &lhs, const Ustring &rhs)
bool operator<= (const Ustring &lhs, const Ustring &rhs)
bool operator<= (const Ustring &lhs, const std::string &rhs)
bool operator<= (const std::string &lhs, const Ustring &rhs)
std::ostream & operator<< (std::ostream &str, const Ustring &obj)

Detailed Description

Unique strings.

Ustring provides an immutable string and uses a UstringHash to keep the strings representaion class (which contains the actual data) unique.

That way Ustrings of the same value and using the same UstringHash can be stored at various locations, while the actual string data are stored only once.

The UstringHash to use is passed to the constructor, and no more needed after the string has been stored.

Conversion to string is possible and cheap, as the created string will, unless he's modified, share it's data with the one inside the Ustring.

Comparison between Ustrings and strings are based on string.

A -> operator is provided as an easy way to invoke const string methods, like size() or c_str().

ustr->size(); // short for ((const std::string &)u).size();

Most common usage will be deriving some class from Ustring, that provides a static UstringHash, and some constructor. Everything else is provided by Ustring.

class PkgName : public Ustring { private: static UstringHash _nameHash; public: explicit PkgName( const std::string & n = "" ) : Ustring( _nameHash, n ) {} };

See also:
UstringHash


Constructor & Destructor Documentation

Ustring::Ustring UstringHash nameHash_r,
const std::string &  n
[inline]
 

Constructor calls UstringHash::add on the given string, and stores the string returned from the hash.


Member Function Documentation

const std::string& Ustring::asString  )  const [inline]
 

Conversion to const std::string &

Ustring::operator const std::string &  )  const [inline]
 

Conversion to const std::string &

const std::string* Ustring::operator->  )  const [inline]
 

ustr->size(); // short for ((const std::string &)ustr).size();


Friends And Related Function Documentation

bool operator!= const std::string &  lhs,
const Ustring rhs
[friend]
 

bool operator!= const Ustring lhs,
const std::string &  rhs
[friend]
 

bool operator!= const Ustring lhs,
const Ustring rhs
[friend]
 

bool operator< const std::string &  lhs,
const Ustring rhs
[friend]
 

bool operator< const Ustring lhs,
const std::string &  rhs
[friend]
 

bool operator< const Ustring lhs,
const Ustring rhs
[friend]
 

std::ostream& operator<< std::ostream &  str,
const Ustring obj
[friend]
 

bool operator<= const std::string &  lhs,
const Ustring rhs
[friend]
 

bool operator<= const Ustring lhs,
const std::string &  rhs
[friend]
 

bool operator<= const Ustring lhs,
const Ustring rhs
[friend]
 

bool operator== const std::string &  lhs,
const Ustring rhs
[friend]
 

bool operator== const Ustring lhs,
const std::string &  rhs
[friend]
 

bool operator== const Ustring lhs,
const Ustring rhs
[friend]
 

bool operator> const std::string &  lhs,
const Ustring rhs
[friend]
 

bool operator> const Ustring lhs,
const std::string &  rhs
[friend]
 

bool operator> const Ustring lhs,
const Ustring rhs
[friend]
 

bool operator>= const std::string &  lhs,
const Ustring rhs
[friend]
 

bool operator>= const Ustring lhs,
const std::string &  rhs
[friend]
 

bool operator>= const Ustring lhs,
const Ustring rhs
[friend]
 


Member Data Documentation

std::string Ustring::_name [private]
 

!!! It should actualy be const !!! But that way default copy and assingment can be used.


The documentation for this class was generated from the following file:
Generated on Thu Feb 23 23:56:11 2006 for liby2util by doxygen 1.3.6