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