StormByte C++ Library: Config module 1.1.0
StormByte-Config is the configuration module of the StormByte C++ suite.
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
StormByte::Config::Item::Base Class Referenceabstract

The base class for all configuration items. More...

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

Inheritance diagram for StormByte::Config::Item::Base:
Inheritance graph
[legend]
Collaboration diagram for StormByte::Config::Item::Base:
Collaboration graph
[legend]

Public Member Functions

 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.
 
Baseoperator= (const Base &base)=default
 Copy assignment operator.
 
Baseoperator= (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.
 
virtual bool Equals (const Base &other) const noexcept=0
 Polymorphic equality comparison.
 
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 constexpr Type Type () const noexcept=0
 Gets the item type.
 
virtual std::optional< CommentTypeGetCommentType () 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.
 
virtual std::string Serialize (const int &indent_level) const noexcept
 Serializes the item.
 
 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

std::optional< std::string > m_name
 Item name.
 

Detailed Description

The base class for all configuration items.

Constructor & Destructor Documentation

◆ Base() [1/4]

StormByte::Config::Item::Base::Base ( )
default

Default constructor.

◆ Base() [2/4]

StormByte::Config::Item::Base::Base ( const std::string &  name)

Constructs a Base item with a name.

Parameters
nameThe name of the item.

◆ Base() [3/4]

StormByte::Config::Item::Base::Base ( const Base base)
default

Copy constructor.

Parameters
baseItem to copy.

◆ Base() [4/4]

StormByte::Config::Item::Base::Base ( Base &&  base)
defaultnoexcept

Move constructor.

Parameters
baseItem to move.

◆ ~Base()

virtual StormByte::Config::Item::Base::~Base ( )
virtualdefaultnoexcept

Destructor.

Member Function Documentation

◆ Equals()

virtual bool StormByte::Config::Item::Base::Equals ( const Base other) const
pure virtualnoexcept

Polymorphic equality comparison.

Parameters
otherThe other item to compare against.
Returns
true if both items are semantically equal.

Implemented in StormByte::Config::Item::Comment< T >, StormByte::Config::Item::Container, StormByte::Config::Item::Value< T >, and StormByte::Config::Item::Value< std::string >.

◆ GetCommentType()

virtual std::optional< CommentType > StormByte::Config::Item::Base::GetCommentType ( ) const
inlinevirtualnoexcept

Returns the comment type if this item is a Comment, otherwise std::nullopt.

Used by the serialization layer to determine the concrete Comment specialization without relying on RTTI / dynamic_cast.

Returns
The CommentType if this is a comment, std::nullopt otherwise.

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

◆ IsNameValid()

bool StormByte::Config::Item::Base::IsNameValid ( ) const
inlinenoexcept

Checks if the current name is valid.

Returns
true if the name is valid.

◆ Name() [1/2]

constexpr const std::optional< std::string > & StormByte::Config::Item::Base::Name ( ) const
inlineconstexprnoexcept

Gets the name of the item.

Returns
The name of the item.

◆ Name() [2/2]

constexpr void StormByte::Config::Item::Base::Name ( const std::string &  name)
inlineconstexprnoexcept

Sets the item name.

Parameters
nameNew name.

◆ operator std::string()

StormByte::Config::Item::Base::operator std::string ( ) const
inline

Converts the item to a string.

Returns
Serialized representation.

◆ operator!=()

bool StormByte::Config::Item::Base::operator!= ( const Base other) const
inlinenoexcept

Inequality operator.

Parameters
otherItem to compare.
Returns
true if items are not equal.

◆ operator=() [1/2]

Base & StormByte::Config::Item::Base::operator= ( Base &&  base)
defaultnoexcept

Move assignment operator.

Parameters
baseItem to move.
Returns
Reference to this Base.

◆ operator=() [2/2]

Base & StormByte::Config::Item::Base::operator= ( const Base base)
default

Copy assignment operator.

Parameters
baseItem to copy.
Returns
Reference to this Base.

◆ operator==()

bool StormByte::Config::Item::Base::operator== ( const Base other) const
inlinenoexcept

Equality operator.

Parameters
otherItem to compare.
Returns
true if both items are equal.

◆ Serialize()

virtual std::string StormByte::Config::Item::Base::Serialize ( const int &  indent_level) const
virtualnoexcept

Serializes the item.

Parameters
indent_levelIndentation level.
Returns
Serialized string.

Reimplemented in StormByte::Config::Item::Comment< T >, StormByte::Config::Item::Container, StormByte::Config::Item::Value< T >, and StormByte::Config::Item::Value< std::string >.

◆ Type()

virtual constexpr Type StormByte::Config::Item::Base::Type ( ) const
constexprpure virtualnoexcept

◆ TypeToString()

constexpr std::string StormByte::Config::Item::Base::TypeToString ( ) const
inlineconstexprnoexcept

Gets the item type as a string.

Returns
Item type as string.

◆ Value() [1/2]

template<typename T >
T & StormByte::Config::Item::Base::Value ( )
inline

Gets the item value (mutable).

Template Parameters
TTarget value type.
Returns
Reference to the value.
Exceptions
WrongValueTypeConversionon type mismatch.

◆ Value() [2/2]

template<typename T >
const T & StormByte::Config::Item::Base::Value ( ) const
inline

Gets the item value (const).

Template Parameters
TTarget value type.
Returns
Const reference to the value.
Exceptions
WrongValueTypeConversionon type mismatch.

Member Data Documentation

◆ m_name

std::optional<std::string> StormByte::Config::Item::Base::m_name
protected

Item name.


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