Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Static Public Member Functions | List of all members
seastar::json::formatter Class Reference

Detailed Description

The formatter prints json values in a json format it overload to_json method for each of the supported format all to_json parameters are passed as a pointer

#include <seastar/json/formatter.hh>

Static Public Member Functions

static sstring to_json (const sstring &str)
 
static sstring to_json (int n)
 
static sstring to_json (unsigned n)
 
static sstring to_json (long n)
 
static sstring to_json (float f)
 
static sstring to_json (double d)
 
static sstring to_json (const char *str, size_t len)
 
static sstring to_json (const char *str)
 
static sstring to_json (bool d)
 
template<std::ranges::input_range Range>
requires (!internal::is_string_like<Range>)
static sstring to_json (const Range &range)
 
static sstring to_json (const date_time &d)
 
static sstring to_json (const jsonable &obj)
 
static sstring to_json (unsigned long l)
 
static future write (output_stream< char > &s, const sstring &str)
 
static future write (output_stream< char > &s, int n)
 
static future write (output_stream< char > &s, long n)
 
static future write (output_stream< char > &s, float f)
 
static future write (output_stream< char > &s, double d)
 
static future write (output_stream< char > &s, const char *str)
 
static future write (output_stream< char > &s, bool d)
 
template<std::ranges::input_range Range>
requires (!internal::is_string_like<Range>)
static future write (output_stream< char > &s, const Range &range)
 
static future write (output_stream< char > &s, const date_time &d)
 
template<std::derived_from< jsonable > Jsonable>
static future write (output_stream< char > &s, Jsonable obj)
 
static future write (output_stream< char > &s, unsigned long l)
 

Member Function Documentation

◆ to_json() [1/13]

static sstring seastar::json::formatter::to_json ( bool  d)
static

return a json formatted bool

Parameters
dthe bool to format
Returns
the given bool in a json format

◆ to_json() [2/13]

static sstring seastar::json::formatter::to_json ( const char *  str)
static

return a json formatted char* (treated as string), assuming there are no zero-chars in the middle

Parameters
strthe char* to format
Returns
the given char* in a json format
Deprecated:
A more robust overload should be preferred: to_json(const char*, size_t)

◆ to_json() [3/13]

static sstring seastar::json::formatter::to_json ( const char *  str,
size_t  len 
)
static

return a json formatted char* (treated as string), possibly with zero-chars in the middle

Parameters
strthe char* to format
lennumber of bytes to read from the str
Returns
the given char* in a json format

◆ to_json() [4/13]

static sstring seastar::json::formatter::to_json ( const date_time &  d)
static

return a json formatted date_time

Parameters
dthe date_time to format
Returns
the given date_time in a json format

◆ to_json() [5/13]

static sstring seastar::json::formatter::to_json ( const jsonable obj)
static

return a json formatted json object

Parameters
objthe date_time to format
Returns
the given json object in a json format

◆ to_json() [6/13]

template<std::ranges::input_range Range>
requires (!internal::is_string_like<Range>)
static sstring seastar::json::formatter::to_json ( const Range &  range)
inlinestatic

converts a given range to a JSON-formatted string

Parameters
rangeA standard range type
Returns
A string containing the JSON representation of the input range

◆ to_json() [7/13]

static sstring seastar::json::formatter::to_json ( const sstring &  str)
static

return a json formatted string

Parameters
strthe string to format
Returns
the given string in a json format

◆ to_json() [8/13]

static sstring seastar::json::formatter::to_json ( double  d)
static

return a json formatted double

Parameters
dthe double to format
Returns
the given double in a json format

◆ to_json() [9/13]

static sstring seastar::json::formatter::to_json ( float  f)
static

return a json formatted float

Parameters
fthe float to format
Returns
the given float in a json format

◆ to_json() [10/13]

static sstring seastar::json::formatter::to_json ( int  n)
static

return a json formatted int

Parameters
nthe int to format
Returns
the given int in a json format

◆ to_json() [11/13]

static sstring seastar::json::formatter::to_json ( long  n)
static

return a json formatted long

Parameters
nthe long to format
Returns
the given long in a json format

◆ to_json() [12/13]

static sstring seastar::json::formatter::to_json ( unsigned long  l)
static

return a json formatted unsigned long

Parameters
lunsigned long to format
Returns
the given unsigned long in a json format

◆ to_json() [13/13]

static sstring seastar::json::formatter::to_json ( unsigned  n)
static

return a json formatted unsigned

Parameters
nthe unsigned to format
Returns
the given unsigned in a json format

◆ write() [1/11]

static future seastar::json::formatter::write ( output_stream< char > &  s,
bool  d 
)
inlinestatic

return a json formatted bool

Parameters
dthe bool to format
Returns
the given bool in a json format

◆ write() [2/11]

static future seastar::json::formatter::write ( output_stream< char > &  s,
const char *  str 
)
inlinestatic

return a json formatted char* (treated as string)

Parameters
strthe char* to format
Returns
the given char* in a json format

◆ write() [3/11]

static future seastar::json::formatter::write ( output_stream< char > &  s,
const date_time &  d 
)
inlinestatic

return a json formatted date_time

Parameters
dthe date_time to format
Returns
the given date_time in a json format

◆ write() [4/11]

template<std::ranges::input_range Range>
requires (!internal::is_string_like<Range>)
static future seastar::json::formatter::write ( output_stream< char > &  s,
const Range &  range 
)
inlinestatic

Converts a range to a JSON array or object and writes it to an output stream.

Parameters
sThe output stream that will receive the JSON-formatted string
rangeThe range to convert. If the range contains key-value pairs (like std::map), it will be formatted as a JSON object. Otherwise, it will be formatted as a JSON array.
Returns
A future that will be resolved when the write operation completes

◆ write() [5/11]

static future seastar::json::formatter::write ( output_stream< char > &  s,
const sstring &  str 
)
inlinestatic

return a json formatted string

Parameters
strthe string to format
Returns
the given string in a json format

◆ write() [6/11]

static future seastar::json::formatter::write ( output_stream< char > &  s,
double  d 
)
inlinestatic

return a json formatted double

Parameters
dthe double to format
Returns
the given double in a json format

◆ write() [7/11]

static future seastar::json::formatter::write ( output_stream< char > &  s,
float  f 
)
inlinestatic

return a json formatted float

Parameters
fthe float to format
Returns
the given float in a json format

◆ write() [8/11]

static future seastar::json::formatter::write ( output_stream< char > &  s,
int  n 
)
inlinestatic

return a json formatted int

Parameters
nthe int to format
Returns
the given int in a json format

◆ write() [9/11]

template<std::derived_from< jsonable > Jsonable>
static future seastar::json::formatter::write ( output_stream< char > &  s,
Jsonable  obj 
)
inlinestatic

return a json formatted json object

Parameters
objthe date_time to format
Returns
the given json object in a json format

◆ write() [10/11]

static future seastar::json::formatter::write ( output_stream< char > &  s,
long  n 
)
inlinestatic

return a json formatted long

Parameters
nthe long to format
Returns
the given long in a json format

◆ write() [11/11]

static future seastar::json::formatter::write ( output_stream< char > &  s,
unsigned long  l 
)
inlinestatic

return a json formatted unsigned long

Parameters
lunsigned long to format
Returns
the given unsigned long in a json format

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