Example #1
0
AnyType::operator NumberType()
{
	if(type != TypeNumber)
		throw InvalidConversionException(type, TypeNumber);
	else
		return NumberType((int)value);
}
Example #2
0
AnyType::operator FloatType()
{
	if (type == TypeNumber)
		return FloatType(value.num);
	else if (type == TypeFloat)
		return FloatType(value.numf);
	else
		throw InvalidConversionException(type, TypeFloat);
}
Example #3
0
AnyType::operator PointType()
{
	if(type == TypePoint)
	{
		return PointType(*((ui::Point*)value));
	}
	else if(type == TypeString)
	{
		ui::Point thisPoint = *((ui::Point*)value);
		std::stringstream pointStream;
		pointStream << thisPoint.X << "," << thisPoint.Y;
		return StringType(pointStream.str());
	}
	else
		throw InvalidConversionException(type, TypePoint);
}
Example #4
0
AnyType::operator StringType()
{
	if(type == TypeNumber)
	{
		std::stringstream numberStream;
		numberStream << ((NumberType*)this)->Value();
		return StringType(numberStream.str());
	}
	else if(type == TypeString && value)
	{
		return StringType(*((std::string*)value));
	}
	else
		throw InvalidConversionException(type, TypeString);

}
Example #5
0
AnyType::operator PointType()
{
	if(type == TypePoint)
	{
		return PointType(*(value.pt));
	}
	else if(type == TypeString)
	{
		std::stringstream pointStream(*(value.str));
		int x, y;
		char comma;
		pointStream >> x >> comma >> y;
		if (pointStream.fail() || comma != ',')
			throw InvalidConversionException(type, TypePoint);
		return PointType(ui::Point(x, y));
	}
Example #6
0
AnyType::operator StringType()
{
	if(type == TypeNumber)
	{
		std::stringstream numberStream;
		numberStream << ((NumberType *)this)->Value();
		return StringType(numberStream.str());
	}
	else if(type == TypeString && value.str)
	{
		return StringType(*(value.str));
	}
	else if (type == TypePoint && value.pt)
	{
		ui::Point thisPoint = *(value.pt);
		std::stringstream pointStream;
		pointStream << thisPoint.X << "," << thisPoint.Y;
		return StringType(pointStream.str());
	}
	else
		throw InvalidConversionException(type, TypeString);

}