summaryrefslogtreecommitdiff
path: root/src/value.h
blob: 20034609c044a6756f4bd94626bce5a3d41cc1cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef VALUE_H_
#define VALUE_H_

#include <vector>
#include <string>

class Value
{
public:
	enum type_e {
		UNDEFINED,
		BOOL,
		NUMBER,
		RANGE,
		VECTOR,
		STRING
	};

	enum type_e type;

	bool b;
	double num;
	std::vector<Value*> vec;
	double range_begin;
	double range_step;
	double range_end;
	std::string text;

	Value();
	~Value();

	Value(bool v);
	Value(double v);
	Value(const std::string &t);

	Value(const Value &v);
	Value& operator = (const Value &v);

	Value operator ! () const;
	Value operator && (const Value &v) const;
	Value operator || (const Value &v) const;

	Value operator + (const Value &v) const;
	Value operator - (const Value &v) const;
	Value operator * (const Value &v) const;
	Value operator / (const Value &v) const;
	Value operator % (const Value &v) const;

	Value operator < (const Value &v) const;
	Value operator <= (const Value &v) const;
	Value operator == (const Value &v) const;
	Value operator != (const Value &v) const;
	Value operator >= (const Value &v) const;
	Value operator > (const Value &v) const;

	Value inv() const;

	bool getnum(double &v) const;
	bool getv2(double &x, double &y) const;
	bool getv3(double &x, double &y, double &z) const;

	std::string toString() const;

	void append(Value *val);

private:
	void reset_undef();
};

std::ostream &operator<<(std::ostream &stream, const Value &value);

#endif
contact: Jan Huwald // Impressum