IDL compiler front-end library
Public Types | Public Member Functions | List of all members
AST::Variant Class Reference

Stores the constant value. More...

#include <Variant.h>

Inheritance diagram for AST::Variant:
AST::Constant

Public Types

enum class  VT {
  EMPTY , BOOLEAN , OCTET , CHAR ,
  WCHAR , USHORT , ULONG , ULONGLONG ,
  SHORT , LONG , LONGLONG , FLOAT ,
  DOUBLE , LONGDOUBLE , STRING , WSTRING ,
  FIXED , ENUM_ITEM , CONSTANT
}
 Value vtype. More...
 

Public Member Functions

VT vtype () const noexcept
 
bool as_bool () const noexcept
 
uint8_t as_octet () const noexcept
 
char as_char () const noexcept
 
wchar_t as_wchar () const noexcept
 
uint16_t as_unsigned_short () const noexcept
 
int16_t as_short () const noexcept
 
uint32_t as_unsigned_long () const noexcept
 
int32_t as_long () const noexcept
 
uint64_t as_unsigned_long_long () const noexcept
 
int64_t as_long_long () const noexcept
 
float as_float () const noexcept
 
double as_double () const noexcept
 
long double as_long_double () const noexcept
 
const std::string & as_string () const noexcept
 
const std::wstring & as_wstring () const noexcept
 
const EnumItemas_enum_item () const noexcept
 
const Constantas_constant () const noexcept
 
const Fixedas_Fixed () const noexcept
 
std::string to_string () const
 
bool empty () const noexcept
 
const Variantdereference_const () const noexcept
 
 ~Variant ()
 Destructor.
 
 Variant ()
 VT::EMPTY.
 
 Variant (const Variant &src)
 Copy constructor.
 
 Variant (Variant &&src) noexcept
 Move constructor.
 
 Variant (bool v) noexcept
 VT::BOOLEAN.
 
 Variant (uint8_t v) noexcept
 VT::OCTET.
 
 Variant (char v) noexcept
 VT::CHAR.
 
 Variant (wchar_t v) noexcept
 VT::WCHAR.
 
 Variant (int16_t v) noexcept
 VT::SHORT.
 
 Variant (uint16_t v) noexcept
 VT::USHORT.
 
 Variant (int32_t v) noexcept
 VT::LONG.
 
 Variant (uint32_t v) noexcept
 VT::ULONG.
 
 Variant (int64_t v) noexcept
 VT::LONGLONG.
 
 Variant (uint64_t v) noexcept
 VT::ULONGLONG.
 
 Variant (float v) noexcept
 VT::FLOAT.
 
 Variant (double v) noexcept
 VT::DOUBLE.
 
 Variant (long double v) noexcept
 VT::LONGDOUBLE.
 
 Variant (std::string &&v) noexcept
 VT::STRING.
 
 Variant (const char *s)
 VT::STRING.
 
 Variant (std::wstring &&v) noexcept
 VT::WSTRING.
 
 Variant (const wchar_t *s)
 VT::WSTRING.
 
 Variant (const Fixed &v) noexcept
 VT::FIXED.
 
 Variant (const EnumItem &item) noexcept
 VT::ENUM_ITEM.
 
 Variant (const Constant &constant) noexcept
 VT::CONSTANT.
 
Variantoperator= (const Variant &src)
 Copy assignment.
 
Variantoperator= (Variant &&src) noexcept
 Move assignment.
 

Detailed Description

Stores the constant value.

Definition at line 41 of file Variant.h.

Member Enumeration Documentation

◆ VT

enum AST::Variant::VT
strong

Value vtype.

Enumerator
EMPTY 

No value.

BOOLEAN 

Variant::as_bool ()

OCTET 

Variant::as_octet ()

CHAR 

Variant::as_char ()

WCHAR 

Variant::as_wchar ()

USHORT 

Variant::as_unsigned_short ()

ULONG 

Variant::as_unsigned_long ()

ULONGLONG 

Variant::as_unsigned_long_long ()

SHORT 

Variant::as_short ()

LONG 

Variant::as_long ()

LONGLONG 

Variant::as_long_long ()

FLOAT 

Variant::as_float ()

DOUBLE 

Variant::as_double ()

LONGDOUBLE 

Variant::as_long_double ()

STRING 

Variant::as_string ()

WSTRING 

Variant::as_wstring ()

FIXED 

Variant::as_Fixed ();.

ENUM_ITEM 

Variant::as_enum_item ()

CONSTANT 

Variant::as_constant ()

Definition at line 45 of file Variant.h.

Member Function Documentation

◆ vtype()

VT AST::Variant::vtype ( ) const
inlinenoexcept
Returns
The value type.

Definition at line 72 of file Variant.h.

◆ as_bool()

bool AST::Variant::as_bool ( ) const
inlinenoexcept
Returns
boolean value.
Invariant
vtype () == VT::BOOLEAN

Definition at line 81 of file Variant.h.

◆ as_octet()

uint8_t AST::Variant::as_octet ( ) const
inlinenoexcept
Returns
octet value.
Invariant
vtype () == VT::OCTET

Definition at line 89 of file Variant.h.

◆ as_char()

char AST::Variant::as_char ( ) const
inlinenoexcept
Returns
char value.
Invariant
vtype () == VT::CHAR

Definition at line 97 of file Variant.h.

◆ as_wchar()

wchar_t AST::Variant::as_wchar ( ) const
inlinenoexcept
Returns
wchar value.
Invariant
vtype () == VT::WCHAR

Definition at line 105 of file Variant.h.

◆ as_unsigned_short()

uint16_t AST::Variant::as_unsigned_short ( ) const
inlinenoexcept
Returns
unsigned short value.
Invariant
vtype () == VT::USHORT

Definition at line 113 of file Variant.h.

◆ as_short()

int16_t AST::Variant::as_short ( ) const
inlinenoexcept
Returns
short value.
Invariant
vtype () == VT::SHORT

Definition at line 121 of file Variant.h.

◆ as_unsigned_long()

uint32_t AST::Variant::as_unsigned_long ( ) const
inlinenoexcept
Returns
unsigned long value.
Invariant
vtype () == VT::ULONG

Definition at line 129 of file Variant.h.

◆ as_long()

int32_t AST::Variant::as_long ( ) const
inlinenoexcept
Returns
long value.
Invariant
vtype () == VT::LONG

Definition at line 137 of file Variant.h.

◆ as_unsigned_long_long()

uint64_t AST::Variant::as_unsigned_long_long ( ) const
inlinenoexcept
Returns
unsigned long long value.
Invariant
vtype () == VT::ULONGLONG

Definition at line 145 of file Variant.h.

◆ as_long_long()

int64_t AST::Variant::as_long_long ( ) const
inlinenoexcept
Returns
long long value.
Invariant
vtype () == VT::LONGLONG

Definition at line 153 of file Variant.h.

◆ as_float()

float AST::Variant::as_float ( ) const
inlinenoexcept
Returns
float value.
Invariant
vtype () == VT::FLOAT

Definition at line 163 of file Variant.h.

◆ as_double()

double AST::Variant::as_double ( ) const
inlinenoexcept
Returns
double value.
Invariant
vtype () == VT::DOUBLE

Definition at line 171 of file Variant.h.

◆ as_long_double()

long double AST::Variant::as_long_double ( ) const
inlinenoexcept
Returns
long double value.
Invariant
vtype () == VT::LONGDOUBLE

Definition at line 179 of file Variant.h.

◆ as_string()

const std::string& AST::Variant::as_string ( ) const
inlinenoexcept
Returns
string value.
Invariant
vtype () == VT::STRING

Definition at line 189 of file Variant.h.

◆ as_wstring()

const std::wstring& AST::Variant::as_wstring ( ) const
inlinenoexcept
Returns
wstring value.
Invariant
vtype () == VT::WSTRING

Definition at line 197 of file Variant.h.

◆ as_enum_item()

const EnumItem& AST::Variant::as_enum_item ( ) const
inlinenoexcept
Returns
Enumerator reference.
Invariant
vtype () == VT::ENUM_ITEM

Definition at line 205 of file Variant.h.

◆ as_constant()

const Constant& AST::Variant::as_constant ( ) const
inlinenoexcept
Returns
Constant reference.
Invariant
vtype () == VT::CONSTANT

Definition at line 213 of file Variant.h.

◆ as_Fixed()

const Fixed& AST::Variant::as_Fixed ( ) const
inlinenoexcept
Returns
Fixed reference.
Invariant
vtype () == VT::FIXED

Definition at line 223 of file Variant.h.

◆ to_string()

std::string AST::Variant::to_string ( ) const

Converts value to std::string. This method escapes character and string values accordingly to C constant escape rules. This method does not add 'L' prefix to wide strings and characters and does not add 'D' suffix to fixed numbers.

◆ empty()

bool AST::Variant::empty ( ) const
inlinenoexcept
Returns
true if Variant is empty. In the valid AST, Variant never be empty.

Definition at line 237 of file Variant.h.

◆ dereference_const()

const Variant& AST::Variant::dereference_const ( ) const
noexcept
Returns
The constant final value.

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