SharedString

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.

Summary
SharedStringSharedStrings are like ConstStrings except their string pointers are guaranteed to be one-one with their data.
Enumerations
ConstructMode
Functions
SharedStringConstructs an empty shared string.
dataA chararcter pointer to the data.
c_strA chararcter pointer to NUL terminated data.
FragmentCasts this string to a Fragment
ConstStringCasts this string to a ConstString
boolfalse if the string is not set.
emptytrue 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.
FoundSharedStringA shared string that is always found, to allow easy construction/passing without worrying about adding new strings.

Enumerations

ConstructMode

InsertInsert a new string if not found.
FindFind only, constructs an empty string if not found.

Functions

SharedString

SharedString()

Constructs an empty shared string.

data

const char *data() const

Returns

A chararcter pointer to the data.

c_str

const char *c_str() const

Returns

A chararcter pointer to NUL terminated data.

Fragment

operator Fragment() const

Casts this string to a Fragment

ConstString

operator ConstString() const

Casts this string to a ConstString

bool

operator bool() const

false if the string is not set.

empty

bool empty() const

true if the string is not set, or is the empty string.

SharedString(const char *string, const StringPool *owner)

SharedString(const char *string,
const StringPool *owner)

Constructs a shared string from a character pointer, used by StringPools.

FoundSharedString

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.

  • Has implicit casts to/from const char *.
SharedString()
Constructs an empty shared string.
const char *data() const
A chararcter pointer to the data.
const char *c_str() const
A chararcter pointer to NUL terminated data.
operator Fragment() const
Casts this string to a Fragment
operator ConstString() const
Casts this string to a ConstString
operator bool() const
false if the string is not set.
bool empty() const
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.
class ReflectExport(reflect) StringPool
A string pool manages SharedStrings.
class FoundSharedString : public SharedString
A shared string that is always found, to allow easy construction/passing without worrying about adding new strings.
class ReflectExport(
   reflect
) StringPoolContext : public StringPool , public utility::Context<StringPoolContext>
SharedStrings are like ConstStrings except their string pointers are guaranteed to be one-one with their data.
Close