summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/AST/SenchaObject.h
blob: 70cadfc8ad7dc03ae1ff14f3163e34d2797a0dab (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
/*
 * SenchaObject.h
 *
 *  Created on: Dec 5, 2012
 *      Author: attero
 */

#ifndef SENCHAOBJECT_H_
#define SENCHAOBJECT_H_
#include <string>
class SenchaObject {

public:
	typedef enum {
		string_literal,
		integer_number,
		float_number,
		null,
		invalid
	} Type;

	Type type;


	std::string text;
	int integer;
	double number;

	void set_value(std::string text)
	{
		this->text = text;
		type = string_literal;
	}

	void set_null_value()
	{
		this->type = null;
		this->integer = 0;
		this->number = 0;
		this->text = "";
	}

	void set_value(int integer)
	{
		this->integer = integer;
		type = integer_number;
	}

	void set_value(double number)
	{
		this->number = number;
		type = float_number;
	}

	SenchaObject();
	SenchaObject(int integer) { set_value(integer); }
	SenchaObject(float number) { set_value(number); }
	SenchaObject(std::string text) { set_value(text); }

	//TODO overload operators as it should be done

	virtual SenchaObject operator+(const SenchaObject& right)const;

	virtual SenchaObject operator-(const SenchaObject& right)const { return SenchaObject(); };
	virtual ~SenchaObject();
};

#endif /* SENCHAOBJECT_H_ */