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 ,
  STRING_VAL , EXCEPTION_VAL , ENUM_VAL , UNKNOWN_VAL
}
 Enumeration of possible value types. More...
 

Public Member Functions

 VariableValue (const std::string &name, int8_t value)
 
 VariableValue (const std::string &name, uint8_t value)
 
 VariableValue (const std::string &name, int16_t value)
 
 VariableValue (const std::string &name, uint16_t value)
 
 VariableValue (const std::string &name, int32_t value)
 
 VariableValue (const std::string &name, uint32_t value)
 
 VariableValue (const std::string &name, int64_t value)
 
 VariableValue (const std::string &name, uint64_t value)
 
 VariableValue (const std::string &name, bool value)
 
 VariableValue (const std::string &name, char value)
 
 VariableValue (const std::string &name, float value)
 
 VariableValue (const std::string &name, double value)
 
 VariableValue (const std::string &name, const std::string &value)
 
 VariableValue (const std::string &name, const char *value)
 
 VariableValue (const std::string &name, const std::exception &ex)
 
template<typename EnumType >
 VariableValue (const std::string &name, EnumType value, typename std::enable_if< std::is_enum< EnumType >::value >::type *=0)
 Constructor for enumerations.
 
 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
 
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 
 
pod_value 
 Union to store POD types.
 
std::string string_value
 Variable to store string, exception messages, and enums.
 

Private Member Functions

template<typename EnumType >
std::string enum_to_string (EnumType value)
 Helper function to convert an enumeration to a string.
 

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.
 

Detailed Description

Structure for storing values of various types, including enumerations.

Definition at line 18 of file VariableValue.hpp.

Member Enumeration Documentation

◆ ValueType

Enumeration of possible value types.

Enumerator
INT8_VAL 
UINT8_VAL 
INT16_VAL 
UINT16_VAL 
INT32_VAL 
UINT32_VAL 
INT64_VAL 
UINT64_VAL 
BOOL_VAL 
CHAR_VAL 
FLOAT_VAL 
DOUBLE_VAL 
STRING_VAL 
EXCEPTION_VAL 
ENUM_VAL 
UNKNOWN_VAL 

Definition at line 24 of file VariableValue.hpp.

Constructor & Destructor Documentation

◆ VariableValue() [1/17]

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

Definition at line 61 of file VariableValue.hpp.

◆ VariableValue() [2/17]

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

Definition at line 66 of file VariableValue.hpp.

◆ VariableValue() [3/17]

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

Definition at line 71 of file VariableValue.hpp.

◆ VariableValue() [4/17]

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

Definition at line 76 of file VariableValue.hpp.

◆ VariableValue() [5/17]

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

Definition at line 81 of file VariableValue.hpp.

◆ VariableValue() [6/17]

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

Definition at line 86 of file VariableValue.hpp.

◆ VariableValue() [7/17]

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

Definition at line 91 of file VariableValue.hpp.

◆ VariableValue() [8/17]

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

Definition at line 96 of file VariableValue.hpp.

◆ VariableValue() [9/17]

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

Definition at line 101 of file VariableValue.hpp.

◆ VariableValue() [10/17]

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

Definition at line 106 of file VariableValue.hpp.

◆ VariableValue() [11/17]

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

Definition at line 111 of file VariableValue.hpp.

◆ VariableValue() [12/17]

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

Definition at line 116 of file VariableValue.hpp.

◆ VariableValue() [13/17]

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

Definition at line 121 of file VariableValue.hpp.

◆ VariableValue() [14/17]

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

Definition at line 125 of file VariableValue.hpp.

◆ VariableValue() [15/17]

logit::VariableValue::VariableValue ( const std::string & name,
const std::exception & ex )
inline

Definition at line 129 of file VariableValue.hpp.

◆ VariableValue() [16/17]

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 138 of file VariableValue.hpp.

◆ VariableValue() [17/17]

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

Copy constructor.

Definition at line 144 of file VariableValue.hpp.

◆ ~VariableValue()

logit::VariableValue::~VariableValue ( )
default

Destructor.

Member Function Documentation

◆ enum_to_string()

template<typename EnumType >
std::string logit::VariableValue::enum_to_string ( EnumType value)
inlineprivate

Helper function to convert an enumeration to a string.

Template Parameters
EnumTypeThe enumeration type.
Parameters
valueThe enumeration value.
Returns
String representation of the enumeration.

Definition at line 235 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 244 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 225 of file VariableValue.hpp.

◆ operator=()

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

Assignment operator.

Definition at line 152 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 172 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 198 of file VariableValue.hpp.

Member Data Documentation

◆ bool_value

bool logit::VariableValue::bool_value

Definition at line 52 of file VariableValue.hpp.

◆ char_value

char logit::VariableValue::char_value

Definition at line 53 of file VariableValue.hpp.

◆ double_value

double logit::VariableValue::double_value

Definition at line 55 of file VariableValue.hpp.

◆ float_value

float logit::VariableValue::float_value

Definition at line 54 of file VariableValue.hpp.

◆ int16_value

int16_t logit::VariableValue::int16_value

Definition at line 46 of file VariableValue.hpp.

◆ int32_value

int32_t logit::VariableValue::int32_value

Definition at line 48 of file VariableValue.hpp.

◆ int64_value

int64_t logit::VariableValue::int64_value

Definition at line 50 of file VariableValue.hpp.

◆ int8_value

int8_t logit::VariableValue::int8_value

Definition at line 44 of file VariableValue.hpp.

◆ is_literal

bool logit::VariableValue::is_literal

Flag indicating if the variable is a literal.

Definition at line 20 of file VariableValue.hpp.

◆ name

std::string logit::VariableValue::name

Variable name.

Definition at line 19 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 58 of file VariableValue.hpp.

◆ type

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

◆ uint16_value

uint16_t logit::VariableValue::uint16_value

Definition at line 47 of file VariableValue.hpp.

◆ uint32_value

uint32_t logit::VariableValue::uint32_value

Definition at line 49 of file VariableValue.hpp.

◆ uint64_value

uint64_t logit::VariableValue::uint64_value

Definition at line 51 of file VariableValue.hpp.

◆ uint8_value

uint8_t logit::VariableValue::uint8_value

Definition at line 45 of file VariableValue.hpp.


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