StormByte-Config 3.0.0
C++26 configuration-document module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Config::Item::Value Class Reference

Scalar configuration item. More...

#include <StormByte/config/item/value.hxx>

Inheritance diagram for StormByte::Config::Item::Value:
Collaboration diagram for StormByte::Config::Item::Value:

Public Member Functions

 Value (int value)
 Integer payload.
 Value (double value)
 Double payload.
 Value (bool value)
 Bool payload.
 Value (const char *value)
 Text payload from a C string.
 Value (std::string_view value)
 Text payload from a view.
 Value (StormByte::Safe::String &&value)
 Text payload.
 Value (const StormByte::Safe::Binary &value)
 Byte payload.
 Value (StormByte::Safe::Binary &&value)
 Byte payload.
 Value (std::string_view name, int value)
 Named integer.
 Value (std::string_view name, double value)
 Named double.
 Value (std::string_view name, bool value)
 Named bool.
 Value (std::string_view name, const char *value)
 Named text from a C string.
 Value (std::string_view name, std::string_view value)
 Named text.
 Value (std::string_view name, const StormByte::Safe::Binary &value)
 Named bytes.
 Value (std::string_view name, StormByte::Safe::Binary &&value)
 Named bytes.
 Value (const Value &value)
 Copy constructor.
 Value (Value &&value) noexcept
 Move constructor.
 ~Value () noexcept override
 Destructor.
Value & operator= (const Value &value)
 Copy assignment.
Value & operator= (Value &&value) noexcept
 Move assignment.
Item::Type Kind () const noexcept
 Payload kind.
Item::Type Type () const noexcept override
 Item type.
Value & operator= (int value)
 Assign an integer.
Value & operator= (double value)
 Assign a double.
Value & operator= (bool value)
 Assign a bool.
Value & operator= (const char *value)
 Assign text from a C string.
Value & operator= (std::string_view value)
 Assign text.
Value & operator= (const StormByte::Safe::Binary &value)
 Assign bytes.
 operator int & ()
 Integer reference.
 operator const int & () const
 Integer reference.
 operator double () const
 Double value.
 operator double & ()
 Double reference.
 operator bool & ()
 Bool reference.
 operator const bool & () const
 Bool reference.
 operator StormByte::Safe::String & ()
 Text reference.
 operator const StormByte::Safe::String & () const
 Text reference.
 operator StormByte::Safe::Binary & ()
 Byte reference.
 operator const StormByte::Safe::Binary & () const
 Byte reference.
PointerType Clone () const override
 Clone onto the Config heap.
PointerType Move () override
 Move onto the Config heap.
StormByte::Safe::String Serialize (const int &indent_level) const override
 Text form of this item.
Public Member Functions inherited from StormByte::Config::Item::Base
 Base () noexcept
 Constructor.
 Base (const StormByte::Safe::String &name)
 Constructor.
 Base (const Base &base) noexcept
 Copy constructor.
 Base (Base &&base) noexcept
 Move constructor.
Base & operator= (const Base &base) noexcept
 Assignment operator.
Base & operator= (Base &&base) noexcept
 Move assignment operator.
 ~Base () noexcept override
 Destructor.
bool operator== (const Base &base) const noexcept
 Compares two items.
bool operator!= (const Base &base) const noexcept
 Compares two items.
constexpr const StormByte::Safe::String & Name () const noexcept
 Gets the name of the item.
void Name (std::string_view name)
 Sets the name of the item.
constexpr std::string_view TypeToString () const noexcept
 Gets the type as string.
template<class T>
decltype(auto) As ()
 Typed view of this item.
template<class T>
decltype(auto) As () const
 Typed view of this item.
Public Member Functions inherited from StormByte::Safe::Clonable< Base, StormByte::Safe::Shared< Base > >
constexpr Clonable ()=default
constexpr Clonable & operator= (const Clonable &)=default
virtual constexpr ~Clonable () noexcept=default

Protected Member Functions

bool Equals (const Base &base) const override
 Compare payloads after the base has matched the type.

Additional Inherited Members

Public Types inherited from StormByte::Safe::Clonable< Base, StormByte::Safe::Shared< Base > >
typedef SmartPointer PointerType
Static Public Member Functions inherited from StormByte::Config::Item::Base
static bool IsNameValid (std::string_view name) noexcept
 Checks if name is valid.
Static Public Member Functions inherited from StormByte::Safe::Clonable< Base, StormByte::Safe::Shared< Base > >
static PointerType MakePointer (Args &&... args)
Protected Attributes inherited from StormByte::Config::Item::Base
StormByte::Safe::String m_name
 Name of the item.

Detailed Description

Scalar configuration item.

The payload is a StormByte::Safe::Variant. Integer, double, bool, text and bytes do not share storage by hand. A text literal binds to const char*. That overload is exact and beats the bool conversion of a pointer. std::string and Safe::String bind to string_view.

Constructor & Destructor Documentation

◆ Value() [1/17]

StormByte::Config::Item::Value::Value ( int value)
explicit

Integer payload.

Parameters
valueInteger.

◆ Value() [2/17]

StormByte::Config::Item::Value::Value ( double value)
explicit

Double payload.

Parameters
valueDouble.

◆ Value() [3/17]

StormByte::Config::Item::Value::Value ( bool value)
explicit

Bool payload.

Parameters
valueBool.

◆ Value() [4/17]

StormByte::Config::Item::Value::Value ( const char * value)
explicit

Text payload from a C string.

Parameters
valueSource. A null pointer is empty text.

◆ Value() [5/17]

StormByte::Config::Item::Value::Value ( std::string_view value)
explicit

Text payload from a view.

Parameters
valueSource. A std::string or Safe::String binds here. Embedded NUL counts.

◆ Value() [6/17]

StormByte::Config::Item::Value::Value ( StormByte::Safe::String && value)
explicit

Text payload.

Parameters
valueOwned text. Left empty.

◆ Value() [7/17]

StormByte::Config::Item::Value::Value ( const StormByte::Safe::Binary & value)
explicit

Byte payload.

Parameters
valueOwned bytes.

◆ Value() [8/17]

StormByte::Config::Item::Value::Value ( StormByte::Safe::Binary && value)
explicit

Byte payload.

Parameters
valueOwned bytes. Left empty.

◆ Value() [9/17]

StormByte::Config::Item::Value::Value ( std::string_view name,
int value )

Named integer.

Parameters
nameItem name.
valueInteger.

◆ Value() [10/17]

StormByte::Config::Item::Value::Value ( std::string_view name,
double value )

Named double.

Parameters
nameItem name.
valueDouble.

◆ Value() [11/17]

StormByte::Config::Item::Value::Value ( std::string_view name,
bool value )

Named bool.

Parameters
nameItem name.
valueBool.

◆ Value() [12/17]

StormByte::Config::Item::Value::Value ( std::string_view name,
const char * value )

Named text from a C string.

Parameters
nameItem name.
valueC string. A null pointer is empty text.

◆ Value() [13/17]

StormByte::Config::Item::Value::Value ( std::string_view name,
std::string_view value )

Named text.

Parameters
nameItem name.
valueText. A std::string or Safe::String binds here. Embedded NUL counts.

◆ Value() [14/17]

StormByte::Config::Item::Value::Value ( std::string_view name,
const StormByte::Safe::Binary & value )

Named bytes.

Parameters
nameItem name.
valueOwned bytes.

◆ Value() [15/17]

StormByte::Config::Item::Value::Value ( std::string_view name,
StormByte::Safe::Binary && value )

Named bytes.

Parameters
nameItem name.
valueOwned bytes. Left empty.

◆ Value() [16/17]

StormByte::Config::Item::Value::Value ( const Value & value)

Copy constructor.

Parameters
valueSource.

◆ Value() [17/17]

StormByte::Config::Item::Value::Value ( Value && value)
noexcept

Move constructor.

Parameters
valueSource. Left as an integer zero.

◆ ~Value()

StormByte::Config::Item::Value::~Value ( )
overridenoexcept

Destructor.

Member Function Documentation

◆ Clone()

PointerType StormByte::Config::Item::Value::Clone ( ) const
overridevirtual

Clone onto the Config heap.

Returns
Shared copy.

Implements StormByte::Safe::Clonable< Base, StormByte::Safe::Shared< Base > >.

◆ Equals()

bool StormByte::Config::Item::Value::Equals ( const Base & base) const
overrideprotectedvirtual

Compare payloads after the base has matched the type.

Parameters
baseOther item, already a Value.
Returns
Whether the payloads are equal.

Implements StormByte::Config::Item::Base.

◆ Kind()

Item::Type StormByte::Config::Item::Value::Kind ( ) const
noexcept

Payload kind.

Returns
Active alternative as an item type.

◆ Move()

PointerType StormByte::Config::Item::Value::Move ( )
overridevirtual

Move onto the Config heap.

Returns
Shared value. This item is left as an integer zero.

Implements StormByte::Safe::Clonable< Base, StormByte::Safe::Shared< Base > >.

◆ operator bool &()

StormByte::Config::Item::Value::operator bool & ( )

Bool reference.

Returns
Active bool.
Exceptions
ExceptionThe payload is not a bool.

◆ operator const bool &()

StormByte::Config::Item::Value::operator const bool & ( ) const

Bool reference.

Returns
Active bool.
Exceptions
ExceptionThe payload is not a bool.

◆ operator const int &()

StormByte::Config::Item::Value::operator const int & ( ) const

Integer reference.

Returns
Active integer.
Exceptions
ExceptionThe payload is not an integer.

◆ operator const StormByte::Safe::Binary &()

StormByte::Config::Item::Value::operator const StormByte::Safe::Binary & ( ) const

Byte reference.

Returns
Active bytes.
Exceptions
ExceptionThe payload is not bytes.

◆ operator const StormByte::Safe::String &()

StormByte::Config::Item::Value::operator const StormByte::Safe::String & ( ) const

Text reference.

Returns
Active text.
Exceptions
ExceptionThe payload is not text.

◆ operator double()

StormByte::Config::Item::Value::operator double ( ) const

Double value.

An integer promotes.

Returns
Active double, or the integer widened.
Exceptions
ExceptionThe payload is neither double nor integer.

◆ operator double &()

StormByte::Config::Item::Value::operator double & ( )

Double reference.

An integer does not promote.

Returns
Active double.
Exceptions
ExceptionThe payload is not a double.

◆ operator int &()

StormByte::Config::Item::Value::operator int & ( )

Integer reference.

Returns
Active integer.
Exceptions
ExceptionThe payload is not an integer.

◆ operator StormByte::Safe::Binary &()

StormByte::Config::Item::Value::operator StormByte::Safe::Binary & ( )

Byte reference.

Returns
Active bytes.
Exceptions
ExceptionThe payload is not bytes.

◆ operator StormByte::Safe::String &()

StormByte::Config::Item::Value::operator StormByte::Safe::String & ( )

Text reference.

Returns
Active text.
Exceptions
ExceptionThe payload is not text.

◆ operator=() [1/8]

Value & StormByte::Config::Item::Value::operator= ( bool value)

Assign a bool.

The kind must already be bool.

Parameters
valueBool.
Returns
This item.
Exceptions
ExceptionThe payload is not a bool.

◆ operator=() [2/8]

Value & StormByte::Config::Item::Value::operator= ( const char * value)

Assign text from a C string.

The kind must already be text.

Parameters
valueC string. A null pointer is empty text.
Returns
This item.
Exceptions
ExceptionThe payload is not text.

◆ operator=() [3/8]

Value & StormByte::Config::Item::Value::operator= ( const StormByte::Safe::Binary & value)

Assign bytes.

The kind must already be bytes.

Parameters
valueOwned bytes.
Returns
This item.
Exceptions
ExceptionThe payload is not bytes.

◆ operator=() [4/8]

Value & StormByte::Config::Item::Value::operator= ( const Value & value)

Copy assignment.

Parameters
valueSource.
Returns
This item.

◆ operator=() [5/8]

Value & StormByte::Config::Item::Value::operator= ( double value)

Assign a double.

The kind must already be double.

Parameters
valueDouble.
Returns
This item.
Exceptions
ExceptionThe payload is not a double.

◆ operator=() [6/8]

Value & StormByte::Config::Item::Value::operator= ( int value)

Assign an integer.

The kind must already be integer.

Parameters
valueInteger.
Returns
This item.
Exceptions
ExceptionThe payload is not an integer.

◆ operator=() [7/8]

Value & StormByte::Config::Item::Value::operator= ( std::string_view value)

Assign text.

The kind must already be text.

Parameters
valueText. A std::string or Safe::String binds here.
Returns
This item.
Exceptions
ExceptionThe payload is not text.

◆ operator=() [8/8]

Value & StormByte::Config::Item::Value::operator= ( Value && value)
noexcept

Move assignment.

Parameters
valueSource. Left as an integer zero.
Returns
This item.

◆ Serialize()

StormByte::Safe::String StormByte::Config::Item::Value::Serialize ( const int & indent_level) const
overridevirtual

Text form of this item.

Parameters
indent_levelTab count before the line.
Returns
One line, without a trailing newline.

Reimplemented from StormByte::Config::Item::Base.

◆ Type()

Item::Type StormByte::Config::Item::Value::Type ( ) const
overridevirtualnoexcept

Item type.

Returns
Same as Kind.

Implements StormByte::Config::Item::Base.


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