]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/json/serialize.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / json / serialize.hpp
1 //
2 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/boostorg/json
8 //
9
10 #ifndef BOOST_JSON_SERIALIZE_HPP
11 #define BOOST_JSON_SERIALIZE_HPP
12
13 #include <boost/json/detail/config.hpp>
14 #include <boost/json/value.hpp>
15 #include <iosfwd>
16 #include <string>
17
18 BOOST_JSON_NS_BEGIN
19
20 /** Return a string representing a serialized element.
21
22 This function serializes `t` as JSON and returns
23 it as a `std::string`.
24
25 @par Complexity
26 Constant or linear in the size of `t`.
27
28 @par Exception Safety
29 Strong guarantee.
30 Calls to allocate may throw.
31
32 @return The serialized string
33
34 @param t The value to serialize
35 */
36 /** @{ */
37 BOOST_JSON_DECL
38 std::string
39 serialize(value const& t);
40
41 BOOST_JSON_DECL
42 std::string
43 serialize(array const& t);
44
45 BOOST_JSON_DECL
46 std::string
47 serialize(object const& t);
48
49 BOOST_JSON_DECL
50 std::string
51 serialize(string const& t);
52
53 BOOST_JSON_DECL
54 std::string
55 serialize(string_view t);
56 /** @} */
57
58 /** Serialize an element to an output stream.
59
60 This function serializes the specified element
61 as JSON into the output stream.
62
63 @return `os`.
64
65 @par Complexity
66 Constant or linear in the size of `t`.
67
68 @par Exception Safety
69 Strong guarantee.
70 Calls to `memory_resource::allocate` may throw.
71
72 @param os The output stream to serialize to.
73
74 @param t The value to serialize
75 */
76 /** @{ */
77 BOOST_JSON_DECL
78 std::ostream&
79 operator<<(
80 std::ostream& os,
81 value const& t);
82
83 BOOST_JSON_DECL
84 std::ostream&
85 operator<<(
86 std::ostream& os,
87 array const& t);
88
89 BOOST_JSON_DECL
90 std::ostream&
91 operator<<(
92 std::ostream& os,
93 object const& t);
94
95 BOOST_JSON_DECL
96 std::ostream&
97 operator<<(
98 std::ostream& os,
99 string const& t);
100 /** @} */
101
102 BOOST_JSON_NS_END
103
104 #endif