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

#ifndef SENCHAOBJECT_H_
#define SENCHAOBJECT_H_
#include <string>
#include <iostream>
#include "../Utils/to_string.h"
#include "Element.h"

class SenchaObject : public Element {

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

	Type type;

	virtual std::string repr();
	virtual std::string str();
	virtual bool is_true();

	std::string text;
	std::string name;
	bool truthy;
	int integer;
	double number;

	void set_value(std::string text);
	void set_new_string(std::string text);
	void set_null_value();
	void set_value(int integer);
	void set_value(double number);
	void set_value(bool logic);

	SenchaObject();
	SenchaObject(int integer) { set_value(integer); }
	SenchaObject(bool truthy) {set_value(truthy); }
	SenchaObject(double number) { set_value(number); }
	SenchaObject(std::string text) { set_value(text); }


	virtual SenchaObject operator< (const SenchaObject& right)const;
	virtual SenchaObject operator> (const SenchaObject& right)const;
	virtual SenchaObject operator<= (const SenchaObject& right)const;
	virtual SenchaObject operator>= (const SenchaObject& right)const;
	virtual SenchaObject operator+(const SenchaObject& right)const;
	virtual SenchaObject operator-(const SenchaObject& right)const;
	virtual SenchaObject operator*(const SenchaObject& right)const;
	virtual SenchaObject operator/(const SenchaObject& right)const;
	virtual SenchaObject operator==(const SenchaObject& right)const;
	virtual SenchaObject operator!=(const SenchaObject& right)const;



	virtual ~SenchaObject();
};

#endif /* SENCHAOBJECT_H_ */