/*
 * 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"


/**
 * SenchaObject stores values in SenchaLang. It handles operations on them, thanks to defined, overloaded operators.
 * Also provides representation of values.
 */
class SenchaObject : public Element {

public:
	/**
	 * Possible types of SenchaObject
	 */
	typedef enum {
		string_literal,
		integer_number,
		float_number,
		null,
		boolean,
		invalid
	} Type;

	Type type;

	/**
	 * repr() returns representation of value as a string
	 */
	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); }


	//Operators used in expressions
	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 operator-() const;
	virtual SenchaObject operator!() const;


	virtual ~SenchaObject();
};

#endif /* SENCHAOBJECT_H_ */
