template <typename CharType>

struct GenericStringRef

Defined at line 346 of file ../../third_party/rapidjson/include/rapidjson/document.h

Reference to a constant string (not taking a copy)

This helper class is used to automatically infer constant string

references for string literals, especially from

character arrays.

The main use is for creating JSON string values without copying the

source string via an

This requires that the referenced

string pointers have a sufficient lifetime, which exceeds the lifetime

of the associated GenericValue.

Template Parameters

CharType character type of the string

Code

                                    
                                            Value v("foo");   // ok, no need to copy & calculate length
                                            const char foo[] = "foo";
                                            v.SetString(foo); // ok
                                        
                                            const char* bar = foo;
                                            // Value x(bar); // not ok, can't rely on bar's lifetime
                                            Value x(StringRef(bar)); // lifetime explicitly guaranteed by user
                                            Value y(StringRef(bar, 3));  // ok, explicitly pass length
                                    
                                

Public Members

const Ch *const s
const SizeType length

Public Methods

template <SizeType N>
void GenericStringRef<CharType> (const CharType (&)[N] str)

Defined at line 375 of file ../../third_party/rapidjson/include/rapidjson/document.h

void GenericStringRef<CharType> (const CharType * str)

Defined at line 399 of file ../../third_party/rapidjson/include/rapidjson/document.h

void GenericStringRef<CharType> (const CharType * str, SizeType len)

Defined at line 411 of file ../../third_party/rapidjson/include/rapidjson/document.h

void GenericStringRef<CharType> (const GenericStringRef<CharType> & rhs)

Defined at line 414 of file ../../third_party/rapidjson/include/rapidjson/document.h

const Ch * operator const type-parameter-0-0 * ()

implicit conversion to plain CharType pointer

Defined at line 417 of file ../../third_party/rapidjson/include/rapidjson/document.h