xrpld
Loading...
Searching...
No Matches
json::StaticString Class Reference

Lightweight wrapper to tag static string. More...

#include <json_value.h>

Public Member Functions

constexpr StaticString (char const *czString)
constexpr operator char const * () const
constexpr char const * cStr () const

Private Attributes

char const * str_

Detailed Description

Lightweight wrapper to tag static string.

Value constructor and ValueType::Object member assignment takes advantage of the StaticString and avoid the cost of string duplication when storing the string or the member name.

Example of usage:

json::Value aValue( StaticString("some text") );
json::Value object;
static const StaticString code("code");
object[code] = 1234;
constexpr StaticString(char const *czString)
Definition json_value.h:46
Represents a JSON value.
Definition json_value.h:130

Definition at line 43 of file json_value.h.

Constructor & Destructor Documentation

◆ StaticString()

json::StaticString::StaticString ( char const * czString)
explicitconstexpr

Definition at line 46 of file json_value.h.

Member Function Documentation

◆ operator char const *()

json::StaticString::operator char const * ( ) const
constexpr

Definition at line 51 of file json_value.h.

◆ cStr()

char const * json::StaticString::cStr ( ) const
nodiscardconstexpr

Definition at line 57 of file json_value.h.

Member Data Documentation

◆ str_

char const* json::StaticString::str_
private

Definition at line 63 of file json_value.h.