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
6namespace 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:
47
49 };
50}
Abstract class for values.
Definition: Value.h:11
virtual std::string GetString() const =0
Will attempt to return the string-data.
virtual int GetInt32() const =0
Will attempt to return the integer data (int)
friend std::ostream & operator<<(std::ostream &os, const Value &v)
Definition: Value.h:24
virtual const std::vector< Value * > & GetList() const =0
Will attempt to return the list-data.
virtual double GetFloat32() const =0
Will attempt to return the floating-point data (double)
Value(DATA_TYPE type)
Definition: Value.cpp:5
virtual long long int GetInt64() const =0
Will attempt to return the integer data (long long)
virtual ~Value()
Definition: Value.h:13
virtual Value * Deepcopy() const =0
Will return a deeopopy of this object.
DATA_TYPE GetDataType() const
Will return the data type of this value.
Definition: Value.cpp:12
virtual std::string GetAsOsString() const =0
Will return a string suitable for an std::ostream.
DATA_TYPE type
Definition: Value.h:48
virtual long double GetFloat64() const =0
Will attempt to return the floating-point data (long double)
DATA_TYPE
The different data types a paramater can be.
Definition: DataType.h:9