BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdljsn::StringUtil Struct Reference

#include <bdljsn_stringutil.h>

Public Types

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

Static Public Member Functions

static int readString (bsl::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 writeString (bsl::ostream &stream, const bsl::string_view &string)
 

Detailed Description

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

Member Enumeration Documentation

◆ Flags

Enumerator
e_NONE 
e_ACCEPT_CAPITAL_UNICODE_ESCAPE 

Member Function Documentation

◆ readString()

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}).

◆ readUnquotedString()

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}).

◆ writeString()

static int bdljsn::StringUtil::writeString ( bsl::ostream &  stream,
const bsl::string_view string 
)
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 {Conventions: Arbitrary UTF-8 to JSON String} for further details.


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