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

Value.h
Go to the documentation of this file.
1 #pragma once
2 #include "DataType.h"
3 #include <ostream>
4 #include <vector>
5
6 namespace Hazelnp
7 {
8 /** Abstract class for values
9 */
10 class Value
11 {
12 public:
13 virtual ~Value() {};
14
15 //! Will return a deeopopy of this object
16 virtual Value* Deepcopy() const = 0;
17
18 //! Will return a string suitable for an std::ostream
19 virtual std::string GetAsOsString() const = 0;
20
21 //! Will return the data type of this value
22 DATA_TYPE GetDataType() const;
23
24 friend std::ostream& operator<< (std::ostream& os, const Value& v)
25 {
26 return os << v.GetAsOsString();
27 }
28
29 //! Will attempt to return the integer data (long long)
30 virtual long long int GetInt64() const = 0;
31 //! Will attempt to return the integer data (int)
32 virtual int GetInt32() const = 0;
33
34 //! Will attempt to return the floating-point data (long double)
35 virtual long double GetFloat64() const = 0;
36 //! Will attempt to return the floating-point data (double)
37 virtual double GetFloat32() const = 0;
38
39 //! Will attempt to return the string-data
40 virtual std::string GetString() const = 0;
41
42 //! Will attempt to return the list-data
43 virtual const std::vector<Value*>& GetList() const = 0;
44
45 protected:
46 Value(DATA_TYPE type);
47
48 DATA_TYPE type;
49 };
50 }
Hazelnp
Definition: CmdArgsInterface.h:7
DataType.h
Hazelnp::Value::GetFloat32
virtual double GetFloat32() const =0
Will attempt to return the floating-point data (double)
Hazelnp::Value
Abstract class for values.
Definition: Value.h:10
Hazelnp::Value::GetInt32
virtual int GetInt32() const =0
Will attempt to return the integer data (int)
Hazelnp::Value::GetString
virtual std::string GetString() const =0
Will attempt to return the string-data.
Hazelnp::Value::~Value
virtual ~Value()
Definition: Value.h:13
Hazelnp::Value::Value
Value(DATA_TYPE type)
Definition: Value.cpp:5
Hazelnp::Value::GetDataType
DATA_TYPE GetDataType() const
Will return the data type of this value.
Definition: Value.cpp:12
Hazelnp::Value::GetInt64
virtual long long int GetInt64() const =0
Will attempt to return the integer data (long long)
Hazelnp::Value::GetAsOsString
virtual std::string GetAsOsString() const =0
Will return a string suitable for an std::ostream.
Hazelnp::Value::GetList
virtual const std::vector< Value * > & GetList() const =0
Will attempt to return the list-data.
Hazelnp::Value::operator<<
friend std::ostream & operator<<(std::ostream &os, const Value &v)
Definition: Value.h:24
Hazelnp::DATA_TYPE
DATA_TYPE
The different data types a paramater can be.
Definition: DataType.h:8
Hazelnp::Value::type
DATA_TYPE type
Definition: Value.h:48
Hazelnp::Value::Deepcopy
virtual Value * Deepcopy() const =0
Will return a deeopopy of this object.
Hazelnp::Value::GetFloat64
virtual long double GetFloat64() const =0
Will attempt to return the floating-point data (long double)