#include "tk_doubleoption.h"
#include "../../tcl_interp.h"

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

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

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

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

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

TkDoubleOption::TkDoubleOption(double value)
{
	this->value=value;
}

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

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