#include </home/runner/work/allwpilib/allwpilib/wpiutil/src/main/native/thirdparty/json/include/wpi/json_serializer.h>
|
| serializer (raw_ostream &s, const char ichar, size_t indent_init_len=512) |
|
| serializer (const serializer &)=delete |
|
serializer & | operator= (const serializer &)=delete |
|
void | dump (const json &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_same_v< NumberType, uint64_t >, int > = 0> |
bool | is_negative_integer (NumberType x) |
|
template<typename NumberType , detail::enable_if_t< std::is_same_v< NumberType, int64_t >, int > = 0> |
bool | is_negative_integer (NumberType x) |
|
template<typename NumberType , detail::enable_if_t< std::is_same< NumberType, uint64_t >::value or std::is_same< NumberType, int64_t >::value, int > = 0> |
void | dump_integer (NumberType x) |
| dump an integer More...
|
|
void | dump_float (double x) |
| dump a floating-point number More...
|
|
|
static uint8_t | decode (uint8_t &state, uint32_t &codep, const uint8_t byte) noexcept |
| check whether a string is UTF-8 encoded More...
|
|
◆ serializer() [1/2]
wpi::json::serializer::serializer |
( |
raw_ostream & |
s, |
|
|
const char |
ichar, |
|
|
size_t |
indent_init_len = 512 |
|
) |
| |
|
inline |
- Parameters
-
[in] | s | output stream to serialize to |
[in] | ichar | indentation character to use |
[in] | indent_init_len | initial length of indentation string buffer |
◆ serializer() [2/2]
wpi::json::serializer::serializer |
( |
const serializer & |
| ) |
|
|
delete |
◆ decode()
static uint8_t wpi::json::serializer::decode |
( |
uint8_t & |
state, |
|
|
uint32_t & |
codep, |
|
|
const uint8_t |
byte |
|
) |
| |
|
staticnoexcept |
check whether a string is UTF-8 encoded
The function checks each byte of a string whether it is UTF-8 encoded. The result of the check is stored in the state parameter. The function must be called initially with state 0 (accept). State 1 means the string must be rejected, because the current byte is not allowed. If the string is completely processed, but the state is non-zero, the string ended prematurely; that is, the last byte indicated more bytes should have followed.
- Parameters
-
[in,out] | state | the state of the decoding |
[in,out] | codep | codepoint (valid only if resulting state is UTF8_ACCEPT) |
[in] | byte | next byte to decode |
- Returns
- new state
- Note
- The function has been edited: a std::array is used.
- Copyright
- Copyright (c) 2008-2009 Bjoern Hoehrmann bjoer.nosp@m.n@ho.nosp@m.ehrma.nosp@m.nn.d.nosp@m.e
- See also
- http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
◆ dump()
void wpi::json::serializer::dump |
( |
const json & |
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
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] | val | value to serialize |
[in] | pretty_print | whether the output shall be pretty-printed |
[in] | ensure_ascii | whether the output shall only use ASCII chars |
[in] | indent_step | the indent level |
[in] | current_indent | the current indent level (only used internally) |
◆ dump_escaped()
void wpi::json::serializer::dump_escaped |
( |
std::string_view |
s, |
|
|
const bool |
ensure_ascii |
|
) |
| |
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] | s | the string to escape |
[in] | ensure_ascii | whether to escape non-ASCII characters with "\uXXXX" sequences |
Complexity: Linear in the length of string s.
◆ dump_float()
void wpi::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] | x | floating-point number to dump |
◆ dump_integer()
void wpi::json::serializer::dump_integer |
( |
NumberType |
x | ) |
|
|
inline |
dump an integer
Dump a given integer to output stream o. Works internally with number_buffer.
- Parameters
-
[in] | x | integer number (signed or unsigned) to dump |
- Template Parameters
-
NumberType | either int64_t or uint64_t |
◆ is_negative_integer() [1/2]
template<typename NumberType ,
detail::enable_if_t< std::is_same_v< NumberType, uint64_t >, int > = 0>
bool wpi::json::serializer::is_negative_integer |
( |
NumberType |
x | ) |
|
|
inline |
◆ is_negative_integer() [2/2]
template<typename NumberType ,
detail::enable_if_t< std::is_same_v< NumberType, int64_t >, int > = 0>
bool wpi::json::serializer::is_negative_integer |
( |
NumberType |
x | ) |
|
|
inline |
◆ operator=()
The documentation for this class was generated from the following file:
- /home/runner/work/allwpilib/allwpilib/wpiutil/src/main/native/thirdparty/json/include/wpi/json_serializer.h