# Leonetienne/Hazelnupp: Hazelnupp/FloatValue.cpp Source File

FloatValue.cpp
Go to the documentation of this file.
#include "FloatValue.h"
#include "HazelnuppException.h"
#include <sstream>
using namespace Hazelnp;
FloatValue::FloatValue(const long double& value)
:
Value(DATA_TYPE::FLOAT),
value { value }
{
return;
}
Value* FloatValue::Deepcopy() const
{
return new FloatValue(value);
}
std::string FloatValue::GetAsOsString() const
{
std::stringstream ss;
ss << "FloatValue: " << value;
return ss.str();
}
const long double& FloatValue::GetValue() const
{
return value;
}
FloatValue::operator long double() const
{
return value;
}
FloatValue::operator double() const
{
return (double)value;
}
long long int FloatValue::GetInt64() const
{
return (long long int)value;
}
int FloatValue::GetInt32() const
{
return (int)value;
}
long double FloatValue::GetFloat64() const
{
return value;
}
double FloatValue::GetFloat32() const
{
return (double)value;
}
std::string FloatValue::GetString() const
{
std::stringstream ss;
ss << value;
return ss.str();
}
const std::vector<Value*>& FloatValue::GetList() const
{
throw HazelnuppValueNotConvertibleException();
}
Hazelnp::FloatValue::GetFloat64
long double GetFloat64() const override
Will return the data as a long double.
Definition: FloatValue.cpp:54
HazelnuppException.h
Hazelnp
Definition: CmdArgsInterface.h:7
Hazelnp::FloatValue::GetString
std::string GetString() const override
Will return the data as a string.
Definition: FloatValue.cpp:64
Hazelnp::FloatValue::GetList
const std::vector< Value * > & GetList() const override
Throws HazelnuppValueNotConvertibleException.
Definition: FloatValue.cpp:72
Hazelnp::FloatValue::GetInt64
long long int GetInt64() const override
Will return the data as a long long int.
Definition: FloatValue.cpp:44
Hazelnp::FloatValue::GetAsOsString
std::string GetAsOsString() const override
Will return a string suitable for an std::ostream;.
Definition: FloatValue.cpp:20
Hazelnp::FloatValue::GetValue
const long double & GetValue() const
Will return the raw value.
Definition: FloatValue.cpp:27
Hazelnp::Value
Abstract class for values.
Definition: Value.h:10
Hazelnp::FloatValue::Deepcopy
Value * Deepcopy() const override
Will return a deeopopy of this object.
Definition: FloatValue.cpp:15
Hazelnp::FloatValue::GetFloat32
double GetFloat32() const override
Will return the data as a double.
Definition: FloatValue.cpp:59
Hazelnp::DATA_TYPE::FLOAT
@ FLOAT
FloatValue.h
Hazelnp::DATA_TYPE
DATA_TYPE
The different data types a paramater can be.
Definition: DataType.h:8
Hazelnp::FloatValue::FloatValue
FloatValue(const long double &value)
Definition: FloatValue.cpp:7
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:38
Hazelnp::FloatValue::GetInt32
int GetInt32() const override
Will return the data as an int.
Definition: FloatValue.cpp:49