|
GREM 3.12.0
Game/Rendering Engine Modules for C++
|
Stateful wrapper object of an output stream for JSON serialization. More...
#include <GREM/core/formats/json.hpp>
Public Member Functions | |
| Writer (std::ostream &stream, const SerializationOptions &options={}) | |
| Construct a writer with an output stream as output. | |
| void | write (char ch) |
| Write a single raw char to the output without any extra formatting. | |
| void | write (StringView raw) |
| Write a raw sequence of chars to the output without any extra formatting. | |
| void | writeIndentation () |
| Write a sequence of indentation characters to the output. | |
| void | writeNewline () |
| Write a newline sequence to the output. | |
| void | writeNull () |
| Write a single JSON value of type Null to the output. | |
| void | writeBoolean (Boolean value) |
| Write a single JSON value of type Boolean to the output. | |
| void | writeString (StringView value) |
| Write a single JSON value of type String to the output from a raw string. | |
| void | writeString (UTF8StringView value) |
| Write a single JSON value of type String to the output from a raw UTF8 string. | |
| void | writeString (const auto &value) |
| Write a single JSON value of type String to the output from any string-view-like or JSON-serializable value. | |
| void | writeNumber (Number value) |
| Write a single JSON value of type Number to the output. | |
| void | writeCustomObject (size_t propertyCountHint, auto callback) |
| Write a single JSON object to the output, using a callback function for writing out the properties. | |
| void | writeCustomObject (auto callback) |
| Write a single JSON object to the output, using a callback function for writing out the properties. | |
| template<typename SerializerOverride = detail::NoSerializerOverride> | |
| void | writeObject (const auto &value, SerializerOverride serializerOverride={}) |
| Write a single JSON object to the output from any range of JSON-serializable key-value pairs. | |
| void | writeCustomArray (size_t itemCountHint, auto callback) |
| Write a single JSON array to the output, using a callback function for writing out the items. | |
| void | writeCustomArray (auto callback) |
| Write a single JSON array to the output, using a callback function for writing out the items. | |
| template<typename SerializerOverride = detail::NoSerializerOverride> | |
| void | writeArray (const auto &value, SerializerOverride serializerOverride={}) |
| Write a single JSON array to the output from any range of JSON-serializable values. | |
| template<typename SerializerOverride = detail::NoSerializerOverride> | |
| void | writeOptional (const auto &value, SerializerOverride serializerOverride={}) |
| Write a single JSON value to the output from any value that supports conversion to bool and the dereference operator. | |
| template<typename Aggregate, typename SerializerOverride = detail::NoSerializerOverride> | |
| void | writeAggregateObject (const Aggregate &value, SerializerOverride serializerOverride={}) |
| Write a single JSON value to the output from any value of aggregate type. | |
| template<typename Aggregate, typename SerializerOverride = detail::NoSerializerOverride> | |
| void | writeAggregateArray (const Aggregate &value, SerializerOverride serializerOverride={}) |
| Write a single JSON value to the output from any value of aggregate type. | |
| template<typename T, typename SerializerOverride = detail::NoSerializerOverride> | |
| void | serialize (const T &value, SerializerOverride serializerOverride={}) |
| Write any JSON-serializable value to the output using its corresponding implementation of Serializer. | |
Public Attributes | |
| SerializationOptions | options |
| The current options of the serialization process. | |
Stateful wrapper object of an output stream for JSON serialization.
|
inlineexplicit |
Construct a writer with an output stream as output.
| stream | output stream to write to. |
| options | output options, see SerializationOptions. |
|
inline |
Write a single raw char to the output without any extra formatting.
| ch | value to write. |
| any | exception thrown by the underlying output stream. |
|
inline |
Write a raw sequence of chars to the output without any extra formatting.
| raw | values to write. |
| any | exception thrown by the underlying output stream. |
|
inline |
Write a sequence of indentation characters to the output.
The length of the sequence matches the current indentation level specified in the options.
| any | exception thrown by the underlying output stream. |
|
inline |
Write a newline sequence to the output.
| any | exception thrown by the underlying output stream. |
|
inline |
Write a single JSON value of type Null to the output.
| any | exception thrown by the underlying output stream. |
|
inline |
Write a single JSON value of type Boolean to the output.
| value | value to write. |
| any | exception thrown by the underlying output stream. |
|
inline |
Write a single JSON value of type String to the output from a raw string.
| value | raw string value to write. |
| any | exception thrown by the underlying output stream. |
|
inline |
Write a single JSON value of type String to the output from a raw UTF8 string.
| value | raw string value to write. |
| any | exception thrown by the underlying output stream. |
|
inline |
Write a single JSON value of type String to the output from any string-view-like or JSON-serializable value.
| value | value to write. |
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the underlying string view conversion or Serializer implementation of the given value type. |
|
inline |
Write a single JSON value of type Number to the output.
| value | value to write. |
| any | exception thrown by the underlying output stream. |
|
inline |
Write a single JSON object to the output, using a callback function for writing out the properties.
| propertyCountHint | estimated number of properties contained by the object, which will be used to determine how to format the object when pretty printing is enabled. |
| callback | function object for writing the object contents, which should return void and accept the following generic parameter:
|
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the callback function. |
|
inline |
Write a single JSON object to the output, using a callback function for writing out the properties.
| callback | function object for writing the object contents, which should return void and accept the following generic parameter:
|
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the callback function. |
|
inline |
Write a single JSON object to the output from any range of JSON-serializable key-value pairs.
| value | range to write as an object. |
| serializerOverride | overloaded function object that overrides the default serialization behavior for nested values whenever a call to serializerOverride(writer, value) yields a valid matching overload. |
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the Serializer/SerializerOverride implementations of the given key/value types. |
|
inline |
Write a single JSON array to the output, using a callback function for writing out the items.
| itemCountHint | estimated number of items contained by the array, which will be used to determine how to format the array when pretty printing is enabled. |
| callback | function object for writing the array contents, which should return void and accept the following generic parameter:
|
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the callback function. |
|
inline |
Write a single JSON array to the output, using a callback function for writing out the items.
| callback | function object for writing the array contents, which should return void and accept the following generic parameter:
|
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the callback function. |
|
inline |
Write a single JSON array to the output from any range of JSON-serializable values.
| value | range to write as an array. |
| serializerOverride | overloaded function object that overrides the default serialization behavior for nested items whenever a call to serializerOverride(writer, value) yields a valid matching overload. |
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the Serializer/SerializerOverride implementation of the element type of the given value type. |
|
inline |
Write a single JSON value to the output from any value that supports conversion to bool and the dereference operator.
If the value evaluates to true when converted to bool, the value is dereferenced and serialized normally. Otherwise, null is written.
| value | value to write. |
| serializerOverride | overloaded function object that overrides the default serialization behavior for the nested value whenever a call to serializerOverride(writer, value) yields a valid matching overload. |
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the Serializer implementation of the dereferenced type of the given value type. |
|
inline |
Write a single JSON value to the output from any value of aggregate type.
The output JSON format is an object with properties whose keys match the field names of the aggregate.
| value | aggregate whose fields to write. |
| serializerOverride | overloaded function object that overrides the default serialization behavior for nested fields whenever a call to serializerOverride(writer, value) yields a valid matching overload. |
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the Serializer/SerializerOverride implementations of the given field types. |
|
inline |
Write a single JSON value to the output from any value of aggregate type.
The output JSON format is an array with all fields as items.
| value | aggregate whose fields to write. |
| serializerOverride | overloaded function object that overrides the default serialization behavior for nested fields whenever a call to serializerOverride(writer, value) yields a valid matching overload. |
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the Serializer/SerializerOverride implementations of the given field types. |
|
inline |
Write any JSON-serializable value to the output using its corresponding implementation of Serializer.
| value | value to write. |
| serializerOverride | overloaded function object that overrides the default serialization behavior for the value or its nested elements/fields whenever a call to serializerOverride(writer, value) yields a valid matching overload. |
| any | exception thrown by the underlying output stream. |
| any | exception thrown by the Serializer/SerializerOverride implementation of T. |
| SerializationOptions grem::json::Writer::options |
The current options of the serialization process.