ListValue.cpp
Go to the documentation of this file.
#include "ListValue.h"
#include "HazelnuppException.h"
#include <sstream>
using namespace Hazelnp;
ListValue::ListValue() :
Value(DATA_TYPE::LIST)
{
return;
}
ListValue::~ListValue()
{
for (Value* val : value)
delete val;
value.clear();
return;
}
Value* ListValue::Deepcopy() const
{
ListValue* newList = new ListValue();
for (const Value* val : value)
newList->AddValue(val);
return newList;
}
void ListValue::AddValue(const Value* value)
{
this->value.emplace_back(value->Deepcopy());
return;
}
const std::vector<Value*>& ListValue::GetValue() const
{
return value;
}
std::string ListValue::GetAsOsString() const
{
std::stringstream ss;
ss << "ListValue: [";
for (const Value* val : value)
{
ss << *val;
if (val != value.back())
ss << ", ";
}
ss << "]";
return ss.str();
}
ListValue::operator std::vector<Value*>() const
{
return value;
}
long long int ListValue::GetInt64() const
{
throw HazelnuppValueNotConvertibleException();
}
int ListValue::GetInt32() const
{
throw HazelnuppValueNotConvertibleException();
}
long double ListValue::GetFloat64() const
{
throw HazelnuppValueNotConvertibleException();
}
double ListValue::GetFloat32() const
{
throw HazelnuppValueNotConvertibleException();
}
std::string ListValue::GetString() const
{
throw HazelnuppValueNotConvertibleException();
}
const std::vector<Value*>& ListValue::GetList() const
{
return value;
}
Hazelnp::ListValue::GetAsOsString
std::string GetAsOsString() const override
Will return a string suitable for an std::ostream;.
Definition: ListValue.cpp:44
HazelnuppException.h
Hazelnp
Definition: DataType.h:3
Hazelnp::ListValue::GetFloat32
double GetFloat32() const override
Throws HazelnuppValueNotConvertibleException.
Definition: ListValue.cpp:84
Hazelnp::ListValue::GetString
std::string GetString() const override
Throws HazelnuppValueNotConvertibleException.
Definition: ListValue.cpp:89
Hazelnp::ListValue::GetList
const std::vector< Value * > & GetList() const override
Will return this values list.
Definition: ListValue.cpp:94
Hazelnp::ListValue::GetValue
const std::vector< Value * > & GetValue() const
Will return the raw value.
Definition: ListValue.cpp:39
Hazelnp::Value
Abstract class for values.
Definition: Value.h:10
Hazelnp::DATA_TYPE::LIST
@ LIST
Hazelnp::ListValue::GetInt64
long long int GetInt64() const override
Throws HazelnuppValueNotConvertibleException.
Definition: ListValue.cpp:69
Hazelnp::ListValue::GetInt32
int GetInt32() const override
Throws HazelnuppValueNotConvertibleException.
Definition: ListValue.cpp:74
ListValue.h
Hazelnp::ListValue::AddValue
void AddValue(const Value *value)
Will add this value to the list.
Definition: ListValue.cpp:33
Hazelnp::ListValue::~ListValue
~ListValue() override
Definition: ListValue.cpp:13
Hazelnp::DATA_TYPE
DATA_TYPE
The different data types a paramater can be.
Definition: DataType.h:7
Hazelnp::ListValue::ListValue
ListValue()
Definition: ListValue.cpp:7
Hazelnp::ListValue::Deepcopy
Value * Deepcopy() const override
Will return a deeopopy of this object.
Definition: ListValue.cpp:23
Hazelnp::Value::Deepcopy
virtual Value * Deepcopy() const =0
Will return a deeopopy of this object.
Hazelnp::ListValue::GetFloat64
long double GetFloat64() const override
Throws HazelnuppValueNotConvertibleException.
Definition: ListValue.cpp:79
Hazelnp::ListValue
Specializations for list values (uses std::vector<Value*>)
Definition: ListValue.h:9
Hazelnp::HazelnuppValueNotConvertibleException
Gets thrown when an attempt is made to retrieve the wrong data type from a value, when the value not ...
Definition: HazelnuppException.h:35