SharedStrings are like ConstStrings except their string pointers are guaranteed to be one-one with their data. Comparisons between SharedStrings is uses the pointer, rather than the data, and therefore may give different orderings on different runs/platforms.
To conserve space, and because SharedStrings are used in maps, there is no need to store the length of the string in the structure.
Consider SharedString the same thing as a const char * for use in maps with pooling keeping them unique.
SharedStrings may only be constructed from StringPools, which guarantee the uniqueness of the strings.
There is a global string pool stack formed from StringPoolContext objects (see Context). Most uses of a SharedString will require that the string be registered in the global pool stack, any strings that are not on the global stack should probably not be accessable as SharedStrings to prevent confusion.
SharedString | SharedStrings are like ConstStrings except their string pointers are guaranteed to be one-one with their data. |
Enumerations | |
ConstructMode | |
Functions | |
SharedString | Constructs an empty shared string. |
data | A chararcter pointer to the data. |
c_str | A chararcter pointer to NUL terminated data. |
Fragment | Casts this string to a Fragment |
ConstString | Casts this string to a ConstString |
bool | false if the string is not set. |
empty | true if the string is not set, or is the empty string. |
SharedString(const char *string, const StringPool *owner) | Constructs a shared string from a character pointer, used by StringPools. |
FoundSharedString | A shared string that is always found, to allow easy construction/passing without worrying about adding new strings. |
SharedString( const char * string, const StringPool * owner )
Constructs a shared string from a character pointer, used by StringPools.
class FoundSharedString : public SharedString
A shared string that is always found, to allow easy construction/passing without worrying about adding new strings. For Example, Use it for accessing maps when the map keys are made of SharedStrings.
Constructs an empty shared string.
SharedString()
A chararcter pointer to the data.
const char *data() const
A chararcter pointer to NUL terminated data.
const char *c_str() const
Casts this string to a Fragment
operator Fragment() const
Casts this string to a ConstString
operator ConstString() const
false if the string is not set.
operator bool() const
true if the string is not set, or is the empty string.
bool empty() const
Constructs a shared string from a character pointer, used by StringPools.
SharedString( const char * string, const StringPool * owner )
A string pool manages SharedStrings.
class ReflectExport( reflect ) StringPool
A shared string that is always found, to allow easy construction/passing without worrying about adding new strings.
class FoundSharedString : public SharedString
class ReflectExport( reflect ) StringPoolContext : public StringPool , public utility::Context<StringPoolContext>