TS_CPP
An efficient & easy to use implementation of a Symbol table used in most compilers
Loading...
Searching...
No Matches
TS_CPP::AttributeValue Class Reference

#include <AttributeValue.h>

Classes

union  DataUnion
 Union which stores either a numeric value (.num) or a pointer to a c string (.strPtr) More...
 

Public Types

enum  AttributeType { NOATRIB = 0 , INT , STRING }
 Enum containing the type of attribute used. More...
 
typedef std::pair< AttributeType, DataUnion > AttributeValuePair
 

Public Member Functions

 AttributeValue (const char *strPtr)
 
 AttributeValue (long long integer)
 
 ~AttributeValue ()
 
bool operator== (const AttributeValue &other)
 
bool operator!= (const AttributeValue &other)
 
std::pair< AttributeType, DataUnion > getValue ()
 
bool isAValidAttributeValue ()
 

Detailed Description

Class returned by Entry::getAttribute with the fields:

Parameters
attributeTypeAn enum containing the type of the attribute (if the attribute does not exist, entryType is Null)
dataAn union which contains either the integer stored or the pointer to the c string stored (if the attribute does not exist, data is nullptr (or 0 if viewed as int))

Definition at line 18 of file AttributeValue.h.

Member Typedef Documentation

◆ AttributeValuePair

typedef std::pair<AttributeType,DataUnion> TS_CPP::AttributeValue::AttributeValuePair

Definition at line 27 of file AttributeValue.h.

Member Enumeration Documentation

◆ AttributeType

Enum containing the type of attribute used.

Definition at line 22 of file AttributeValue.h.

Constructor & Destructor Documentation

◆ AttributeValue() [1/2]

AttributeValue::AttributeValue ( const char * strPtr)
explicit

This constructor initializes an AttributeValue object with a c string as a value If the strPtr is null, an Atribute of type NOATRIB is returned instead

Parameters
strPtrThe pointer to the string that will be copied inside and stored as the value

Definition at line 5 of file AttributeValue.cpp.

◆ AttributeValue() [2/2]

TS_CPP::AttributeValue::AttributeValue ( long long integer)
explicit

This constructor initializes an AttributeValue object with a long long as a value

Parameters
integerThe long long number stored as the value

◆ ~AttributeValue()

AttributeValue::~AttributeValue ( )

This destructor check if the value is a c string, and if it is, it frees the memory pointed by the stored pointer before freeing itself

Definition at line 26 of file AttributeValue.cpp.

Member Function Documentation

◆ getValue()

std::pair< AttributeValue::AttributeType, AttributeValue::DataUnion > AttributeValue::getValue ( )

This function get the value of the attribute The availability of the string pointed by DataUnion is guaranteed until object destruction

Returns
A std::pair with the first parameter being an Enum AttributeType representing the type of the AttributeValue and the second parameter being a DataUnion to either a string or int (check the first parameter to get its actual type)

Definition at line 58 of file AttributeValue.cpp.

◆ isAValidAttributeValue()

bool AttributeValue::isAValidAttributeValue ( )

This function returns true if the data stored inside is valid or false if the data used is invalid (i.e: a null pointer to a string)

Returns
true if the data stored inside is valid or false if the data used is invalid

Definition at line 63 of file AttributeValue.cpp.

◆ operator!=()

bool AttributeValue::operator!= ( const AttributeValue & other)

The != operator returns true if both AttributeValues have different types or its value is different (either the c string or the integer) or false otherwise

Parameters
otherThe other AttributeValue used to compare
Returns
true if both AttributeValues have different types or its value is different (either the c string or the integer) or false otherwise

Definition at line 53 of file AttributeValue.cpp.

◆ operator==()

bool AttributeValue::operator== ( const AttributeValue & other)

The == operator returns true if both AttributeValues have the same type and its value is the same (either the c string or the integer) or false otherwise

Parameters
otherThe other AttributeValue used to compare
Returns
true if both AttributeValues have the same type and its value is the same (either the c string or the integer) or false otherwise

Definition at line 34 of file AttributeValue.cpp.


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