1#ifndef SIMDJSON_INTERNAL_JSONFORMATUTILS_H
2#define SIMDJSON_INTERNAL_JSONFORMATUTILS_H
4#include "simdjson/base.h"
12inline std::ostream& operator<<(std::ostream& out,
const escape_json_string &str);
14class escape_json_string {
16 escape_json_string(std::string_view _str) noexcept : str{_str} {}
17 operator std::string() const noexcept { std::stringstream s; s << *
this;
return s.str(); }
20 friend std::ostream& operator<<(std::ostream& out,
const escape_json_string &unescaped);
23inline std::ostream& operator<<(std::ostream& out,
const escape_json_string &unescaped) {
24 for (
size_t i=0; i<unescaped.str.length(); i++) {
25 switch (unescaped.str[i]) {
48 if (
static_cast<unsigned char>(unescaped.str[i]) <= 0x1F) {
50 std::ios::fmtflags f(out.flags());
51 out <<
"\\u" << std::hex << std::setw(4) << std::setfill(
'0') << int(unescaped.str[i]);
54 out << unescaped.str[i];
The top level simdjson namespace, containing everything the library provides.