mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 10:35:50 +00:00
Per XLS-0095, we are taking steps to rename ripple(d) to xrpl(d). This change specifically removes all copyright notices referencing Ripple, XRPLF, and certain affiliated contributors upon mutual agreement, so the notice in the LICENSE.md file applies throughout. Copyright notices referencing external contributions remain as-is. Duplicate verbiage is also removed.
42 lines
952 B
C++
42 lines
952 B
C++
#ifndef XRPL_JSON_OUTPUT_H_INCLUDED
|
|
#define XRPL_JSON_OUTPUT_H_INCLUDED
|
|
|
|
#include <boost/beast/core/string.hpp>
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
namespace Json {
|
|
|
|
class Value;
|
|
|
|
using Output = std::function<void(boost::beast::string_view const&)>;
|
|
|
|
inline Output
|
|
stringOutput(std::string& s)
|
|
{
|
|
return [&](boost::beast::string_view const& b) {
|
|
s.append(b.data(), b.size());
|
|
};
|
|
}
|
|
|
|
/** Writes a minimal representation of a Json value to an Output in O(n) time.
|
|
|
|
Data is streamed right to the output, so only a marginal amount of memory is
|
|
used. This can be very important for a very large Json::Value.
|
|
*/
|
|
void
|
|
outputJson(Json::Value const&, Output const&);
|
|
|
|
/** Return the minimal string representation of a Json::Value in O(n) time.
|
|
|
|
This requires a memory allocation for the full size of the output.
|
|
If possible, use outputJson().
|
|
*/
|
|
std::string
|
|
jsonAsString(Json::Value const&);
|
|
|
|
} // namespace Json
|
|
|
|
#endif
|