2
0
mirror of https://github.com/boostorg/json.git synced 2026-02-09 11:12:37 +00:00

move operator<< overloads to corresponding headers

This commit is contained in:
Dmitry Arkhipov
2022-10-24 15:43:33 +03:00
parent 77c94f5cd2
commit 7d4b9cdefa
5 changed files with 95 additions and 44 deletions

View File

@@ -1659,6 +1659,30 @@ public:
return ! (lhs == rhs);
}
/** Serialize @ref array to an output stream.
This function serializes an `array` as JSON into the output stream.
@return Reference to `os`.
@par Complexity
Constant or linear in the size of `arr`.
@par Exception Safety
Strong guarantee.
Calls to `memory_resource::allocate` may throw.
@param os The output stream to serialize to.
@param arr The value to serialize.
*/
BOOST_JSON_DECL
friend
std::ostream&
operator<<(
std::ostream& os,
array const& arr);
private:
template<class It>
using iter_cat = typename

View File

@@ -1529,6 +1529,29 @@ public:
return ! (lhs == rhs);
}
/** Serialize @ref object to an output stream.
This function serializes an `object` as JSON into the output stream.
@return Reference to `os`.
@par Complexity
Constant or linear in the size of `obj`.
@par Exception Safety
Strong guarantee.
Calls to `memory_resource::allocate` may throw.
@param os The output stream to serialize to.
@param obj The value to serialize.
*/
BOOST_JSON_DECL
friend
std::ostream&
operator<<(
std::ostream& os,
object const& obj);
private:
#ifndef BOOST_JSON_DOCS
// VFALCO friending a detail function makes it public

View File

@@ -55,50 +55,6 @@ std::string
serialize(string_view t);
/** @} */
/** Serialize an element to an output stream.
This function serializes the specified element
as JSON into the output stream.
@return `os`.
@par Complexity
Constant or linear in the size of `t`.
@par Exception Safety
Strong guarantee.
Calls to `memory_resource::allocate` may throw.
@param os The output stream to serialize to.
@param t The value to serialize
*/
/** @{ */
BOOST_JSON_DECL
std::ostream&
operator<<(
std::ostream& os,
value const& t);
BOOST_JSON_DECL
std::ostream&
operator<<(
std::ostream& os,
array const& t);
BOOST_JSON_DECL
std::ostream&
operator<<(
std::ostream& os,
object const& t);
BOOST_JSON_DECL
std::ostream&
operator<<(
std::ostream& os,
string const& t);
/** @} */
BOOST_JSON_NS_END
#endif

View File

@@ -2738,6 +2738,30 @@ public:
return subview().find_last_not_of(ch, pos);
}
/** Serialize @ref string to an output stream.
This function serializes a `string` as JSON into the output stream.
@return Reference to `os`.
@par Complexity
Constant or linear in the size of `str`.
@par Exception Safety
Strong guarantee.
Calls to `memory_resource::allocate` may throw.
@param os The output stream to serialize to.
@param str The value to serialize.
*/
BOOST_JSON_DECL
friend
std::ostream&
operator<<(
std::ostream& os,
string const& str);
private:
class undo;

View File

@@ -3315,6 +3315,30 @@ public:
return ! (lhs == rhs);
}
/** Serialize @ref value to an output stream.
This function serializes a `value` as JSON into the output stream.
@return Reference to `os`.
@par Complexity
Constant or linear in the size of `jv`.
@par Exception Safety
Strong guarantee.
Calls to `memory_resource::allocate` may throw.
@param os The output stream to serialize to.
@param jv The value to serialize.
*/
BOOST_JSON_DECL
friend
std::ostream&
operator<<(
std::ostream& os,
value const& jv);
private:
static
void