ECSTASY
All in the name
Loading...
Searching...
No Matches
util::serialization::INode Class Referenceabstract

Serialization node. More...

#include <INode.hpp>

Inheritance diagram for util::serialization::INode:

Public Types

enum class  Type {
  Unknown = -1 , Null , Object , Array ,
  String , Integer , Float , Boolean ,
  Date , Time , DateTime , Count
}
 Available node types. More...
 
using Date = std::chrono::year_month_day
 Type::Date underlying type.
 
using Time = std::chrono::nanoseconds
 Type::Time underlying type.
 
using DateTime = std::chrono::high_resolution_clock::time_point
 Type::DateTime underlying type.
 

Public Member Functions

virtual ~INode ()=default
 Default destructor.
 
virtual Type getType () const noexcept=0
 Types check ///.
 
virtual bool isType (Type type) const noexcept=0
 Check if the node type is type.
 
virtual bool isNull () const noexcept=0
 Check if the node type is Type::Null.
 
virtual bool isObject () const noexcept=0
 Check if the node type is Type::Object.
 
virtual bool isArray () const noexcept=0
 Check if the node type is Type::Array.
 
virtual bool isString () const noexcept=0
 Check if the node type is Type::String.
 
virtual bool isInteger () const noexcept=0
 Check if the node type is Type::Integer.
 
virtual bool isFloat () const noexcept=0
 Check if the node type is Type::Float.
 
virtual bool isBoolean () const noexcept=0
 Check if the node type is Type::Boolean.
 
virtual bool isDate () const noexcept=0
 Check if the node type is Type::Date.
 
virtual bool isTime () const noexcept=0
 Check if the node type is Type::Time.
 
virtual bool isDateTime () const noexcept=0
 Check if the node type is Type::DateTime.
 
virtual const IObjectNodeasObject () const =0
 Value getter ///.
 
virtual IObjectNodeasObject ()=0
 Get the object node value.
 
virtual std::optional< std::reference_wrapper< const IObjectNode > > tryAsObject () const noexcept=0
 Try to get the node object value.
 
virtual std::optional< std::reference_wrapper< IObjectNode > > tryAsObject () noexcept=0
 Try to get the node object value.
 
virtual const IArrayNodeasArray () const =0
 Get the array node value.
 
virtual IArrayNodeasArray ()=0
 Get the array node value.
 
virtual std::optional< std::reference_wrapper< const IArrayNode > > tryAsArray () const noexcept=0
 Try to get the node array value.
 
virtual std::optional< std::reference_wrapper< IArrayNode > > tryAsArray () noexcept=0
 Try to get the node array value.
 
virtual std::string_view asString () const =0
 Get the string node value.
 
virtual std::optional< std::string_viewtryAsString () const noexcept=0
 Try to get the node string value.
 
virtual int64_t asInteger () const =0
 Get the integer node value.
 
virtual std::optional< int64_t > tryAsInteger () const noexcept=0
 Try to get the node integer value.
 
virtual double asFloat () const =0
 Get the float node value.
 
virtual std::optional< double > tryAsFloat () const noexcept=0
 Try to get the node float value.
 
virtual bool asBoolean () const =0
 Get the boolean node value.
 
virtual std::optional< bool > tryAsBoolean () const noexcept=0
 Try to get the node boolean value.
 
virtual Date asDate () const =0
 Get the date node value.
 
virtual std::optional< DatetryAsDate () const noexcept=0
 Try to get the node date value.
 
virtual Time asTime () const =0
 Get the time node value.
 
virtual std::optional< TimetryAsTime () const noexcept=0
 Try to get the node time value.
 
virtual DateTime asDateTime () const =0
 Get the datetime node value.
 
virtual std::optional< DateTimetryAsDateTime () const noexcept=0
 Try to get the node datetime value.
 

Detailed Description

Serialization node.

Can be any type of INode::Type.

Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Definition at line 32 of file INode.hpp.

Member Typedef Documentation

◆ Date

Type::Date underlying type.

Definition at line 58 of file INode.hpp.

◆ DateTime

using util::serialization::INode::DateTime = std::chrono::high_resolution_clock::time_point

Type::DateTime underlying type.

Definition at line 64 of file INode.hpp.

◆ Time

Type::Time underlying type.

Definition at line 61 of file INode.hpp.

Member Enumeration Documentation

◆ Type

Available node types.

Warning
Some types may not be available depending on the underlying format.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)
Enumerator
Unknown 

Unknown type.

Null 

Null node (none/null).

Object 

Node containing multiple named nodes. (similar to a std::map<string, INode>)

Array 

Node containing multiple unnamed nodes. (similar to a std::vector<string>)

String 

String node.

Integer 

Integer number node.

Float 

Floating point number node.

Boolean 

Boolean value node.

Date 

Date node.

Time 

Time node.

DateTime 

DateTime node. (Timestamp)

Count 

Keep last - number of available node types.

Definition at line 42 of file INode.hpp.

42 {
43 Unknown = -1,
44 Null,
45 Object,
46 Array,
47 String,
48 Integer,
49 Float,
50 Boolean,
51 Date,
52 Time,
53 DateTime,
54 Count
55 };
std::chrono::year_month_day Date
Type::Date underlying type.
Definition INode.hpp:58
std::chrono::nanoseconds Time
Type::Time underlying type.
Definition INode.hpp:61
std::chrono::high_resolution_clock::time_point DateTime
Type::DateTime underlying type.
Definition INode.hpp:64
@ Float
Floating point number node.
@ Boolean
Boolean value node.
@ Array
Node containing multiple unnamed nodes. (similar to a std::vector<string>)
@ Object
Node containing multiple named nodes. (similar to a std::map<string, INode>)
@ Integer
Integer number node.
@ Null
Null node (none/null).
@ Count
Keep last - number of available node types.

Constructor & Destructor Documentation

◆ ~INode()

virtual util::serialization::INode::~INode ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ asArray() [1/2]

virtual const IArrayNode & util::serialization::INode::asArray ( ) const
pure virtual

Get the array node value.

Returns
const IArrayNode& node value.
Exceptions
std::runtime_errorIf the node is the node type is not Type::Array.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ asArray() [2/2]

virtual IArrayNode & util::serialization::INode::asArray ( )
pure virtual

Get the array node value.

Returns
IArrayNode& node value.
Exceptions
std::runtime_errorIf the node is the node type is not Type::Array.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ asBoolean()

virtual bool util::serialization::INode::asBoolean ( ) const
pure virtual

Get the boolean node value.

Returns
bool node value.
Exceptions
std::bad_optional_castIf the node is the node type is not Type::Boolean.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ asDate()

virtual Date util::serialization::INode::asDate ( ) const
pure virtual

Get the date node value.

Returns
Date node value.
Exceptions
std::bad_optional_castIf the node is the node type is not Type::Date.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ asDateTime()

virtual DateTime util::serialization::INode::asDateTime ( ) const
pure virtual

Get the datetime node value.

Returns
DateTime node value.
Exceptions
std::bad_optional_castIf the node is the node type is not Type::DateTime.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ asFloat()

virtual double util::serialization::INode::asFloat ( ) const
pure virtual

Get the float node value.

Returns
double node value.
Exceptions
std::bad_optional_castIf the node is the node type is not Type::Float.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ asInteger()

virtual int64_t util::serialization::INode::asInteger ( ) const
pure virtual

Get the integer node value.

Returns
int node value.
Exceptions
std::bad_optional_castIf the node is the node type is not Type::Integer.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ asObject() [1/2]

virtual const IObjectNode & util::serialization::INode::asObject ( ) const
pure virtual

Value getter ///.

Get the object node value.

Returns
const IObjectNode& node value.
Exceptions
std::runtime_errorIf the node is the node type is not Type::Object.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ asObject() [2/2]

virtual IObjectNode & util::serialization::INode::asObject ( )
pure virtual

Get the object node value.

Returns
IObjectNode& node value.
Exceptions
std::runtime_errorIf the node is the node type is not Type::Object.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ asString()

virtual std::string_view util::serialization::INode::asString ( ) const
pure virtual

Get the string node value.

Returns
std::string_view node value.
Exceptions
std::bad_optional_castIf the node is the node type is not Type::String.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ asTime()

virtual Time util::serialization::INode::asTime ( ) const
pure virtual

Get the time node value.

Returns
Time node value.
Exceptions
std::bad_optional_castIf the node is the node type is not Type::Time.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ getType()

virtual Type util::serialization::INode::getType ( ) const
pure virtualnoexcept

Types check ///.

Get the node type.

Returns
Type Node type.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::TomlNode< N >, util::serialization::TomlNode< toml::array >, and util::serialization::TomlNode< toml::table >.

◆ isArray()

virtual bool util::serialization::INode::isArray ( ) const
pure virtualnoexcept

Check if the node type is Type::Array.

Returns
bool Whether the node type is Type::Array.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ isBoolean()

virtual bool util::serialization::INode::isBoolean ( ) const
pure virtualnoexcept

Check if the node type is Type::Boolean.

Returns
bool Whether the node type is Type::Boolean.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ isDate()

virtual bool util::serialization::INode::isDate ( ) const
pure virtualnoexcept

Check if the node type is Type::Date.

Returns
bool Whether the node type is Type::Date.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ isDateTime()

virtual bool util::serialization::INode::isDateTime ( ) const
pure virtualnoexcept

Check if the node type is Type::DateTime.

Returns
bool Whether the node type is Type::DateTime.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ isFloat()

virtual bool util::serialization::INode::isFloat ( ) const
pure virtualnoexcept

Check if the node type is Type::Float.

Returns
bool Whether the node type is Type::Float.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ isInteger()

virtual bool util::serialization::INode::isInteger ( ) const
pure virtualnoexcept

Check if the node type is Type::Integer.

Returns
bool Whether the node type is Type::Integer.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ isNull()

virtual bool util::serialization::INode::isNull ( ) const
pure virtualnoexcept

Check if the node type is Type::Null.

Returns
bool Whether the node type is Type::Null.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ isObject()

virtual bool util::serialization::INode::isObject ( ) const
pure virtualnoexcept

Check if the node type is Type::Object.

Returns
bool Whether the node type is Type::Object.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ isString()

virtual bool util::serialization::INode::isString ( ) const
pure virtualnoexcept

Check if the node type is Type::String.

Returns
bool Whether the node type is Type::String.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ isTime()

virtual bool util::serialization::INode::isTime ( ) const
pure virtualnoexcept

Check if the node type is Type::Time.

Returns
bool Whether the node type is Type::Time.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ isType()

virtual bool util::serialization::INode::isType ( Type  type) const
pure virtualnoexcept

Check if the node type is type.

Returns
bool Whether the node type is type.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ tryAsArray() [1/2]

virtual std::optional< std::reference_wrapper< const IArrayNode > > util::serialization::INode::tryAsArray ( ) const
pure virtualnoexcept

Try to get the node array value.

Returns
std::optional<const IArrayNode &> Filled with the node string if the type is Type::Array, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ tryAsArray() [2/2]

virtual std::optional< std::reference_wrapper< IArrayNode > > util::serialization::INode::tryAsArray ( )
pure virtualnoexcept

Try to get the node array value.

Returns
std::optional<IArrayNode &> Filled with the node string if the type is Type::Array, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ tryAsBoolean()

virtual std::optional< bool > util::serialization::INode::tryAsBoolean ( ) const
pure virtualnoexcept

Try to get the node boolean value.

Returns
std::optional<bool> Filled with the node boolean if the type is Type::Boolean, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::TomlNode< N >, util::serialization::TomlNode< toml::array >, and util::serialization::TomlNode< toml::table >.

◆ tryAsDate()

virtual std::optional< Date > util::serialization::INode::tryAsDate ( ) const
pure virtualnoexcept

Try to get the node date value.

Returns
std::optional<Date> Filled with the node date if the type is Type::Date, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::TomlNode< N >, util::serialization::TomlNode< toml::array >, and util::serialization::TomlNode< toml::table >.

◆ tryAsDateTime()

virtual std::optional< DateTime > util::serialization::INode::tryAsDateTime ( ) const
pure virtualnoexcept

Try to get the node datetime value.

Returns
std::optional<DateTime> Filled with the node datetime if the type is Type::DateTime, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::TomlNode< N >, util::serialization::TomlNode< toml::array >, and util::serialization::TomlNode< toml::table >.

◆ tryAsFloat()

virtual std::optional< double > util::serialization::INode::tryAsFloat ( ) const
pure virtualnoexcept

Try to get the node float value.

Returns
std::optional<double> Filled with the node float if the type is Type::Float, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::TomlNode< N >, util::serialization::TomlNode< toml::array >, and util::serialization::TomlNode< toml::table >.

◆ tryAsInteger()

virtual std::optional< int64_t > util::serialization::INode::tryAsInteger ( ) const
pure virtualnoexcept

Try to get the node integer value.

Returns
std::optional<int64_t> Filled with the node integer if the type is Type::Integer, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::TomlNode< N >, util::serialization::TomlNode< toml::array >, and util::serialization::TomlNode< toml::table >.

◆ tryAsObject() [1/2]

virtual std::optional< std::reference_wrapper< const IObjectNode > > util::serialization::INode::tryAsObject ( ) const
pure virtualnoexcept

Try to get the node object value.

Returns
std::optional<const IObjectNode &> Filled with the node string if the type is Type::Object, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ tryAsObject() [2/2]

virtual std::optional< std::reference_wrapper< IObjectNode > > util::serialization::INode::tryAsObject ( )
pure virtualnoexcept

Try to get the node object value.

Returns
std::optional<IObjectNode &> Filled with the node string if the type is Type::Object, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::ANode.

◆ tryAsString()

virtual std::optional< std::string_view > util::serialization::INode::tryAsString ( ) const
pure virtualnoexcept

Try to get the node string value.

Returns
std::optional<std::string_view> Filled with the node string if the type is Type::String, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::TomlNode< N >, util::serialization::TomlNode< toml::array >, and util::serialization::TomlNode< toml::table >.

◆ tryAsTime()

virtual std::optional< Time > util::serialization::INode::tryAsTime ( ) const
pure virtualnoexcept

Try to get the node time value.

Returns
std::optional<Time> Filled with the node time if the type is Type::Time, empty otherwise.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-12-08)

Implemented in util::serialization::TomlNode< N >, util::serialization::TomlNode< toml::array >, and util::serialization::TomlNode< toml::table >.


The documentation for this class was generated from the following file: