|
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) |
|
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