Пример #1
0
const ImageMetadata* ObjectType::deserializeImageMetadata(const xml_node node) {
	const xml_attribute pathAttribute = node.attribute("path");
	const string path(pathAttribute.as_string());
	if (path.empty()) {
#ifdef ENABLE_LOGGING
		LOGGER->error("The \"path\" attribute is a required field for %s", node.path('/').c_str());
#endif
		exit(XML_SCHEMA_MISMATCH);
	}

	const xml_attribute widthAttribute = node.attribute("width");
	const int width = widthAttribute.as_int(-1);

	const xml_attribute heightAttribute = node.attribute("height");
	const int height = heightAttribute.as_int(-1);

	// if width or height is below zero, we assume this is a single image
	if (width < 0 || height < 0) {
		return new ImageMetadata(path);
	}

	const xml_attribute rowCountAttribute = node.attribute("rows");
	const int rowCount = rowCountAttribute.as_int(1);

	const xml_attribute columnCountAttribute = node.attribute("columns");
	const int columnCount = columnCountAttribute.as_int(1);

	return new ImageMetadata(path, width, height, rowCount, columnCount);
}
Пример #2
0
const ImageReference* ObjectType::deserializeImageReference(const xml_node node) {
	const xml_attribute idAttribute = node.attribute("id");
	const int id = idAttribute.as_int(0);

	const xml_attribute alphaAttribute = node.attribute("alpha");
	const int alpha = alphaAttribute.as_int(255);

	return new ImageReference(id, alpha);
}
Пример #3
0
const Sequence* ObjectType::deserializeSequence(const xml_node node) {
	const xml_attribute idAttribute = node.attribute("id");
	const int id = idAttribute.as_int();

	const xml_attribute nextAttribute = node.attribute("next");
	const int next = nextAttribute.as_int(0);

	auto const frames = new vector<const Frame*>();
	const auto frameNodes = node.children("frame");
	for (const xml_node frameNode : frameNodes) {
		auto const frame = deserializeFrame(frameNode);
		frames->push_back(frame);
	}

	return new Sequence(id, next, frames);
}
Пример #4
0
const Frame* ObjectType::deserializeFrame(const xml_node node) {
	const xml_attribute waitAttribute = node.attribute("wait");
	const int wait = waitAttribute.as_int(0);

	const xml_node imageReferenceNode = node.child("pic");
	const ImageReference* imageReference = deserializeImageReference(imageReferenceNode);

	return new Frame(wait, imageReference);
}