| Leonetienne/Hazelnupp Simple, easy to use, command line parameter interface

FloatValue.cpp
Go to the documentation of this file.
1 #include "FloatValue.h"
2 #include "HazelnuppException.h"
3 #include <sstream>
4
5 using namespace Hazelnp;
6
7 FloatValue::FloatValue(const long double& value)
8 :
9 Value(DATA_TYPE::FLOAT),
10 value { value }
11 {
12 return;
13 }
14
15 Value* FloatValue::Deepcopy() const
16 {
17 return new FloatValue(value);
18 }
19
20 std::string FloatValue::GetAsOsString() const
21 {
22 std::stringstream ss;
23 ss << "FloatValue: " << value;
24 return ss.str();
25 }
26
27 const long double& FloatValue::GetValue() const
28 {
29 return value;
30 }
31
32 FloatValue::operator long double() const
33 {
34 return value;
35 }
36
37 FloatValue::operator double() const
38 {
39 return (double)value;
40 }
41
42
43
44 long long int FloatValue::GetInt64() const
45 {
46 return (long long int)value;
47 }
48
49 int FloatValue::GetInt32() const
50 {
51 return (int)value;
52 }
53
54 long double FloatValue::GetFloat64() const
55 {
56 return value;
57 }
58
59 double FloatValue::GetFloat32() const
60 {
61 return (double)value;
62 }
63
64 std::string FloatValue::GetString() const
65 {
66 std::stringstream ss;
67 ss << value;
68
69 return ss.str();
70 }
71
72 const std::vector<Value*>& FloatValue::GetList() const
73 {
74 throw HazelnuppValueNotConvertibleException();
75 }
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:9
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