userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
string_builder.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <string>
7
#include <string_view>
8
9
#include <
userver/formats/json/string_builder_fwd.hpp
>
10
#include <
userver/formats/json/value.hpp
>
11
#include <
userver/formats/serialize/to.hpp
>
12
#include <
userver/formats/serialize/write_to_stream.hpp
>
13
#include <
userver/utils/fast_pimpl.hpp
>
14
15
USERVER_NAMESPACE_BEGIN
16
17
namespace
formats::json
{
18
31
class
StringBuilder final :
public
serialize::SaxStream
{
32
public
:
33
// Required by the WriteToStream fallback to Serialize
34
using
Value =
formats::json::Value
;
35
36
StringBuilder();
37
~StringBuilder();
38
41
class
ObjectGuard final {
42
public
:
43
explicit
ObjectGuard(StringBuilder& sw);
44
~ObjectGuard();
45
46
private
:
47
StringBuilder& sw_;
48
};
49
52
class
ArrayGuard final {
53
public
:
54
explicit
ArrayGuard(StringBuilder& sw);
55
~ArrayGuard();
56
57
private
:
58
StringBuilder& sw_;
59
};
60
62
std::string
GetString
()
const
;
63
std::string_view GetStringView()
const
;
64
65
void
WriteNull();
66
void
WriteString(std::string_view value);
67
void
WriteBool(
bool
value);
68
void
WriteInt64(int64_t value);
69
void
WriteUInt64(uint64_t value);
70
void
WriteDouble(
double
value);
71
73
void
Key
(std::string_view sw);
74
76
void
WriteRawString
(std::string_view value);
77
78
void
WriteValue(
const
Value& value);
79
80
private
:
81
struct
Impl;
82
utils::FastPimpl<Impl, 112, 8>
impl_;
83
};
84
85
void
WriteToStream(
bool
value,
StringBuilder
& sw);
86
void
WriteToStream(
long
long
value,
StringBuilder
& sw);
87
void
WriteToStream(
unsigned
long
long
value,
StringBuilder
& sw);
88
void
WriteToStream(
int
value,
StringBuilder
& sw);
89
void
WriteToStream(
unsigned
value,
StringBuilder
& sw);
90
void
WriteToStream(
long
value,
StringBuilder
& sw);
91
void
WriteToStream(
unsigned
long
value,
StringBuilder
& sw);
92
void
WriteToStream(
double
value,
StringBuilder
& sw);
93
void
WriteToStream(
const
char
* value,
StringBuilder
& sw);
94
void
WriteToStream(std::string_view value,
StringBuilder
& sw);
95
void
WriteToStream(
const
formats::json::Value
& value,
StringBuilder
& sw);
96
void
WriteToStream(
const
std::string& value,
StringBuilder
& sw);
97
98
void
WriteToStream(std::chrono::system_clock::time_point tp,
StringBuilder
& sw);
99
100
}
// namespace formats::json
101
102
USERVER_NAMESPACE_END
userver
formats
json
string_builder.hpp
Generated on
for userver by
Doxygen
1.17.0