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