BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdljsn::StringUtil Struct Reference

#include <bdljsn_stringutil.h>

Detailed Description

This class provides utility functions for converting arbitrary UTF-8 sequences into JSON strings and visa versa. See JSON Strings for details of these transformations.

See bdljsn_stringutil

Public Types

enum  Flags { e_NONE = 0 , e_ACCEPT_CAPITAL_UNICODE_ESCAPE = 1 << 0 , e_NO_ESCAPING_FORWARD_SLASH = 1 << 1 }
 

Static Public Member Functions

static int readString (bsl::string *value, const bsl::string_view &string, int flags=e_NONE)
 
static int readString (std::string *value, const bsl::string_view &string, int flags=e_NONE)
 
static int readUnquotedString (bsl::string *value, const bsl::string_view &string, int flags=e_NONE)
 
static int readUnquotedString (std::string *value, const bsl::string_view &string, int flags=e_NONE)
 
static int writeString (bsl::ostream &stream, const bsl::string_view &string, int flags=e_NONE)
 

Member Enumeration Documentation

◆ Flags

Enumerator
e_NONE 
e_ACCEPT_CAPITAL_UNICODE_ESCAPE 
e_NO_ESCAPING_FORWARD_SLASH 

Member Function Documentation

◆ readString() [1/2]

int bdljsn::StringUtil::readString ( bsl::string value,
const bsl::string_view string,
int  flags = e_NONE 
)
inlinestatic

Load to the specified value the UTF-8 codepoint sequence equivalent to the specified (JSON) string (see JSON Strings ). Return 0 on success and a non-zero value otherwise. Optionally specify flags to request variances from certain rules of JSON decoding (see Strictness ).

◆ readString() [2/2]

int bdljsn::StringUtil::readString ( std::string *  value,
const bsl::string_view string,
int  flags = e_NONE 
)
inlinestatic

◆ readUnquotedString() [1/2]

static int bdljsn::StringUtil::readUnquotedString ( bsl::string value,
const bsl::string_view string,
int  flags = e_NONE 
)
static

Load to the specified value the UTF-8 codepoint sequence equivalent to the specified string, that is JSON-compliant absent the leading and trailing double quote characters (see JSON Strings ). Return 0 on success and a non-zero value otherwise. Optionally specify flags to request variances from certain rules of JSON decoding (see Strictness ).

◆ readUnquotedString() [2/2]

static int bdljsn::StringUtil::readUnquotedString ( std::string *  value,
const bsl::string_view string,
int  flags = e_NONE 
)
static

◆ writeString()

static int bdljsn::StringUtil::writeString ( bsl::ostream &  stream,
const bsl::string_view string,
int  flags = e_NONE 
)
static

Write to the specified stream a JSON-compliant string that is equivalent to the specified string, an arbitrary UTF-8 codepoint sequence. Return 0 on success and a non-zero value otherwise. The operation fails if string is not a sequence of UTF-8 codepoints or if there is an error writing to stream. See Guarantees: Arbitrary UTF-8 to JSON String for further details.


The documentation for this struct was generated from the following file: