/*
 * SenchaObject.h
 *
 *  Created on: Dec 5, 2012
 *      Author: attero
 */

#ifndef SENCHAOBJECT_H_
#define SENCHAOBJECT_H_
#include <string>
#include <iostream>
#include "to_string.h"
class SenchaObject {

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

	Type type;

	virtual std::string repr();

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

	void set_value(std::string text)
	{
		if(text[0] == '\"' && text[text.size()-1] == '\"')
		{
			this->text = text.substr(1, text.size()-2);
			type = string_literal;
		}
	}

	void set_new_string(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;
	}

	void set_value(bool logic)
	{
		this->truthy = logic;
		type = boolean;
	}

	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); }

	//TODO overload operators as it should be done

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