40 #include "wpi/raw_ostream.h" 46 static constexpr uint8_t UTF8_ACCEPT = 0;
47 static constexpr uint8_t UTF8_REJECT = 1;
55 : o(s), loc(
std::localeconv()),
56 thousands_sep(loc->thousands_sep == nullptr ?
'\0' : * (loc->thousands_sep)),
57 decimal_point(loc->decimal_point == nullptr ?
'\0' : * (loc->decimal_point)),
58 indent_char(ichar), indent_string(512, indent_char)
82 void dump(
const json& val,
const bool pretty_print,
83 const bool ensure_ascii,
84 const unsigned int indent_step,
85 const unsigned int current_indent = 0);
102 void dump_escaped(
StringRef s,
const bool ensure_ascii);
113 template<
typename NumberType, detail::enable_if_t<
114 std::is_same<NumberType, uint64_t>::value or
115 std::is_same<NumberType, int64_t>::value,
117 void dump_integer(NumberType x)
126 const bool is_negative = (x <= 0) and (x != 0);
132 assert(i < number_buffer.size() - 1);
134 const auto digit = std::labs(static_cast<long>(x % 10));
135 number_buffer[i++] =
static_cast<char>(
'0' + digit);
142 assert(i < number_buffer.size() - 2);
143 number_buffer[i++] =
'-';
146 std::reverse(number_buffer.begin(), number_buffer.begin() + i);
147 o.write(number_buffer.data(), i);
158 void dump_float(
double x);
181 static uint8_t decode(uint8_t& state, uint32_t& codep,
const uint8_t byte) noexcept;
188 std::array<char, 64> number_buffer{{}};
191 const std::lconv* loc =
nullptr;
193 const char thousands_sep =
'\0';
195 const char decimal_point =
'\0';
198 std::array<char, 512> string_buffer{{}};
201 const char indent_char;
203 std::string indent_string;
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
Definition: SmallVector.h:946
namespace to hold default to_json function
Definition: json_binary_writer.cpp:39
Definition: json_serializer.h:44
a class to store JSON values
Definition: json.h:2714
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
serializer(raw_ostream &s, const char ichar)
Definition: json_serializer.h:54
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
Definition: json_serializer.cpp:1130