Chi-Tech
chi_data_types::Varying Class Reference

#include <varying.h>

Data Structures

struct  IsBool
 
struct  IsByteArray
 
struct  IsFloat
 
struct  IsInteger
 
struct  IsSignedInteger
 
struct  IsString
 
struct  IsUnsignedInteger
 
class  VaryingArbitraryType
 
class  VaryingType
 

Public Types

template<typename T >
using StringType = typename std::enable_if_t< IsString< T >::value, T >
 
template<typename T >
using SignedIntegerType = typename std::enable_if_t< IsSignedInteger< T >::value, T >
 
template<typename T >
using UnsignedIntegerType = typename std::enable_if_t< IsUnsignedInteger< T >::value, T >
 

Public Member Functions

template<typename T >
 Varying (const T &value)
 
 Varying (const std::vector< std::byte > &value)
 
 Varying (const std::string &value)
 
 Varying (const char *value)
 
 Varying (const Varying &other)
 
 Varying (Varying &&other) noexcept
 
Varyingoperator= (const Varying &other)
 
Varyingoperator= (const std::vector< std::byte > &value)
 
Varyingoperator= (const std::string &value)
 
template<typename T , std::enable_if_t< IsBool< T >::value, bool > = true>
Varyingoperator= (const T &value)
 
template<typename T , std::enable_if_t< IsInteger< T >::value, bool > = true>
Varyingoperator= (const T &value)
 
template<typename T , std::enable_if_t< IsFloat< T >::value, bool > = true>
Varyingoperator= (const T &value)
 
bool operator== (const Varying &that) const
 
bool operator!= (const Varying &that) const
 
bool operator> (const Varying &that) const
 
bool operator>= (const Varying &that) const
 
bool operator< (const Varying &that) const
 
bool operator<= (const Varying &that) const
 
template<typename T >
BoolType< T > GetValue () const
 
template<typename T >
FloatType< T > GetValue () const
 
template<typename T >
StringType< T > GetValue () const
 
template<typename T >
SignedIntegerType< T > GetValue () const
 
template<typename T >
UnsignedIntegerType< T > GetValue () const
 
std::string StringValue () const
 
bool BoolValue () const
 
int64_t IntegerValue () const
 
double FloatValue () const
 
size_t ByteSize () const
 
VaryingDataType Type () const
 
std::string TypeName () const
 
std::string PrintStr (bool with_type=true) const
 
 ~Varying ()=default
 

Static Public Member Functions

static std::unique_ptr< VaryingTypeHelper (const bool &value)
 
static std::unique_ptr< VaryingTypeHelper (const int64_t &value)
 
static std::unique_ptr< VaryingTypeHelper (const double &value)
 
template<typename T >
static T DefaultValue ()
 

Private Types

template<typename T >
using BoolType = typename std::enable_if_t< IsBool< T >::value, T >
 
template<typename T >
using FloatType = typename std::enable_if_t< IsFloat< T >::value, T >
 
template<typename T >
using IntegerType = typename std::enable_if_t< IsInteger< T >::value, T >
 
template<typename T >
using BoolStorageType = typename std::enable_if_t< IsBool< T >::value, bool >
 
template<typename T >
using FloatStorageType = typename std::enable_if_t< IsFloat< T >::value, double >
 
template<typename T >
using IntegerStorageType = typename std::enable_if_t< IsInteger< T >::value, int64_t >
 

Private Member Functions

template<typename T >
BoolStorageType< T > CastValue (const T &value)
 
template<typename T >
FloatStorageType< T > CastValue (const T &value)
 
template<typename T >
IntegerStorageType< T > CastValue (const T &value)
 
void CheckTypeMatch (VaryingDataType type_A, VaryingDataType type_B_required) const
 

Private Attributes

VaryingDataType type_ = VaryingDataType::VOID
 
std::unique_ptr< VaryingTypedata_ = nullptr
 

Detailed Description

Definition at line 13 of file varying.h.

Member Typedef Documentation

◆ BoolStorageType

template<typename T >
using chi_data_types::Varying::BoolStorageType = typename std::enable_if_t<IsBool<T>::value, bool>
private

Definition at line 53 of file varying.h.

◆ BoolType

template<typename T >
using chi_data_types::Varying::BoolType = typename std::enable_if_t<IsBool<T>::value, T>
private

Definition at line 46 of file varying.h.

◆ FloatStorageType

template<typename T >
using chi_data_types::Varying::FloatStorageType = typename std::enable_if_t<IsFloat<T>::value, double>
private

Definition at line 55 of file varying.h.

◆ FloatType

template<typename T >
using chi_data_types::Varying::FloatType = typename std::enable_if_t<IsFloat<T>::value, T>
private

Definition at line 48 of file varying.h.

◆ IntegerStorageType

template<typename T >
using chi_data_types::Varying::IntegerStorageType = typename std::enable_if_t<IsInteger<T>::value, int64_t>
private

Definition at line 57 of file varying.h.

◆ IntegerType

template<typename T >
using chi_data_types::Varying::IntegerType = typename std::enable_if_t<IsInteger<T>::value, T>
private

Definition at line 50 of file varying.h.

◆ SignedIntegerType

template<typename T >
using chi_data_types::Varying::SignedIntegerType = typename std::enable_if_t<IsSignedInteger<T>::value, T>

Definition at line 419 of file varying.h.

◆ StringType

template<typename T >
using chi_data_types::Varying::StringType = typename std::enable_if_t<IsString<T>::value, T>

Definition at line 417 of file varying.h.

◆ UnsignedIntegerType

template<typename T >
using chi_data_types::Varying::UnsignedIntegerType = typename std::enable_if_t<IsUnsignedInteger<T>::value, T>

Definition at line 422 of file varying.h.

Constructor & Destructor Documentation

◆ Varying() [1/6]

template<typename T >
chi_data_types::Varying::Varying ( const T &  value)
inlineexplicit

Generalized constructor for bool, integral- and float-types. This constructor has been specialized for std::string and std::vector<std::byte>.

Definition at line 232 of file varying.h.

◆ Varying() [2/6]

chi_data_types::Varying::Varying ( const std::vector< std::byte > &  value)
explicit

Constructor for an arbitrary sequence of bytes value.

Definition at line 184 of file varying.cc.

◆ Varying() [3/6]

chi_data_types::Varying::Varying ( const std::string &  value)
explicit

Constructor for a string value.

Definition at line 193 of file varying.cc.

◆ Varying() [4/6]

chi_data_types::Varying::Varying ( const char *  value)
inlineexplicit

Constructor for a string literal value.

Definition at line 314 of file varying.h.

◆ Varying() [5/6]

chi_data_types::Varying::Varying ( const Varying other)

Copy constructor.

Definition at line 200 of file varying.cc.

◆ Varying() [6/6]

chi_data_types::Varying::Varying ( Varying &&  other)
noexcept

Move constructor.

Definition at line 207 of file varying.cc.

◆ ~Varying()

chi_data_types::Varying::~Varying ( )
default

Member Function Documentation

◆ BoolValue()

bool chi_data_types::Varying::BoolValue ( ) const

Returns the bool value if valid. Otherwise throws std::logic_error.

Definition at line 256 of file varying.cc.

◆ ByteSize()

size_t chi_data_types::Varying::ByteSize ( ) const

Returns the raw byte size associated with the type.

Definition at line 281 of file varying.cc.

◆ CastValue() [1/3]

template<typename T >
BoolStorageType< T > chi_data_types::Varying::CastValue ( const T &  value)
inlineprivate

Definition at line 61 of file varying.h.

◆ CastValue() [2/3]

template<typename T >
FloatStorageType< T > chi_data_types::Varying::CastValue ( const T &  value)
inlineprivate

Definition at line 67 of file varying.h.

◆ CastValue() [3/3]

template<typename T >
IntegerStorageType< T > chi_data_types::Varying::CastValue ( const T &  value)
inlineprivate

Definition at line 73 of file varying.h.

◆ CheckTypeMatch()

void chi_data_types::Varying::CheckTypeMatch ( VaryingDataType  type_A,
VaryingDataType  type_B_required 
) const
private

Checks if two VaryingDataType values match. Type A is matched against type B.

Definition at line 171 of file varying.cc.

◆ DefaultValue()

template<typename T >
static T chi_data_types::Varying::DefaultValue ( )
inlinestatic

Returns a default value for the type required.

Definition at line 394 of file varying.h.

◆ FloatValue()

double chi_data_types::Varying::FloatValue ( ) const

Returns the float value if valid. Otherwise throws std::logic_error.

Definition at line 272 of file varying.cc.

◆ GetValue() [1/5]

template<typename T >
BoolType< T > chi_data_types::Varying::GetValue ( ) const
inline

Returns values of type bool if able.

Definition at line 427 of file varying.h.

◆ GetValue() [2/5]

template<typename T >
FloatType< T > chi_data_types::Varying::GetValue ( ) const
inline

Returns floating point values if able.

Definition at line 436 of file varying.h.

◆ GetValue() [3/5]

template<typename T >
StringType< T > chi_data_types::Varying::GetValue ( ) const
inline

Returns a string if able.

Definition at line 447 of file varying.h.

◆ GetValue() [4/5]

template<typename T >
SignedIntegerType< T > chi_data_types::Varying::GetValue ( ) const
inline

Returns a signed integer if able.

Definition at line 456 of file varying.h.

◆ GetValue() [5/5]

template<typename T >
UnsignedIntegerType< T > chi_data_types::Varying::GetValue ( ) const
inline

Returns an unsigned integer if able.

Definition at line 467 of file varying.h.

◆ Helper() [1/3]

static std::unique_ptr< VaryingType > chi_data_types::Varying::Helper ( const bool &  value)
inlinestatic

Definition at line 255 of file varying.h.

◆ Helper() [2/3]

static std::unique_ptr< VaryingType > chi_data_types::Varying::Helper ( const double &  value)
inlinestatic

Definition at line 265 of file varying.h.

◆ Helper() [3/3]

static std::unique_ptr< VaryingType > chi_data_types::Varying::Helper ( const int64_t &  value)
inlinestatic

Definition at line 260 of file varying.h.

◆ IntegerValue()

int64_t chi_data_types::Varying::IntegerValue ( ) const

Returns the integer value if valid. Otherwise throws std::logic_error.

Definition at line 264 of file varying.cc.

◆ operator!=()

bool chi_data_types::Varying::operator!= ( const Varying that) const
inline

Inequality operator

Definition at line 375 of file varying.h.

◆ operator<()

bool chi_data_types::Varying::operator< ( const Varying that) const
inline

Relation operators

Definition at line 385 of file varying.h.

◆ operator<=()

bool chi_data_types::Varying::operator<= ( const Varying that) const
inline

Relation operators

Definition at line 387 of file varying.h.

◆ operator=() [1/6]

chi_data_types::Varying & chi_data_types::Varying::operator= ( const std::string &  value)

Assigns a string value.

Definition at line 238 of file varying.cc.

◆ operator=() [2/6]

chi_data_types::Varying & chi_data_types::Varying::operator= ( const std::vector< std::byte > &  value)

Assigns an arbitrary sequence of bytes value.

Definition at line 229 of file varying.cc.

◆ operator=() [3/6]

template<typename T , std::enable_if_t< IsBool< T >::value, bool > = true>
Varying & chi_data_types::Varying::operator= ( const T &  value)
inline

Assigns a bool value.

Definition at line 343 of file varying.h.

◆ operator=() [4/6]

template<typename T , std::enable_if_t< IsInteger< T >::value, bool > = true>
Varying & chi_data_types::Varying::operator= ( const T &  value)
inline

Assigns an integer value.

Definition at line 353 of file varying.h.

◆ operator=() [5/6]

template<typename T , std::enable_if_t< IsFloat< T >::value, bool > = true>
Varying & chi_data_types::Varying::operator= ( const T &  value)
inline

Assign a floating point value.

Definition at line 363 of file varying.h.

◆ operator=() [6/6]

chi_data_types::Varying & chi_data_types::Varying::operator= ( const Varying other)

Assignment operator. i.e., type_A = type_B

Definition at line 215 of file varying.cc.

◆ operator==()

bool chi_data_types::Varying::operator== ( const Varying that) const
inline

Equality operator

Definition at line 372 of file varying.h.

◆ operator>()

bool chi_data_types::Varying::operator> ( const Varying that) const
inline

Relation operators

Definition at line 378 of file varying.h.

◆ operator>=()

bool chi_data_types::Varying::operator>= ( const Varying that) const
inline

Relation operators

Definition at line 380 of file varying.h.

◆ PrintStr()

std::string chi_data_types::Varying::PrintStr ( bool  with_type = true) const

Returns a string value for the value.

Definition at line 285 of file varying.cc.

◆ StringValue()

std::string chi_data_types::Varying::StringValue ( ) const

Returns the string value if valid. Otherwise throws std::logic_error.

Definition at line 248 of file varying.cc.

◆ Type()

VaryingDataType chi_data_types::Varying::Type ( ) const
inline

Returns the current-type of the variable.

Definition at line 494 of file varying.h.

◆ TypeName()

std::string chi_data_types::Varying::TypeName ( ) const
inline

Returns the string type name of the type.

Definition at line 496 of file varying.h.

Field Documentation

◆ data_

std::unique_ptr<VaryingType> chi_data_types::Varying::data_ = nullptr
private

Definition at line 217 of file varying.h.

◆ type_

VaryingDataType chi_data_types::Varying::type_ = VaryingDataType::VOID
private

Type specification

Definition at line 216 of file varying.h.


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