StormByte C++ Library: Config module 1.1.0
StormByte-Config is the configuration module of the StormByte C++ suite.
Loading...
Searching...
No Matches
Protected Attributes | List of all members
StormByte::Config::Item::Value< T > Class Template Reference

Named or unnamed typed value. More...

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

Inheritance diagram for StormByte::Config::Item::Value< T >:
Inheritance graph
[legend]
Collaboration diagram for StormByte::Config::Item::Value< T >:
Collaboration graph
[legend]

Public Member Functions

Construction
 Value (const T &value)
 Constructs a Value with the given value.
 
template<typename U = T>
requires StormByte::Type::SameAs<U, std::string>
 Value (const char *value)
 Constructs a string Value from a C string.
 
template<typename U = T>
requires StormByte::Type::SameAs<U, std::string>
 Value (const char *name, const char *value)
 Constructs a named string Value from C strings.
 
 Value (T &&value)
 Move constructor from value.
 
 Value (const std::string &name, const T &value)
 Constructs a named Value.
 
 Value (std::string &&name, T &&value)
 Constructs a named Value (move).
 
 Value (const std::string &name, const char *value)
 Named string constructor from C string value.
 
 Value (std::string &&name, const char *value)
 Named string constructor (move name) from C string value.
 
 Value (const Value &single)=default
 Copy constructor.
 
 Value (Value &&single) noexcept=default
 Move constructor.
 
Value & operator= (const Value &single)=default
 Copy assignment operator.
 
Value & operator= (Value &&single) noexcept=default
 Move assignment operator.
 
virtual ~Value () noexcept override=default
 Destructor.
 
Access
bool Equals (const Base &other) const noexcept override
 Polymorphic equality comparison.
 
virtual constexpr Item::Type Type () const noexcept override
 Gets the type of the item.
 
bool operator== (const Value< T > &single) const noexcept
 Checks if two Value objects are equal.
 
bool operator!= (const Value< T > &single) const noexcept
 Inequality operator.
 
T & operator* () noexcept
 Gets the item value (mutable).
 
const T & operator* () const noexcept
 Gets the item value (const).
 
std::string Serialize (const int &indent_level) const noexcept override
 Serializes the item to a string.
 
virtual PointerType Clone () const override
 Clones the item.
 
virtual PointerType Move () override
 Moves the item.
 
- Public Member Functions inherited from StormByte::Config::Item::Base
 Base ()=default
 Default constructor.
 
 Base (const std::string &name)
 Constructs a Base item with a name.
 
 Base (const Base &base)=default
 Copy constructor.
 
 Base (Base &&base) noexcept=default
 Move constructor.
 
Base & operator= (const Base &base)=default
 Copy assignment operator.
 
Base & operator= (Base &&base) noexcept=default
 Move assignment operator.
 
virtual ~Base () noexcept=default
 Destructor.
 
bool operator== (const Base &other) const noexcept
 Equality operator.
 
bool operator!= (const Base &other) const noexcept
 Inequality operator.
 
constexpr const std::optional< std::string > & Name () const noexcept
 Gets the name of the item.
 
constexpr void Name (const std::string &name) noexcept
 Sets the item name.
 
bool IsNameValid () const noexcept
 Checks if the current name is valid.
 
virtual std::optional< CommentType > GetCommentType () const noexcept
 Returns the comment type if this item is a Comment, otherwise std::nullopt.
 
constexpr std::string TypeToString () const noexcept
 Gets the item type as a string.
 
 operator std::string () const
 Converts the item to a string.
 
template<typename T >
const T & Value () const
 Gets the item value (const).
 
template<typename T >
T & Value ()
 Gets the item value (mutable).
 

Protected Attributes

T m_value
 The value of the item.
 
- Protected Attributes inherited from StormByte::Config::Item::Base
std::optional< std::string > m_name
 Item name.
 

Detailed Description

template<AllowedValueType T>
class StormByte::Config::Item::Value< T >

Named or unnamed typed value.

Template Parameters
Tstd::string, int, double, bool or std::vector<std::byte>.

Constructor & Destructor Documentation

◆ Value() [1/10]

template<AllowedValueType T>
StormByte::Config::Item::Value< T >::Value ( const T &  value)
inline

Constructs a Value with the given value.

Parameters
valueThe value of the item.

◆ Value() [2/10]

template<AllowedValueType T>
template<typename U = T>
requires StormByte::Type::SameAs<U, std::string>
StormByte::Config::Item::Value< T >::Value ( const char *  value)
inline

Constructs a string Value from a C string.

Parameters
valueSource C string.

◆ Value() [3/10]

template<AllowedValueType T>
template<typename U = T>
requires StormByte::Type::SameAs<U, std::string>
StormByte::Config::Item::Value< T >::Value ( const char *  name,
const char *  value 
)
inline

Constructs a named string Value from C strings.

Parameters
nameItem name.
valueSource C string.

◆ Value() [4/10]

template<AllowedValueType T>
StormByte::Config::Item::Value< T >::Value ( T &&  value)
inline

Move constructor from value.

Parameters
valueItem value.

◆ Value() [5/10]

template<AllowedValueType T>
StormByte::Config::Item::Value< T >::Value ( const std::string &  name,
const T &  value 
)
inline

Constructs a named Value.

Parameters
nameItem name.
valueItem value.

◆ Value() [6/10]

template<AllowedValueType T>
StormByte::Config::Item::Value< T >::Value ( std::string &&  name,
T &&  value 
)
inline

Constructs a named Value (move).

Parameters
nameItem name.
valueItem value.

◆ Value() [7/10]

template<AllowedValueType T>
StormByte::Config::Item::Value< T >::Value ( const std::string &  name,
const char *  value 
)
inline

Named string constructor from C string value.

Parameters
nameItem name.
valueC string value.

◆ Value() [8/10]

template<AllowedValueType T>
StormByte::Config::Item::Value< T >::Value ( std::string &&  name,
const char *  value 
)
inline

Named string constructor (move name) from C string value.

Parameters
nameItem name.
valueC string value.

◆ Value() [9/10]

template<AllowedValueType T>
StormByte::Config::Item::Value< T >::Value ( const Value< T > &  single)
default

Copy constructor.

Parameters
singleItem to copy.

◆ Value() [10/10]

template<AllowedValueType T>
StormByte::Config::Item::Value< T >::Value ( Value< T > &&  single)
defaultnoexcept

Move constructor.

Parameters
singleItem to move.

◆ ~Value()

template<AllowedValueType T>
virtual StormByte::Config::Item::Value< T >::~Value ( )
overridevirtualdefaultnoexcept

Destructor.

Member Function Documentation

◆ Clone()

template<AllowedValueType T>
virtual PointerType StormByte::Config::Item::Value< T >::Clone ( ) const
inlineoverridevirtual

Clones the item.

Returns
Cloned item.

Reimplemented in StormByte::Config::Item::Comment< T >.

◆ Equals()

template<AllowedValueType T>
bool StormByte::Config::Item::Value< T >::Equals ( const Base &  other) const
inlineoverridevirtualnoexcept

Polymorphic equality comparison.

Parameters
otherThe other item to compare against.
Returns
true if both items are of the same type and hold the same value.

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

◆ Move()

template<AllowedValueType T>
virtual PointerType StormByte::Config::Item::Value< T >::Move ( )
inlineoverridevirtual

Moves the item.

Returns
Moved item.

Reimplemented in StormByte::Config::Item::Comment< T >.

◆ operator!=()

template<AllowedValueType T>
bool StormByte::Config::Item::Value< T >::operator!= ( const Value< T > &  single) const
inlinenoexcept

Inequality operator.

Parameters
singleItem to compare.
Returns
true if not equal.

◆ operator*() [1/2]

template<AllowedValueType T>
const T & StormByte::Config::Item::Value< T >::operator* ( ) const
inlinenoexcept

Gets the item value (const).

Returns
Item value.

◆ operator*() [2/2]

template<AllowedValueType T>
T & StormByte::Config::Item::Value< T >::operator* ( )
inlinenoexcept

Gets the item value (mutable).

Returns
Item value.

◆ operator=() [1/2]

template<AllowedValueType T>
Value & StormByte::Config::Item::Value< T >::operator= ( const Value< T > &  single)
default

Copy assignment operator.

Parameters
singleItem to copy.
Returns
Reference to this Value.

◆ operator=() [2/2]

template<AllowedValueType T>
Value & StormByte::Config::Item::Value< T >::operator= ( Value< T > &&  single)
defaultnoexcept

Move assignment operator.

Parameters
singleItem to move.
Returns
Reference to this Value.

◆ operator==()

template<AllowedValueType T>
bool StormByte::Config::Item::Value< T >::operator== ( const Value< T > &  single) const
inlinenoexcept

Checks if two Value objects are equal.

Parameters
singleThe Value object to compare.
Returns
true if equal.

◆ Serialize()

template<AllowedValueType T>
std::string StormByte::Config::Item::Value< T >::Serialize ( const int &  indent_level) const
overridevirtualnoexcept

Serializes the item to a string.

Parameters
indent_levelThe indentation level for serialization.
Returns
The serialized string.

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

◆ Type()

template<AllowedValueType T>
virtual constexpr Item::Type StormByte::Config::Item::Value< T >::Type ( ) const
inlineconstexproverridevirtualnoexcept

Gets the type of the item.

Returns
Item::Type The type of the item.

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

Reimplemented in StormByte::Config::Item::Comment< T >.

Member Data Documentation

◆ m_value

template<AllowedValueType T>
T StormByte::Config::Item::Value< T >::m_value
protected

The value of the item.


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