template<typename StreamLike>
vt::util::json::Appender struct

Appends data to a JSON output stream by adding elements to a JSON array until it is destroyed.

Base classes

struct BaseAppender
Base class for JSON appender to avoid unnecessary inclusions.

Public types

using jsonlib = nlohmann::json
using SerializerType = nlohmann::detail::serializer<jsonlib>
using AdaptorType = util::json::OutputAdaptor<StreamLike>

Constructors, destructors, conversion operators

Appender(std::string const& array, jsonlib const& metadata, std::string const& filename, bool compress)
Construct a JSON appender for a specific array with a filename.
Appender(std::string const& array, jsonlib const& metadata, StreamLike in_os, bool compress)
Construct a JSON appender for a specific array with a stream.
~Appender() virtual

Public functions

void addElm(jsonlib const& in)
Add an element to the JSON array.
void stageObject(jsonlib const& in)
Create an additional element in stages.
void commitStaged()
Commit a staged element.
auto finish() -> StreamLike
Finalize the output, closing the array, and flushing the stream.

Function documentation

template<typename StreamLike>
vt::util::json::Appender<StreamLike>::Appender(std::string const& array, jsonlib const& metadata, std::string const& filename, bool compress)

Construct a JSON appender for a specific array with a filename.

Parameters
array in the JSON array name
metadata in the JSON metadata
filename in the JSON filename
compress in whether to compress the output

template<typename StreamLike>
vt::util::json::Appender<StreamLike>::Appender(std::string const& array, jsonlib const& metadata, StreamLike in_os, bool compress)

Construct a JSON appender for a specific array with a stream.

Parameters
array in the JSON array name
metadata in the JSON metadata
in_os in the output stream
compress in whether to compress the output

template<typename StreamLike>
void vt::util::json::Appender<StreamLike>::addElm(jsonlib const& in)

Add an element to the JSON array.

Parameters
in in the element to add

template<typename StreamLike>
void vt::util::json::Appender<StreamLike>::stageObject(jsonlib const& in)

Create an additional element in stages.

Parameters
in in an object to stage