TS_CPP
An efficient & easy to use implementation of a Symbol table used in most compilers
Loading...
Searching...
No Matches
AttributeValue.h
1#ifndef PRACTICA_ATTRIBUTEVALUE_H
2#define PRACTICA_ATTRIBUTEVALUE_H
3
4#include <cstring>
5#include <utility>
6#include <cstdlib>
7
8#include "TSConfig.h"
9
10namespace TS_CPP{
11
12
19{
20public:
22 enum AttributeType{NOATRIB = 0,INT,STRING};
23
25 union DataUnion{char* strPtr; long long integer;};
26
27 typedef std::pair<AttributeType,DataUnion> AttributeValuePair;
28
34 explicit AttributeValue(const char* strPtr);
35
40 explicit AttributeValue(long long integer);
41
46
52 bool operator== (const AttributeValue& other);
53
59 bool operator!= (const AttributeValue& other);
60
66 std::pair<AttributeType,DataUnion> getValue();
67
73
74private:
76 AttributeType type;
77
79 DataUnion data;
80};
81
82}
83
84#endif //PRACTICA_ATTRIBUTEVALUE_H
AttributeType
Enum containing the type of attribute used.
std::pair< AttributeType, DataUnion > getValue()
AttributeValue(long long integer)
AttributeValue(const char *strPtr)
bool operator==(const AttributeValue &other)
bool operator!=(const AttributeValue &other)
Union which stores either a numeric value (.num) or a pointer to a c string (.strPtr)