#include "tk_intoption.h"
#include "../../tcl_interp.h"

const char* TkIntOption::type="TkIntOption";

const char* TkIntOption::getType() const
{
	return type;
}

void TkIntOption::doSerialize(TiXmlElement& element) const
{
	element.SetAttribute("value",value);
}

void TkIntOption::doDeserialize(const TiXmlElement& element)
{
	element.Attribute("value",&value);
}

TkIntOption::TkIntOption()
{
	this->value=0;
}

TkIntOption::TkIntOption(int value)
{
	this->value=value;
}

const string& TkIntOption::toString() const
{
	char buf[128];
	sprintf(buf,"%d",value);
	return *(new string(buf));
}

void TkIntOption::fromObject(Tcl_Obj* object)
{
	Tcl_GetIntFromObj(TclInterp::defaultInterp->getInterp(),object,&value);
}
