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

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