xentara-workbench-plugin v1.0.1
The Xentara Workbench Plugin Framework
Loading...
Searching...
No Matches
xentara::workbench::json::Object Class Referencefinal

A generic JSON object. More...

#include <xentara/workbench/json/Object_stage1.hpp>

Classes

class  XentaraElementFilter
 A decoding filter class that throws an exception if a member name is reserved in the configuration of Xentara elements. More...
 

Public Member Functions

 Object ()
 Default constructor.
 
 Object (const Object &)
 Copy constructor.
 
 Object (Object &&) noexcept
 Move constructor.
 
 ~Object ()
 Destructor.
 
auto operator= (const Object &) -> Object &
 Copy-assignment operator.
 
auto operator= (Object &&) noexcept -> Object &
 Move-assignment operator.
 
constexpr auto empty () const noexcept -> bool
 Checks if the object is empty.
 
auto decode (utils::json::decoder::Object &encodedObject, DecodingOptions options={}) -> void
 Reads the object from a JSON object.
 
auto decode (utils::json::decoder::Value &encodedValue, DecodingOptions options={}) -> void
 Reads the object from a JSON value.
 
template<typename Filter >
requires std::is_invocable_r_v<bool, std::decay_t<Filter>, const utils::json::decoder::Name &, utils::json::decoder::Value &>
auto decode (utils::json::decoder::Object &encodedObject, Filter &&filter, DecodingOptions options={}) -> void
 Reads the object from a JSON object, applying a filter to the top-level JSON object.
 
template<typename Filter >
requires std::is_invocable_r_v<bool, std::decay_t<Filter>, const utils::json::decoder::Name &, utils::json::decoder::Value &>
auto decode (utils::json::decoder::Value &encodedValue, Filter &&filter, DecodingOptions options={}) -> void
 Reads the object from a JSON value, applying a filter to the top-level JSON object.
 
auto encode (utils::json::encoder::Object &encodedObject) const -> void
 Write the object to a JSON object.
 
auto encode (utils::json::encoder::Value &encodedValue) const -> void
 Write the object to a generic JSON value.
 
auto toString (utils::json::encoder::Document::Format format=utils::json::encoder::Document::Format::Regular) const -> std::string
 Converts the JSON object to a string.
 
auto operator== (const Object &) const -> bool
 Equality comparison operator.
 

Static Public Member Functions

static auto fromString (std::string_view string, DecodingOptions options={}) -> utils::eh::expected< Object, ui::String >
 Creates a JSON object from a string.
 
template<typename Filter >
requires std::is_invocable_r_v<bool, std::decay_t<Filter>, const utils::json::decoder::Name &, utils::json::decoder::Value &>
static auto fromString (std::string_view string, Filter &&filter, DecodingOptions options={}) -> utils::eh::expected< Object, ui::String >
 Creates a JSON object from a string, applying a filter to the top-level JSON object.
 

Static Public Attributes

static constexpr XentaraElementFilter kXentaraElementFilter
 A decoding filter that throws an exception if a member name is reserved in the configuration of Xentara elements.
 

Detailed Description

A generic JSON object.

Constructor & Destructor Documentation

◆ Object() [1/3]

xentara::workbench::json::Object::Object ( )
default

Default constructor.

◆ Object() [2/3]

xentara::workbench::json::Object::Object ( const Object )
default

Copy constructor.

◆ Object() [3/3]

xentara::workbench::json::Object::Object ( Object &&  )
defaultnoexcept

Move constructor.

◆ ~Object()

xentara::workbench::json::Object::~Object ( )
default

Destructor.

Member Function Documentation

◆ decode() [1/4]

auto xentara::workbench::json::Object::decode ( utils::json::decoder::Object encodedObject,
DecodingOptions  options = {} 
) -> void

Reads the object from a JSON object.

Parameters
encodedObjectThe encoded JSON object
optionsDecoding opotions.
Exceptions
std::runtime_errorAn error occurred

◆ decode() [2/4]

template<typename Filter >
requires std::is_invocable_r_v<bool, std::decay_t<Filter>, const utils::json::decoder::Name &, utils::json::decoder::Value &>
auto xentara::workbench::json::Object::decode ( utils::json::decoder::Object encodedObject,
Filter &&  filter,
DecodingOptions  options = {} 
) -> void

Reads the object from a JSON object, applying a filter to the top-level JSON object.

Parameters
encodedObjectThe encoded JSON object
filterA filter object that can be used to filter out object members
optionsAdditional decoding opotions.
Exceptions
std::runtime_errorAn error occurred

◆ decode() [3/4]

auto xentara::workbench::json::Object::decode ( utils::json::decoder::Value encodedValue,
DecodingOptions  options = {} 
) -> void

Reads the object from a JSON value.

Parameters
encodedValueThe encoded JSON value
optionsDecoding opotions.
Exceptions
std::runtime_errorAn error occurred

◆ decode() [4/4]

template<typename Filter >
requires std::is_invocable_r_v<bool, std::decay_t<Filter>, const utils::json::decoder::Name &, utils::json::decoder::Value &>
auto xentara::workbench::json::Object::decode ( utils::json::decoder::Value encodedValue,
Filter &&  filter,
DecodingOptions  options = {} 
) -> void

Reads the object from a JSON value, applying a filter to the top-level JSON object.

Parameters
encodedValueThe encoded JSON value
filterA filter object that can be used to filter out object members
optionsAdditional decoding opotions.
Exceptions
std::runtime_errorAn error occurred

◆ empty()

constexpr auto xentara::workbench::json::Object::empty ( ) const -> bool
constexprnoexcept

Checks if the object is empty.

Returns
Returns true if the object is empty, *false if it has any members.

◆ encode() [1/2]

auto xentara::workbench::json::Object::encode ( utils::json::encoder::Object encodedObject) const -> void

Write the object to a JSON object.

Parameters
encodedObjectThe JSON object to encode to
Exceptions
std::runtime_errorAn error occurred

◆ encode() [2/2]

auto xentara::workbench::json::Object::encode ( utils::json::encoder::Value encodedValue) const -> void

Write the object to a generic JSON value.

Parameters
encodedValueThe JSON value to encode to
Exceptions
std::runtime_errorAn error occurred

◆ fromString() [1/2]

static auto xentara::workbench::json::Object::fromString ( std::string_view  string,
DecodingOptions  options = {} 
) -> utils::eh::expected< Object, ui::String >
static

Creates a JSON object from a string.

Parameters
stringThe string to decode
optionsDecoding opotions.
Returns
The object, or an error message on error.

◆ fromString() [2/2]

template<typename Filter >
requires std::is_invocable_r_v<bool, std::decay_t<Filter>, const utils::json::decoder::Name &, utils::json::decoder::Value &>
static auto xentara::workbench::json::Object::fromString ( std::string_view  string,
Filter &&  filter,
DecodingOptions  options = {} 
) -> utils::eh::expected<Object, ui::String>
static

Creates a JSON object from a string, applying a filter to the top-level JSON object.

Parameters
stringThe string to decode
filterA filter object that can be used to filter out object members
optionsAdditional decoding opotions.
Returns
The object, or an error message on error.
See also
utils::json::decoder::Object::filter()

◆ operator=() [1/2]

auto xentara::workbench::json::Object::operator= ( const Object ) -> Object &
default

Copy-assignment operator.

◆ operator=() [2/2]

auto xentara::workbench::json::Object::operator= ( Object &&  ) -> Object &
defaultnoexcept

Move-assignment operator.

◆ operator==()

auto xentara::workbench::json::Object::operator== ( const Object ) const -> bool
default

Equality comparison operator.

◆ toString()

auto xentara::workbench::json::Object::toString ( utils::json::encoder::Document::Format  format = utils::json::encoder::Document::Format::Regular) const -> std::string

Converts the JSON object to a string.

Parameters
formatThe format to use for the document
Returns
The JSON text.

Member Data Documentation

◆ kXentaraElementFilter

constexpr XentaraElementFilter xentara::workbench::json::Object::kXentaraElementFilter
staticconstexpr

A decoding filter that throws an exception if a member name is reserved in the configuration of Xentara elements.