xentara-utils v2.0.4
The Xentara Utility Library
|
A JSON document. More...
#include <xentara/utils/json/encoder/Document.hpp>
Public Types | |
enum class | Format { Regular , Compact } |
different formats More... | |
Public Member Functions | |
Document (std::reference_wrapper< io::OutputStream< char > > stream, Format format=Format::Regular) noexcept | |
Constructor. | |
~Document () noexcept(false) | |
Destructor. | |
auto | close () -> void |
Writes the termination of the document, if it has not already been written. | |
auto | asObject () -> Object |
Adds a JSON object as the root element of the document. | |
auto | asArray () -> Array |
Adds a JSON array as the root element of the document. | |
auto | asValue () -> Value |
Adds a generic JSON value as the root element of the document. | |
A JSON document.
Objects of this class can be moved, but not copied.
|
strong |
|
explicitnoexcept |
Constructor.
stream | The stream to write the document to |
format | The format to use |
xentara::utils::json::encoder::Document::~Document | ( | ) |
Destructor.
This destructor writes the termination, if it has not already been written.
This destructor will throw an exception if the termination cannot be written. To prevent termination of the program, no exceptions are thrown during stack windup, though. You can prevent the destructor from throwing any exceptions by closing the objects manually beforehand using close().
std::runtime_error | An error occured writing to the stream |
auto xentara::utils::json::encoder::Document::asArray | ( | ) | -> Array |
Adds a JSON array as the root element of the document.
std::runtime_error | An error occured writing to the stream |
auto xentara::utils::json::encoder::Document::asObject | ( | ) | -> Object |
Adds a JSON object as the root element of the document.
std::runtime_error | An error occured writing to the stream |
auto xentara::utils::json::encoder::Document::asValue | ( | ) | -> Value |
Adds a generic JSON value as the root element of the document.
std::runtime_error | An error occured writing to the stream |
auto xentara::utils::json::encoder::Document::close | ( | ) | -> void |
Writes the termination of the document, if it has not already been written.
std::runtime_error | An error occured writing to the stream |