SharedString |
SharedStringSharedStrings, once set up as defined in the Shared String Library documentation, can be used almost just like STL strings. They are immutable, that is, you cannot change the value without reassigning a new string value. TODO: Complete this documentation Summary
Default constructorInitializes shared string to /str/; defaults to the empty string if no string is specified. Usage// initialize string s to contain 'hello there' AuthorDavid C. Haley (david at the-haleys dot com) Parameters
Constructor for C-style stringsInitializes shared string to /str/. Necessary to disambiguate assignment operators/constructors on certain compilers. Usage// initialize string s to contain 'hello there' AuthorDavid C. Haley (david at the-haleys dot com) Parameters
str
Returns a constant reference to the string’s value. Returning a constant reference avoids having to copy the string if you don’t have to. NoteThe reference’s validity is undefined if you unregister the string it came from. (In practice, it should work as long as some other string is using the same value. But this is not safe practice so you should avoid it.) Usageshared_str s = "hello"; AuthorDavid C. Haley (david at the-haleys dot com) ReturnsA constant reference to the string value c_str
Returns a 0-terminated C-style string. Convenient if you need the C-style pointer and don’t want to go through the string object. See usage note for str() regarding safety of the pointer after unregistering the shared string. Usageshared_str s = "hello"; AuthorDavid C. Haley (david at the-haleys dot com) ReturnsA C-style string pointer to the string’s value. ciEqual
Test for case-insensitive equality against /rhs/. Note: Method is overloaded to accept: -SharedString-, -std::string-, -const char *- Usageshared_str s = "hello"; AuthorDavid C. Haley (david at the-haleys dot com) Parameters
ReturnsTrue if this string is case-insensitively equal to rhs. Assignment OperatorThere are three equality operators, overloaded for efficiency. SharedString & operator= (const std::string & rhs) They all do the expected thing, and assign rhs to the string on the left hand side (‘this’). Usageshared_str s; Parameters
ReturnThe new value of the string. (e.g. s = “foo” returns s with value “foo”) Addition OperatorThere are three addition operators, and three += operators. SharedString operator + (const std::string & rhs) const They all do the expected thing, and add rhs to the string on the left hand side (‘this’). Usageshared_str s = "fo"; Parameters
ReturnThe result of the addition. In the case of the + operator, the returned string is a new copy. In the case of +=, the returned string is the original left-hand side. Equality OperatorThere are three equality operators, overloaded for efficiency. bool operator == (const SharedString & rhs) const The != operator is also implemented for all three types. These return true if lhs == rhs. Equality is case-sensitive. (For !=, they return false if == is false.) Usageshared_str s = "foo"; Parameters
ReturnTrue if ‘this’ == rhs. Less-than OperatorThere are three less-than operators, overloaded for efficiency. bool operator < (const SharedString & rhs) const These return true if ‘this’ < rhs. That is, if ‘this’ is lexicographically less than rhs. Usageshared_str s = "foo"; Parameters
ReturnTrue if ‘this’ < rhs. assignString
Registers a string with the shared string table. Adds the string if it’s not already present, or increases the reference count. Stores the pointer returned by the manager. AuthorDavid C. Haley (david at the-haleys dot com) Parameters
|
Returns a constant reference to the string’s value.
inline const std::string & str() const
Returns a 0-terminated C-style string.
inline const char * c_str() const
Get the length of the stored string.
inline typename SharedString<ManagerWrapper>::size_type length() const
Test for case-insensitive equality against /rhs/.
inline bool ciEqual( const SharedString & rhs ) const
Points to the string in the manager.
const std::string * str_
Unregisters the string with the manager.
void deleteString()
Registers a string with the shared string table.
void assignString( const std:: string & newstr )