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
3
using namespace
TS_CPP
;
4
5
AttributeValue::AttributeValue
(
const
char
* strPtr)
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
20
AttributeValue::AttributeValue
(
long
long
int
integer)
21
{
22
this->data = {.integer = integer};
23
this->type = INT;
24
}
25
26
AttributeValue::~AttributeValue
()
27
{
28
if
(this->type == STRING)
29
{
30
free(this->data.strPtr);
31
}
32
}
33
34
bool
AttributeValue::operator==
(
const
AttributeValue
& other)
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
53
bool
AttributeValue::operator!=
(
const
AttributeValue
& other)
54
{
55
return
! (*
this
== other);
56
}
57
58
std::pair<AttributeValue::AttributeType, AttributeValue::DataUnion>
AttributeValue::getValue
()
59
{
60
return
{type,data};
61
}
62
63
bool
AttributeValue::isAValidAttributeValue
()
64
{
65
return
this->type != NOATRIB;
66
}
TS_CPP::AttributeValue
Definition
AttributeValue.h:19
TS_CPP::AttributeValue::getValue
std::pair< AttributeType, DataUnion > getValue()
Definition
AttributeValue.cpp:58
TS_CPP::AttributeValue::AttributeValue
AttributeValue(const char *strPtr)
Definition
AttributeValue.cpp:5
TS_CPP::AttributeValue::~AttributeValue
~AttributeValue()
Definition
AttributeValue.cpp:26
TS_CPP::AttributeValue::isAValidAttributeValue
bool isAValidAttributeValue()
Definition
AttributeValue.cpp:63
TS_CPP::AttributeValue::operator==
bool operator==(const AttributeValue &other)
Definition
AttributeValue.cpp:34
TS_CPP::AttributeValue::operator!=
bool operator!=(const AttributeValue &other)
Definition
AttributeValue.cpp:53
TS_CPP
Definition
AttributeValue.h:10
Include
AttributeValue.cpp
Generated by
1.11.0