LogIt++
Loading...
Searching...
No Matches
logit::VariableValue Struct Reference

Structure for storing values of various types, including enumerations. More...

#include <VariableValue.hpp>

Public Types

enum class  ValueType {
  INT8_VAL , UINT8_VAL , INT16_VAL , UINT16_VAL ,
  INT32_VAL , UINT32_VAL , INT64_VAL , UINT64_VAL ,
  BOOL_VAL , CHAR_VAL , FLOAT_VAL , DOUBLE_VAL ,
  LONG_DOUBLE_VAL , DURATION_VAL , TIME_POINT_VAL , STRING_VAL ,
  EXCEPTION_VAL , ERROR_CODE_VAL , ENUM_VAL , PATH_VAL ,
  POINTER_VAL , SMART_POINTER_VAL , VARIANT_VAL , OPTIONAL_VAL ,
  UNKNOWN_VAL
}
 Enumeration of possible value types for VariableValue. More...
 

Public Member Functions

template<typename T>
 VariableValue (const std::string &name, T value, typename std::enable_if< std::is_same< T, bool >::value >::type *=nullptr)
 
template<typename T>
 VariableValue (const std::string &name, T value, typename std::enable_if< std::is_same< T, char >::value >::type *=nullptr)
 
 VariableValue (const std::string &name, const std::string &value)
 
 VariableValue (const std::string &name, const char *value)
 
template<typename T>
 VariableValue (const std::string &name, const T &value, typename std::enable_if< std::is_base_of< std::exception, T >::value >::type *=nullptr)
 
 VariableValue (const std::string &name, const std::error_code &ec)
 
template<typename T>
 VariableValue (const std::string &name, T value, typename std::enable_if< std::is_floating_point< T >::value >::type *=nullptr)
 
template<typename T>
 VariableValue (const std::string &name, T value, typename std::enable_if< std::is_integral< T >::value >::type *=nullptr)
 
template<typename EnumType>
 VariableValue (const std::string &name, EnumType value, typename std::enable_if< std::is_enum< EnumType >::value >::type *=0)
 Constructor for enumerations.
 
template<typename Rep, typename Period>
 VariableValue (const std::string &name, const std::chrono::duration< Rep, Period > &duration)
 
template<typename Clock, typename Duration>
 VariableValue (const std::string &name, const std::chrono::time_point< Clock, Duration > &time_point)
 
 VariableValue (const std::string &name, const std::filesystem::path &path)
 
template<typename... Ts>
 VariableValue (const std::string &name, const std::variant< Ts... > &variant)
 
template<typename T>
 VariableValue (const std::string &name, const std::optional< T > &optional)
 
 VariableValue (const std::string &name, void *ptr)
 
template<typename T>
 VariableValue (const std::string &name, const std::shared_ptr< T > &ptr)
 
template<typename T>
 VariableValue (const std::string &name, const std::unique_ptr< T > &ptr)
 
 VariableValue (const VariableValue &other)
 Copy constructor.
 
VariableValueoperator= (const VariableValue &other)
 Assignment operator.
 
 ~VariableValue ()=default
 Destructor.
 
std::string to_string () const
 Method to get the value as a string.
 
std::string to_string (const char *fmt) const
 Method to get the value as a formatted string.
 

Public Attributes

std::string name
 Variable name.
 
bool is_literal
 Flag indicating if the variable is a literal.
 
enum logit::VariableValue::ValueType type
 Specifies the type of the stored value in the VariableValue structure.
 
union { 
 
   int8_t   int8_value 
 
   uint8_t   uint8_value 
 
   int16_t   int16_value 
 
   uint16_t   uint16_value 
 
   int32_t   int32_value 
 
   uint32_t   uint32_value 
 
   int64_t   int64_value 
 
   uint64_t   uint64_value 
 
   bool   bool_value 
 
   char   char_value 
 
   float   float_value 
 
   double   double_value 
 
   long double   long_double_value 
 
pod_value 
 Union to store POD types.
 
std::string string_value
 Variable to store string, exception messages, and enums.
 
std::error_code error_code_value
 Variable to store std::error_code.
 

Static Private Member Functions

static bool is_valid_literal_name (const std::string &name)
 Helper function to check if a name is a valid literal.
 
static bool is_pod_type (ValueType type)
 Helper function to determine if a ValueType represents a POD type.
 
template<typename Period>
static std::string duration_units ()
 Helper function to get the unit of the duration.
 

Detailed Description

Structure for storing values of various types, including enumerations.

Definition at line 38 of file VariableValue.hpp.

Member Enumeration Documentation

◆ ValueType

Enumeration of possible value types for VariableValue.

Enumerator
INT8_VAL 

Value of type int8_t (signed 8-bit integer).

UINT8_VAL 

Value of type uint8_t (unsigned 8-bit integer).

INT16_VAL 

Value of type int16_t (signed 16-bit integer).

UINT16_VAL 

Value of type uint16_t (unsigned 16-bit integer).

INT32_VAL 

Value of type int32_t (signed 32-bit integer).

UINT32_VAL 

Value of type uint32_t (unsigned 32-bit integer).

INT64_VAL 

Value of type int64_t (signed 64-bit integer).

UINT64_VAL 

Value of type uint64_t (unsigned 64-bit integer).

BOOL_VAL 

Value of type bool.

CHAR_VAL 

Value of type char (single character).

FLOAT_VAL 

Value of type float (single-precision floating point).

DOUBLE_VAL 

Value of type double (double-precision floating point).

LONG_DOUBLE_VAL 

Value of type long double (extended-precision floating point).

DURATION_VAL 

Value of type std::chrono::duration (time duration).

TIME_POINT_VAL 

Value of type std::chrono::time_point (specific point in time).

STRING_VAL 

Value of type std::string (dynamic-length string).

EXCEPTION_VAL 

Value representing an exception (derived from std::exception).

ERROR_CODE_VAL 

Value of type std::error_code (system error code).

ENUM_VAL 

Value of any enumeration type (converted to string or integral value).

PATH_VAL 

Value of type std::filesystem::path (filesystem path).

POINTER_VAL 

Value of type void* (raw pointer).

SMART_POINTER_VAL 

Value of type std::shared_ptr or std::unique_ptr (smart pointers).

VARIANT_VAL 

Value of type std::variant (type-safe union).

OPTIONAL_VAL 

Value of type std::optional (optional value holder).

UNKNOWN_VAL 

Unknown or unsupported value type.

Definition at line 44 of file VariableValue.hpp.

Constructor & Destructor Documentation

◆ VariableValue() [1/18]

template<typename T>
logit::VariableValue::VariableValue ( const std::string & name,
T value,
typename std::enable_if< std::is_same< T, bool >::value >::type * = nullptr )
inline

Definition at line 93 of file VariableValue.hpp.

◆ VariableValue() [2/18]

template<typename T>
logit::VariableValue::VariableValue ( const std::string & name,
T value,
typename std::enable_if< std::is_same< T, char >::value >::type * = nullptr )
inline

Definition at line 100 of file VariableValue.hpp.

◆ VariableValue() [3/18]

logit::VariableValue::VariableValue ( const std::string & name,
const std::string & value )
inlineexplicit

Definition at line 106 of file VariableValue.hpp.

◆ VariableValue() [4/18]

logit::VariableValue::VariableValue ( const std::string & name,
const char * value )
inlineexplicit

Definition at line 110 of file VariableValue.hpp.

◆ VariableValue() [5/18]

template<typename T>
logit::VariableValue::VariableValue ( const std::string & name,
const T & value,
typename std::enable_if< std::is_base_of< std::exception, T >::value >::type * = nullptr )
inline

Definition at line 114 of file VariableValue.hpp.

◆ VariableValue() [6/18]

logit::VariableValue::VariableValue ( const std::string & name,
const std::error_code & ec )
inlineexplicit

Definition at line 119 of file VariableValue.hpp.

◆ VariableValue() [7/18]

template<typename T>
logit::VariableValue::VariableValue ( const std::string & name,
T value,
typename std::enable_if< std::is_floating_point< T >::value >::type * = nullptr )
inline

Definition at line 124 of file VariableValue.hpp.

◆ VariableValue() [8/18]

template<typename T>
logit::VariableValue::VariableValue ( const std::string & name,
T value,
typename std::enable_if< std::is_integral< T >::value >::type * = nullptr )
inline

Definition at line 140 of file VariableValue.hpp.

◆ VariableValue() [9/18]

template<typename EnumType>
logit::VariableValue::VariableValue ( const std::string & name,
EnumType value,
typename std::enable_if< std::is_enum< EnumType >::value >::type * = 0 )
inline

Constructor for enumerations.

Template Parameters
EnumTypeThe enumeration type.
Parameters
nameThe variable name.
valueThe enumeration value.

Definition at line 179 of file VariableValue.hpp.

◆ VariableValue() [10/18]

template<typename Rep, typename Period>
logit::VariableValue::VariableValue ( const std::string & name,
const std::chrono::duration< Rep, Period > & duration )
inline

Definition at line 186 of file VariableValue.hpp.

◆ VariableValue() [11/18]

template<typename Clock, typename Duration>
logit::VariableValue::VariableValue ( const std::string & name,
const std::chrono::time_point< Clock, Duration > & time_point )
inline

Definition at line 192 of file VariableValue.hpp.

◆ VariableValue() [12/18]

logit::VariableValue::VariableValue ( const std::string & name,
const std::filesystem::path & path )
inlineexplicit

Definition at line 200 of file VariableValue.hpp.

◆ VariableValue() [13/18]

template<typename... Ts>
logit::VariableValue::VariableValue ( const std::string & name,
const std::variant< Ts... > & variant )
inlineexplicit

Definition at line 205 of file VariableValue.hpp.

◆ VariableValue() [14/18]

template<typename T>
logit::VariableValue::VariableValue ( const std::string & name,
const std::optional< T > & optional )
inlineexplicit

Definition at line 221 of file VariableValue.hpp.

◆ VariableValue() [15/18]

logit::VariableValue::VariableValue ( const std::string & name,
void * ptr )
inlineexplicit

Definition at line 240 of file VariableValue.hpp.

◆ VariableValue() [16/18]

template<typename T>
logit::VariableValue::VariableValue ( const std::string & name,
const std::shared_ptr< T > & ptr )
inlineexplicit

Definition at line 248 of file VariableValue.hpp.

◆ VariableValue() [17/18]

template<typename T>
logit::VariableValue::VariableValue ( const std::string & name,
const std::unique_ptr< T > & ptr )
inlineexplicit

Definition at line 257 of file VariableValue.hpp.

◆ VariableValue() [18/18]

logit::VariableValue::VariableValue ( const VariableValue & other)
inline

Copy constructor.

Definition at line 266 of file VariableValue.hpp.

◆ ~VariableValue()

logit::VariableValue::~VariableValue ( )
default

Destructor.

Member Function Documentation

◆ duration_units()

template<typename Period>
static std::string logit::VariableValue::duration_units ( )
inlinestaticprivate

Helper function to get the unit of the duration.

Template Parameters
PeriodThe period type of the duration.
Returns
A string representing the unit of the duration.

Definition at line 403 of file VariableValue.hpp.

◆ is_pod_type()

static bool logit::VariableValue::is_pod_type ( ValueType type)
inlinestaticprivate

Helper function to determine if a ValueType represents a POD type.

Parameters
typeThe ValueType to check.
Returns
True if the type is POD, false otherwise.

Definition at line 378 of file VariableValue.hpp.

◆ is_valid_literal_name()

static bool logit::VariableValue::is_valid_literal_name ( const std::string & name)
inlinestaticprivate

Helper function to check if a name is a valid literal.

Parameters
nameThe name to check.
Returns
True if valid, false otherwise.

Definition at line 370 of file VariableValue.hpp.

◆ operator=()

VariableValue & logit::VariableValue::operator= ( const VariableValue & other)
inline

Assignment operator.

Definition at line 276 of file VariableValue.hpp.

◆ to_string() [1/2]

std::string logit::VariableValue::to_string ( ) const
inline

Method to get the value as a string.

Returns
String representation of the value.

Definition at line 297 of file VariableValue.hpp.

◆ to_string() [2/2]

std::string logit::VariableValue::to_string ( const char * fmt) const
inline

Method to get the value as a formatted string.

Parameters
fmtThe format string.
Returns
Formatted string representation of the value.

Definition at line 333 of file VariableValue.hpp.

Member Data Documentation

◆ bool_value

bool logit::VariableValue::bool_value

Definition at line 81 of file VariableValue.hpp.

◆ char_value

char logit::VariableValue::char_value

Definition at line 82 of file VariableValue.hpp.

◆ double_value

double logit::VariableValue::double_value

Definition at line 84 of file VariableValue.hpp.

◆ error_code_value

std::error_code logit::VariableValue::error_code_value

Variable to store std::error_code.

Definition at line 89 of file VariableValue.hpp.

◆ float_value

float logit::VariableValue::float_value

Definition at line 83 of file VariableValue.hpp.

◆ int16_value

int16_t logit::VariableValue::int16_value

Definition at line 75 of file VariableValue.hpp.

◆ int32_value

int32_t logit::VariableValue::int32_value

Definition at line 77 of file VariableValue.hpp.

◆ int64_value

int64_t logit::VariableValue::int64_value

Definition at line 79 of file VariableValue.hpp.

◆ int8_value

int8_t logit::VariableValue::int8_value

Definition at line 73 of file VariableValue.hpp.

◆ is_literal

bool logit::VariableValue::is_literal

Flag indicating if the variable is a literal.

Definition at line 40 of file VariableValue.hpp.

◆ long_double_value

long double logit::VariableValue::long_double_value

Definition at line 85 of file VariableValue.hpp.

◆ name

std::string logit::VariableValue::name

Variable name.

Definition at line 39 of file VariableValue.hpp.

◆ [union]

union { ... } logit::VariableValue::pod_value

Union to store POD types.

◆ string_value

std::string logit::VariableValue::string_value

Variable to store string, exception messages, and enums.

Definition at line 88 of file VariableValue.hpp.

◆ type

enum logit::VariableValue::ValueType logit::VariableValue::type

Specifies the type of the stored value in the VariableValue structure.

◆ uint16_value

uint16_t logit::VariableValue::uint16_value

Definition at line 76 of file VariableValue.hpp.

◆ uint32_value

uint32_t logit::VariableValue::uint32_value

Definition at line 78 of file VariableValue.hpp.

◆ uint64_value

uint64_t logit::VariableValue::uint64_value

Definition at line 80 of file VariableValue.hpp.

◆ uint8_value

uint8_t logit::VariableValue::uint8_value

Definition at line 74 of file VariableValue.hpp.


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