Template Class RapidjsonFormat

Inheritance Relationships

Base Type

Class Documentation

template<typename AllocatorT = rapidjson::MemoryPoolAllocator<>>
class uconfig::RapidjsonFormat : public uconfig::Format

Rapidjson format.

tparam AllocatorT

rapidjson allocator to use. Default rapidjson::MemoryPoolAllocator<>.

Public Types

using allocator_type = AllocatorT

rapidjson allocator used.

using json_doc_type = rapidjson::GenericDocument<rapidjson::UTF8<>, allocator_type>

rapidjson::Document with allocator_type.

using json_value_type = rapidjson::GenericValue<rapidjson::UTF8<>, allocator_type>

rapidjson::Value with allocator_type.

using json_pointer_type = rapidjson::GenericPointer<json_value_type, allocator_type>

rapidjson::Pointer with allocator_type.

using source_type = json_value_type

rapidjson::Value to parse from.

using dest_type = json_doc_type

rapidjson::Document to emit to.

Public Functions

template<typename T>
std::optional<T> Parse(const json_value_type *source, const std::string &path) const

Parse the value at path from source JSON.

Template Parameters

T – Type to parse.

Parameters
  • [in] source – JSON object to parse from.

  • [in] path – JSON-path to the value.

Returns

Value wrapped in std::optional or std::nullopt.

template<typename T>
void Emit(dest_type *dest, const std::string &path, const T &value) const

Emit the value at path to JSON dest.

Template Parameters

T – Type to emit.

Parameters
  • [in] dest – JSON object to emit to.

  • [in] path – JSON-path to the value.

  • [in] value – Value to emit.

virtual std::string VectorElementPath(const std::string &vector_path, std::size_t index) const noexcept override

Construct JSON-path to a array element at index.

Parameters
  • [in] vector_path – Path to the JSON-array itself.

  • [in] index – Position in the array to make path to.

Returns

JSON-path to the array element at index.

Public Static Attributes

static const std::string name = "[JSON]"

Name of the format. Used to form nice error-strings.