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

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