Wire Sysio Wire Sysion 1.0.0
|
Reference to a constant string (not taking a copy) More...
#include <document.h>
Public Types | |
typedef CharType | Ch |
character type of the string | |
Public Member Functions | |
template<SizeType N> | |
GenericStringRef (const CharType(&str)[N]) RAPIDJSON_NOEXCEPT | |
Create string reference from const character array. | |
GenericStringRef (const CharType *str) | |
Explicitly create string reference from const character pointer. | |
GenericStringRef (const CharType *str, SizeType len) | |
Create constant string reference from pointer and length. | |
GenericStringRef (const GenericStringRef &rhs) | |
operator const Ch * () const | |
implicit conversion to plain CharType pointer | |
Public Attributes | |
const Ch *const | s |
plain CharType pointer | |
const SizeType | length |
length of the string (excluding the trailing NULL terminator) | |
Related Symbols | |
(Note that these are not member symbols.) | |
template<typename CharType > | |
GenericStringRef< CharType > | StringRef (const CharType *str) |
Mark a character pointer as constant string. | |
template<typename CharType > | |
GenericStringRef< CharType > | StringRef (const CharType *str, size_t length) |
Mark a character pointer as constant string. | |
CharType | character type of the string |
This helper class is used to automatically infer constant string references for string literals, especially from const
(!) character arrays.
The main use is for creating JSON string values without copying the source string via an Allocator. This requires that the referenced string pointers have a sufficient lifetime, which exceeds the lifetime of the associated GenericValue.
Example
Definition at line 256 of file document.h.
CharType GenericStringRef< CharType >::Ch |
Definition at line 257 of file document.h.
|
inline |
This constructor implicitly creates a constant string reference from a const
character array. It has better performance than StringRef(const CharType*) by inferring the string length from the array length, and also supports strings containing null characters.
N | length of the string, automatically inferred |
str | Constant character array, lifetime assumed to be longer than the use of the string in e.g. a GenericValue |
snprintf
are excluded from consideration. In such cases, the referenced string should be copied to the GenericValue instead. Definition at line 285 of file document.h.
|
inlineexplicit |
This constructor can be used to explicitly create a reference to a constant string pointer.
str | Constant character pointer, lifetime assumed to be longer than the use of the string in e.g. a GenericValue |
snprintf
are excluded from consideration. In such cases, the referenced string should be copied to the GenericValue instead. Definition at line 309 of file document.h.
|
inline |
str | constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue |
len | length of the string, excluding the trailing NULL terminator |
Definition at line 321 of file document.h.
|
inline |
|
inline |
Definition at line 327 of file document.h.
|
related |
Mark a plain character pointer as a "string literal". This function can be used to avoid copying a character string to be referenced as a value in a JSON GenericValue object, if the string's lifetime is known to be valid long enough.
CharType | Character type of the string |
str | Constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue |
Definition at line 364 of file document.h.
|
related |
Mark a plain character pointer as a "string literal". This function can be used to avoid copying a character string to be referenced as a value in a JSON GenericValue object, if the string's lifetime is known to be valid long enough.
This version has better performance with supplied length, and also supports string containing null characters.
CharType | character type of the string |
str | Constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue |
length | The length of source string. |
Definition at line 384 of file document.h.
const SizeType GenericStringRef< CharType >::length |
Definition at line 330 of file document.h.
const Ch* const GenericStringRef< CharType >::s |
Definition at line 329 of file document.h.