xentara-utils v2.0.4
The Xentara Utility Library
|
A JSON document. More...
#include <xentara/utils/json/decoder/Document.hpp>
Public Member Functions | |
Document (std::reference_wrapper< io::InputStream< char > > stream) | |
Constructor. | |
auto | read () -> Value |
Reads the root element of the document. | |
auto | readAsObject () -> Object |
Reads the root element of the document as a JSON object. | |
auto | readAsArray () -> Array |
Reads the root element of the document as a JSON array. | |
auto | description () const -> std::string |
Retuns a descption of the stream used to read the document. | |
auto | lineNumber () const -> std::uint_least32_t |
Gets the current line number. | |
auto | location () const -> Location |
Gets the current location. | |
auto | location (std::uint_least32_t lineNumber) const -> Location |
Gets an arbitrary location within the document. | |
A JSON document.
Objects of this class can be moved, but not copied.
|
explicit |
Constructor.
stream | The stream to read the document from. The stream must contain the document encoded as UTF-8 data. |
auto xentara::utils::json::decoder::Document::description | ( | ) | const -> std::string |
Retuns a descption of the stream used to read the document.
auto xentara::utils::json::decoder::Document::lineNumber | ( | ) | const -> std::uint_least32_t |
Gets the current line number.
auto xentara::utils::json::decoder::Document::location | ( | ) | const -> Location |
Gets the current location.
auto xentara::utils::json::decoder::Document::location | ( | std::uint_least32_t | lineNumber | ) | const -> Location |
Gets an arbitrary location within the document.
lineNumber | The line number |
auto xentara::utils::json::decoder::Document::read | ( | ) | -> Value |
Reads the root element of the document.
This function loads the root element of the document. The root element is usually a JSON object, but can theoretically be any type of value.
SyntaxError | The stream does not contain a valid JSON element |
std::runtime_error | An error occured reading from the stream |
auto xentara::utils::json::decoder::Document::readAsArray | ( | ) | -> Array |
Reads the root element of the document as a JSON array.
This function loads the root element of the document and tries to interpret it as a JSON array.
SyntaxError | The stream does not contain a valid JSON element |
std::runtime_error | An error occured reading from the stream |
auto xentara::utils::json::decoder::Document::readAsObject | ( | ) | -> Object |
Reads the root element of the document as a JSON object.
This function loads the root element of the document and tries to interpret it as a JSON object.
SyntaxError | The stream does not contain a valid JSON element |
std::runtime_error | An error occured reading from the stream |