WPILibC++  unspecified
wpi::json::serializer Class Reference

wrapper around the serialization functions More...

#include <json_serializer.h>

Public Member Functions

 serializer (const serializer &)=delete
 
serializeroperator= (const serializer &)=delete
 
 serializer (llvm::raw_ostream &s)
 
void dump (const json &val, const bool pretty_print, const unsigned int indent_step, const unsigned int current_indent=0)
 internal implementation of the serialization function More...
 
void dump_escaped (llvm::StringRef s) const
 dump escaped string More...
 
void dump_float (double x)
 dump a floating-point number More...
 

Detailed Description

wrapper around the serialization functions

Constructor & Destructor Documentation

wpi::json::serializer::serializer ( llvm::raw_ostream s)
inlineexplicit
Parameters
[in]soutput stream to serialize to
[in]icharindentation character to use

Member Function Documentation

void json::serializer::dump ( const json val,
const bool  pretty_print,
const unsigned int  indent_step,
const unsigned int  current_indent = 0 
)

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
Parameters
[in]valvalue to serialize
[in]pretty_printwhether the output shall be pretty-printed
[in]indent_stepthe indent level
[in]current_indentthe current indent level (only used internally)
void json::serializer::dump_escaped ( llvm::StringRef  s) const

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

Linear in the length of string s.

void json::serializer::dump_float ( double  x)

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

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