WPILibC++ 2024.3.2
detail::serializer< BasicJsonType > Class Template Reference

#include </home/runner/work/allwpilib/allwpilib/wpiutil/src/main/native/thirdparty/json/include/wpi/detail/output/serializer.h>

Public Member Functions

 serializer (output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict, size_t indent_init_len=512)
 
 serializer (raw_ostream &os, const char ichar, size_t indent_init_len=512, error_handler_t error_handler_=error_handler_t::strict)
 
 serializer (const serializer &)=delete
 
serializeroperator= (const serializer &)=delete
 
 serializer (serializer &&)=delete
 
serializeroperator= (serializer &&)=delete
 
 ~serializer ()=default
 
void dump (const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
 internal implementation of the serialization function More...
 
void dump_escaped (std::string_view s, const bool ensure_ascii)
 dump escaped string More...
 
template<typename NumberType , detail::enable_if_t< std::is_integral< NumberType >::value||std::is_same< NumberType, number_unsigned_t >::value||std::is_same< NumberType, number_integer_t >::value||std::is_same< NumberType, binary_char_t >::value, int > = 0>
void dump_integer (NumberType x)
 dump an integer More...
 
void dump_float (number_float_t x)
 dump a floating-point number More...
 
void dump_float (number_float_t x, std::true_type)
 
void dump_float (number_float_t x, std::false_type)
 

Constructor & Destructor Documentation

◆ serializer() [1/4]

template<typename BasicJsonType >
detail::serializer< BasicJsonType >::serializer ( output_adapter_t< char >  s,
const char  ichar,
error_handler_t  error_handler_ = error_handler_t::strict,
size_t  indent_init_len = 512 
)
inline
Parameters
[in]soutput stream to serialize to
[in]icharindentation character to use
[in]error_handler_how to react on decoding errors

◆ serializer() [2/4]

template<typename BasicJsonType >
detail::serializer< BasicJsonType >::serializer ( raw_ostream &  os,
const char  ichar,
size_t  indent_init_len = 512,
error_handler_t  error_handler_ = error_handler_t::strict 
)
inline

◆ serializer() [3/4]

template<typename BasicJsonType >
detail::serializer< BasicJsonType >::serializer ( const serializer< BasicJsonType > &  )
delete

◆ serializer() [4/4]

template<typename BasicJsonType >
detail::serializer< BasicJsonType >::serializer ( serializer< BasicJsonType > &&  )
delete

◆ ~serializer()

template<typename BasicJsonType >
detail::serializer< BasicJsonType >::~serializer ( )
default

Member Function Documentation

◆ dump()

template<typename BasicJsonType >
void detail::serializer< BasicJsonType >::dump ( const BasicJsonType &  val,
const bool  pretty_print,
const bool  ensure_ascii,
const unsigned int  indent_step,
const unsigned int  current_indent = 0 
)
inline

internal implementation of the serialization function

This function is called by the public member function dump and organizes the serialization internally. The indentation level is propagated as additional parameter. In case of arrays and objects, the function is called recursively.

  • strings and object keys are escaped using escape_string()
  • integer numbers are converted implicitly via operator<<
  • floating-point numbers are converted to a string using "%g" format
  • binary values are serialized as objects containing the subtype and the byte array
Parameters
[in]valvalue to serialize
[in]pretty_printwhether the output shall be pretty-printed
[in]ensure_asciiIf ensure_ascii is true, all non-ASCII characters in the output are escaped with \uXXXX sequences, and the result consists of ASCII characters only.
[in]indent_stepthe indent level
[in]current_indentthe current indent level (only used internally)

◆ dump_escaped()

template<typename BasicJsonType >
void detail::serializer< BasicJsonType >::dump_escaped ( std::string_view  s,
const bool  ensure_ascii 
)
inline

dump escaped string

Escape a string by replacing certain special characters by a sequence of an escape character (backslash) and another character and other control characters by a sequence of "\u" followed by a four-digit hex representation. The escaped string is written to output stream o.

Parameters
[in]sthe string to escape
[in]ensure_asciiwhether to escape non-ASCII characters with \uXXXX sequences

@complexity Linear in the length of string s.

◆ dump_float() [1/3]

template<typename BasicJsonType >
void detail::serializer< BasicJsonType >::dump_float ( number_float_t  x)
inline

dump a floating-point number

Dump a given floating-point number to output stream o. Works internally with number_buffer.

Parameters
[in]xfloating-point number to dump

◆ dump_float() [2/3]

template<typename BasicJsonType >
void detail::serializer< BasicJsonType >::dump_float ( number_float_t  x,
std::false_type   
)
inline

◆ dump_float() [3/3]

template<typename BasicJsonType >
void detail::serializer< BasicJsonType >::dump_float ( number_float_t  x,
std::true_type   
)
inline

◆ dump_integer()

template<typename BasicJsonType >
template<typename NumberType , detail::enable_if_t< std::is_integral< NumberType >::value||std::is_same< NumberType, number_unsigned_t >::value||std::is_same< NumberType, number_integer_t >::value||std::is_same< NumberType, binary_char_t >::value, int > = 0>
void detail::serializer< BasicJsonType >::dump_integer ( NumberType  x)
inline

dump an integer

Dump a given integer to output stream o. Works internally with number_buffer.

Parameters
[in]xinteger number (signed or unsigned) to dump
Template Parameters
NumberTypeeither number_integer_t or number_unsigned_t

◆ operator=() [1/2]

template<typename BasicJsonType >
serializer & detail::serializer< BasicJsonType >::operator= ( const serializer< BasicJsonType > &  )
delete

◆ operator=() [2/2]

template<typename BasicJsonType >
serializer & detail::serializer< BasicJsonType >::operator= ( serializer< BasicJsonType > &&  )
delete

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