Leonetienne/Hazelnupp
Simple, easy to use, command line parameter interface
ListValue.cpp
Go to the documentation of this file.
3#include <sstream>
4
5using namespace Hazelnp;
6
7ListValue::ListValue() :
9{
10 return;
11}
12
14{
15 for (Value* val : value)
16 delete val;
17
18 value.clear();
19
20 return;
21}
22
24{
25 ListValue* newList = new ListValue();
26
27 for (const Value* val : value)
28 newList->AddValue(val);
29
30 return newList;
31}
32
33void ListValue::AddValue(const Value* value)
34{
35 this->value.emplace_back(value->Deepcopy());
36 return;
37}
38
39const std::vector<Value*>& ListValue::GetValue() const
40{
41 return value;
42}
43
44std::string ListValue::GetAsOsString() const
45{
46 std::stringstream ss;
47
48 ss << "ListValue: [";
49
50 for (const Value* val : value)
51 {
52 ss << *val;
53 if (val != value.back())
54 ss << ", ";
55 }
56
57 ss << "]";
58
59 return ss.str();
60}
61
62ListValue::operator std::vector<Value*>() const
63{
64 return value;
65}
66
67
68
69long long int ListValue::GetInt64() const
70{
72}
73
75{
77}
78
79long double ListValue::GetFloat64() const
80{
82}
83
85{
87}
88
89std::string ListValue::GetString() const
90{
92}
93
94const std::vector<Value*>& ListValue::GetList() const
95{
96 return value;
97}
Gets thrown when an attempt is made to retrieve the wrong data type from a value, when the value not ...
Specializations for list values (uses std::vector<Value*>)
Definition: ListValue.h:10
Value * Deepcopy() const override
Will return a deeopopy of this object.
Definition: ListValue.cpp:23
int GetInt32() const override
Throws HazelnuppValueNotConvertibleException.
Definition: ListValue.cpp:74
long double GetFloat64() const override
Throws HazelnuppValueNotConvertibleException.
Definition: ListValue.cpp:79
std::string GetAsOsString() const override
Will return a string suitable for an std::ostream;.
Definition: ListValue.cpp:44
double GetFloat32() const override
Throws HazelnuppValueNotConvertibleException.
Definition: ListValue.cpp:84
const std::vector< Value * > & GetValue() const
Will return the raw value.
Definition: ListValue.cpp:39
~ListValue() override
Definition: ListValue.cpp:13
long long int GetInt64() const override
Throws HazelnuppValueNotConvertibleException.
Definition: ListValue.cpp:69
const std::vector< Value * > & GetList() const override
Will return this values list.
Definition: ListValue.cpp:94
std::string GetString() const override
Throws HazelnuppValueNotConvertibleException.
Definition: ListValue.cpp:89
void AddValue(const Value *value)
Will add this value to the list.
Definition: ListValue.cpp:33
Abstract class for values.
Definition: Value.h:11
virtual Value * Deepcopy() const =0
Will return a deeopopy of this object.
DATA_TYPE
The different data types a paramater can be.
Definition: DataType.h:9