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 FloatValue::FloatValue(const long double& value)
6  :
8  value { value }
9 {
10  return;
11 }
12 
14 {
15  return new FloatValue(value);
16 }
17 
18 std::string FloatValue::GetAsOsString() const
19 {
20  std::stringstream ss;
21  ss << "FloatValue: " << value;
22  return ss.str();
23 }
24 
25 const long double& FloatValue::GetValue() const
26 {
27  return value;
28 }
29 
30 FloatValue::operator long double() const
31 {
32  return value;
33 }
34 
35 FloatValue::operator double() const
36 {
37  return (double)value;
38 }
39 
40 
41 
42 long long int FloatValue::GetInt64() const
43 {
44  return (long long int)value;
45 }
46 
48 {
49  return (int)value;
50 }
51 
52 long double FloatValue::GetFloat64() const
53 {
54  return value;
55 }
56 
57 double FloatValue::GetFloat32() const
58 {
59  return (double)value;
60 }
61 
62 std::string FloatValue::GetString() const
63 {
64  std::stringstream ss;
65  ss << value;
66 
67  return ss.str();
68 }
69 
70 const std::vector<Value*>& FloatValue::GetList() const
71 {
73 }
HazelnuppException.h
DATA_TYPE
DATA_TYPE
The different data types a paramater can be.
Definition: DataType.h:5
FloatValue::GetValue
const long double & GetValue() const
Will return the raw value.
Definition: FloatValue.cpp:25
DATA_TYPE::FLOAT
@ FLOAT
Value
Abstract class for values.
Definition: Value.h:8
FloatValue::GetString
std::string GetString() const override
Will return the data as a string.
Definition: FloatValue.cpp:62
FloatValue::Deepcopy
Value * Deepcopy() const override
Will return a deeopopy of this object.
Definition: FloatValue.cpp:13
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
FloatValue::GetAsOsString
std::string GetAsOsString() const override
Will return a string suitable for an std::ostream;.
Definition: FloatValue.cpp:18
FloatValue::GetFloat64
long double GetFloat64() const override
Will return the data as a long double.
Definition: FloatValue.cpp:52
FloatValue::FloatValue
FloatValue(const long double &value)
Definition: FloatValue.cpp:5
FloatValue::GetInt32
int GetInt32() const override
Will return the data as an int.
Definition: FloatValue.cpp:47
FloatValue.h
FloatValue::GetInt64
long long int GetInt64() const override
Will return the data as a long long int.
Definition: FloatValue.cpp:42
FloatValue::GetList
const std::vector< Value * > & GetList() const override
Throws HazelnuppValueNotConvertibleException.
Definition: FloatValue.cpp:70
FloatValue::GetFloat32
double GetFloat32() const override
Will return the data as a double.
Definition: FloatValue.cpp:57