userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
raw_string.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/formats/json/raw_string.hpp
4
/// @brief @copybrief formats::json::RawString
5
6
#
include
<
string
>
7
#
include
<
string_view
>
8
9
#
include
<
userver
/
formats
/
json_fwd
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
formats::
json
{
14
15
/// @brief JSON fragment stored as text and written to output without re-encoding.
16
class
RawString
{
17
public
:
18
/// @brief Constructs from provided json object.
19
/*implicit*/
RawString
(
const
Value
& value);
20
21
/// @brief Constructs from provided json string. It is the user's
22
/// responsibility to ensure that the input json string is valid.
23
explicit
RawString
(std::string json)
noexcept
;
24
25
/// @brief Constructs empty json object (`{}`).
26
RawString
()
noexcept
=
default
;
27
28
RawString(
RawString
&&)
noexcept
=
default
;
29
RawString(
const
RawString
&) =
default
;
30
31
RawString
& operator=(
RawString
&&)
noexcept
=
default
;
32
RawString
& operator=(
const
RawString
&) =
default
;
33
34
/// @brief Returns view to json
35
std::string_view
GetView
()
const
noexcept
;
36
37
friend
bool
operator==(
const
RawString
& lhs,
const
RawString
& rhs)
noexcept
{
38
return
lhs
.
GetView
(
)
== rhs
.
GetView
(
)
;
39
}
40
41
private
:
42
std::string json_;
43
};
44
45
void
WriteToStream(
const
RawString
& value, StringBuilder& sw);
46
47
Value
Serialize(
const
RawString
& json, formats::
serialize
::
To
<
Value
>);
48
49
RawString
Parse(
const
Value
& value, formats::
parse
::
To
<
RawString
>);
50
51
}
// namespace formats::json
52
53
USERVER_NAMESPACE_END
userver
formats
json
raw_string.hpp
Generated on
for userver by
Doxygen
1.17.0