Beispiel #1
0
void XSerializer<Space>::deserialize(Space& val, XValue const& xval)
{
	Handler<XObject> obj(xval.as<XObject>());
	val.top(obj->get<decltype(val.top())>("top"));
	val.left(obj->get<decltype(val.left())>("left"));
	val.right(obj->get<decltype(val.right())>("right"));
	val.bottom(obj->get<decltype(val.bottom())>("bottom"));
}
Beispiel #2
0
XValue XSerializer<Space>::serialize(Space& val)
{
	Handler<XObject> obj(new XObject);
	obj->set("right", val.right());
	obj->set("left", val.left());
	obj->set("top", val.top());
	obj->set("bottom", val.bottom());
	return obj;
}
Beispiel #3
0
TEST(GeomSerializeTest, SpaceVectorTest)
{
	XValue v;
	{
		Space area(0,2,4,6);
		XArchiverOut arc;
		arc << area;
		arc >> v;
	}
	{
		Space area;
		XArchiverIn in(v);
		in >> area;
		ASSERT_FLOAT_EQ(0, area.top());
		ASSERT_FLOAT_EQ(2, area.bottom());
		ASSERT_FLOAT_EQ(4, area.left());
		ASSERT_FLOAT_EQ(6, area.right());
	}
}
Beispiel #4
0
void parseAttr<Space>(std::string const& name, Space& v, Space const& def, tinyxml2::XMLElement* elm)
{
	float margin=0.0f;
	v=def;
	if(elm->QueryFloatAttribute(name.c_str(), &margin) == tinyxml2::XML_SUCCESS){
		v.margin(margin);
	}
	if(elm->QueryFloatAttribute((name+"-top").c_str(), &margin) == tinyxml2::XML_SUCCESS){
		v.top(margin);
	}
	if(elm->QueryFloatAttribute((name+"-left").c_str(), &margin) == tinyxml2::XML_SUCCESS){
		v.left(margin);
	}
	if(elm->QueryFloatAttribute((name+"-right").c_str(), &margin) == tinyxml2::XML_SUCCESS){
		v.right(margin);
	}
	if(elm->QueryFloatAttribute((name+"-bottom").c_str(), &margin) == tinyxml2::XML_SUCCESS){
		v.bottom(margin);
	}
}