xentara-plugin v2.0.3
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::config::Context::ReferenceKey Class Referencefinal

A key used to resolve a cross reference in the configuration. More...

#include <xentara/config/Context.hpp>

Public Member Functions

 ReferenceKey (utils::json::decoder::Value &value)
 Constructor for a key contained in a JSON value.
 
 ReferenceKey (const utils::json::decoder::Name &name)
 Constructor for a key contained in the name of a JSON object member.
 
template<std::convertible_to< std::string_view > Key>
 ReferenceKey (const Key &key, const utils::json::decoder::Location &location)
 Constructor for an arbitrary key.
 
 ReferenceKey (std::string &&key, const utils::json::decoder::Location &location)
 Constructor for an arbitrary key.
 
 ReferenceKey (std::string_view key, WithoutLocationTag tag)
 Constructor for an arbitrary key not associated with any location in a JSON document.
 

Related Symbols

(Note that these are not member symbols.)

constexpr WithoutLocationTag kWithoutLocation
 A marker to specify that a resolver key is not associated with a location in any JSON document.
 

Detailed Description

A key used to resolve a cross reference in the configuration.

Constructor & Destructor Documentation

◆ ReferenceKey() [1/5]

xentara::config::Context::ReferenceKey::ReferenceKey ( utils::json::decoder::Value value)

Constructor for a key contained in a JSON value.

This constructor is used to resolve a reference using a key contained in a JSON value. The key is read from the value using Value::asString().

Parameters
valueThe JSON value containing the primary key of the object to resolve
Exceptions
utils::json::decoder::TypeMismatchErrorkey is not a string value
std::runtime_errorAn error occurred reading the key from the JSON document

◆ ReferenceKey() [2/5]

xentara::config::Context::ReferenceKey::ReferenceKey ( const utils::json::decoder::Name name)

Constructor for a key contained in the name of a JSON object member.

This constructor is used to resolve a reference using a key contained in a JSON value. The key is read from the value using Value::asString().

Parameters
nameThe JSON object member name containing the primary key of the object to resolve
Exceptions
utils::json::decoder::TypeMismatchErrorkey is not a string value
std::runtime_errorAn error occurred reading the key from the JSON document

◆ ReferenceKey() [3/5]

template<std::convertible_to< std::string_view > Key>
xentara::config::Context::ReferenceKey::ReferenceKey ( const Key key,
const utils::json::decoder::Location location 
)

Constructor for an arbitrary key.

This constructor is used to resolve a reference using an arbitrary key.

Parameters
keyThe primary key of the object to resolve, in UTF-8 encoding
locationThe location within the JSON document that the key is associated with. This is used to output the line number in error messages. The location can be a location of a value the key is derived from, or any location that helps the user find the error in the JSON document in case the reference cannot be resolved.
Exceptions
utils::json::decoder::TypeMismatchErrorkey is not a string value
std::runtime_errorAn error occurred reading the key from the JSON document

◆ ReferenceKey() [4/5]

xentara::config::Context::ReferenceKey::ReferenceKey ( std::string &&  key,
const utils::json::decoder::Location location 
)

Constructor for an arbitrary key.

This constructor is used to resolve a reference using an arbitrary key.

Parameters
keyThe primary key of the object to resolve, in UTF-8 encoding
locationThe location within the JSON document that the key is associated with. This is used to output the line number in error messages. The location can be a location of a value the key is derived from, or any location that helps the user find the error in the JSON document in case the reference cannot be resolved.
Exceptions
utils::json::decoder::TypeMismatchErrorkey is not a string value
std::runtime_errorAn error occurred reading the key from the JSON document

◆ ReferenceKey() [5/5]

xentara::config::Context::ReferenceKey::ReferenceKey ( std::string_view  key,
WithoutLocationTag  tag 
)

Constructor for an arbitrary key not associated with any location in a JSON document.

This constructor is used to resolve a reference using an arbitrary key that is not related to any JSON document.

Attention
Using a key constructed using this constructor makes it difficult for the user to fix any errors that may occur resolving the reference, as the error message will not contain any file name or line number. This constructor should only be used
Parameters
keyThe primary key of the object to resolve, in UTF-8 encoding
tagAlways pass kWithoutLocation as this parameter
Exceptions
utils::json::decoder::TypeMismatchErrorkey is not a string value
std::runtime_errorAn error occurred reading the key from the JSON document

Friends And Related Symbol Documentation

◆ kWithoutLocation

constexpr WithoutLocationTag kWithoutLocation
related

A marker to specify that a resolver key is not associated with a location in any JSON document.

This marker is used instead of a location object to specify that a resolver key is not associated with any JSON document location.