TS_CPP
An efficient & easy to use implementation of a Symbol table used in most compilers
Loading...
Searching...
No Matches
AttributeValue.cpp
1#include "AttributeValue.h"
2
3using namespace TS_CPP;
4
6{
7 if(strPtr!= nullptr)
8 {
9 this->data = {.strPtr = strdup(strPtr)};
10 this->type = STRING;
11 }
12 else
13 {
14 this->data = {.strPtr = nullptr};
15 this->type = NOATRIB;
16 }
17
18}
19
20AttributeValue::AttributeValue(long long int integer)
21{
22 this->data = {.integer = integer};
23 this->type = INT;
24}
25
27{
28 if(this->type == STRING)
29 {
30 free(this->data.strPtr);
31 }
32}
33
35{
36 if(this->type == other.type)
37 {
38 if(this->type == STRING && strcmp(this->data.strPtr,other.data.strPtr) == 0)
39 {
40 return true;
41 }
42 else
43 {
44 return this->data.integer == other.data.integer;
45 }
46 }
47 else
48 {
49 return false;
50 }
51}
52
54{
55 return ! (*this == other);
56}
57
58std::pair<AttributeValue::AttributeType, AttributeValue::DataUnion> AttributeValue::getValue()
59{
60 return {type,data};
61}
62
64{
65 return this->type != NOATRIB;
66}
std::pair< AttributeType, DataUnion > getValue()
AttributeValue(const char *strPtr)
bool operator==(const AttributeValue &other)
bool operator!=(const AttributeValue &other)