当前位置: 首页>>代码示例>>C++>>正文


C++ CL_DomElement类代码示例

本文整理汇总了C++中CL_DomElement的典型用法代码示例。如果您正苦于以下问题:C++ CL_DomElement类的具体用法?C++ CL_DomElement怎么用?C++ CL_DomElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CL_DomElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load_material

void CL_Collada_Material_Impl::load_material(CL_DomElement &material_element, std::vector<CL_Collada_Effect> &effects)
{
	id = material_element.get_attribute("id");

	CL_DomElement instance_effect_element = material_element.named_item("instance_effect").to_element();
	if (instance_effect_element.is_null())
		throw CL_Exception("Only instance_effect materials are supported");

	CL_String url = instance_effect_element.get_attribute("url");
	url = url.substr(1);	// Remove the initial '#' symbol

	std::vector<CL_Collada_Effect>::size_type size, cnt;
	size = effects.size();
	for (cnt=0; cnt< size; cnt++)
	{
		if (effects[cnt].get_id() == url)
		{
			effect = effects[cnt];
			break;
		}
	}

	if (effect.is_null())
		throw CL_Exception("Unable to find effect");

}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:26,代码来源:collada_material.cpp

示例2: named_item_ns

void CL_DomElement::set_child_string_ns(const CL_DomString &namespace_uri, const CL_DomString &qualified_name, const CL_DomString &value)
{
	CL_DomString local_name;
	CL_DomString::size_type pos = qualified_name.find(L':');
	if (pos != CL_DomString::npos)
		local_name = qualified_name.substr(pos+1);
	else
		local_name = qualified_name;

	CL_DomElement element = named_item_ns(namespace_uri, local_name).to_element();
	if (element.is_null())
	{
		element = get_owner_document().create_element_ns(namespace_uri, qualified_name);
		append_child(element);
	}

	CL_DomText dom_text = get_owner_document().create_text_node(value);
	if (element.get_first_child().is_text())
	{
		CL_DomNode temp_domnode = element.get_first_child();
		replace_child(dom_text, temp_domnode);
	}
	else
	{
		element.append_child(dom_text);
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:27,代码来源:dom_element.cpp

示例3: DEBUG_MSG

void BBN_Prob::load_from_xml(CL_DomElement element)
{
  DEBUG_MSG("BBN_Prob::load_from_xml(CL_DomElement) - Called.")

	_probability = CL_StringHelp::text_to_float(element.get_attribute("value"));
  DEBUG_MSG("BBN_Prob::load_from_xml(CL_DomElement) - Prob value = '" + CL_StringHelp::float_to_text(_probability) + "'.")

	_option = static_cast<CL_String8>(element.get_attribute("option"));
	DEBUG_MSG("BBN_Prob::load_from_xml(CL_DomElement) - Prob option = '" + _option + "'.")
}
开发者ID:aggronerd,项目名称:Mystery-Game,代码行数:10,代码来源:BBN_Prob.cpp

示例4: CL_Exception

void CL_Collada_Effect_Texture_Impl::load_texture(CL_DomElement &profile_element, CL_DomElement &newparam_element, CL_DomElement &sampler2d_element, std::vector<CL_Collada_Image> &library_images)
{
	sid = newparam_element.get_attribute("sid");

	CL_DomElement source_element = sampler2d_element.named_item("source").to_element();
	if (source_element.is_null())
		throw CL_Exception("source is missing");

	CL_String source_name = source_element.get_text();

	// Find the corresponding surface
	CL_DomElement surface_element;
	CL_DomNode cur_child(profile_element.get_first_child());
	while (!cur_child.is_null())
	{
			if(cur_child.get_node_name() == "newparam")
			{
				CL_DomElement newparam_element = cur_child.to_element();
				CL_String new_sid = newparam_element.get_attribute("sid");
				if (new_sid == source_name)
				{
					surface_element = newparam_element.named_item("surface").to_element();
					if (!surface_element.is_null())
						break;	// Found match
				}
			}
			cur_child = cur_child.get_next_sibling();
	}

	if (surface_element.is_null())
		throw CL_Exception("Cannot find the corresponding surface");

	CL_DomElement init_from_element = surface_element.named_item("init_from").to_element();
	if (init_from_element.is_null())
		throw CL_Exception("Only init_from surfaces are supported");

	CL_String image_name = init_from_element.get_text();

	unsigned int size = library_images.size();
	for (unsigned int cnt=0; cnt < size; cnt++)
	{
		if (library_images[cnt].get_id() == image_name)
		{
			image = library_images[cnt];
			break;
		}
	}
	if (image.is_null())
		throw CL_Exception("Cannot find requested image in the image library");

}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:51,代码来源:collada_effect_texture.cpp

示例5: load_primitive

void CL_Collada_Triangles_Impl::load_primitive(CL_DomElement &primitive_element)
{
	unsigned int count = stride * triangle_count * 3;

	primitive.resize(count);

	CL_String points = primitive_element.get_text();
	const CL_String::char_type *primitive_text = points.c_str();

	for (unsigned int cnt=0; cnt < count; cnt++)
	{
		if (!(*primitive_text))
			throw CL_Exception("Primitive data count mismatch");

		int value = atoi(primitive_text);
		primitive[cnt] = value;

		while(*primitive_text)
		{
			if (*(primitive_text++) <= ' ')	// Find whitespace
				break;
		}

		while(*primitive_text)
		{
			if ((*primitive_text) > ' ')	// Find end of whitespace
				break;
			primitive_text++;
		}

	}
	if (*primitive_text)
			throw CL_Exception("Primitive data count mismatch (end)");
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:34,代码来源:collada_triangles.cpp

示例6: validate_vcount

void CL_Collada_Triangles_Impl::validate_vcount(CL_DomElement &vcount_element)
{
	CL_String points = vcount_element.get_text();
	const CL_String::char_type *vcount_text = points.c_str();

	for (unsigned int cnt=0; cnt < triangle_count; cnt++)
	{
		if (!(*vcount_text))
			throw CL_Exception("VCount data count mismatch");

		int value = atoi(vcount_text);

		if (value != 3)
			throw CL_Exception("Only triangles are supported. Export your mesh as triangles please");

		while(*vcount_text)
		{
			if (*(vcount_text++) <= ' ')	// Find whitespace
				break;
		}

		while(*vcount_text)
		{
			if ((*vcount_text) > ' ')	// Find end of whitespace
				break;
			vcount_text++;
		}

	}
	if (*vcount_text)
			throw CL_Exception("VCount data count mismatch (end)");
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:32,代码来源:collada_triangles.cpp

示例7: CL_DomNode

CL_DomDocument::CL_DomDocument(
	const CL_DomString &namespace_uri,
	const CL_DomString &qualified_name,
	const CL_DomDocumentType &document_type)
: CL_DomNode(CL_SharedPtr<CL_DomNode_Generic>(new CL_DomDocument_Generic))
{
	impl->owner_document = impl;
	CL_DomElement element = create_element(qualified_name);
	element.set_attribute("xmlns:" + element.get_prefix(), qualified_name);
	append_child(element);

	CL_DomDocument_Generic *doc = dynamic_cast<CL_DomDocument_Generic *>(impl.get());
	const CL_DomDocument_Generic *doctype = dynamic_cast<const CL_DomDocument_Generic *>(document_type.impl.get());
	doc->public_id = doctype->public_id;
	doc->system_id = doctype->system_id;
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:16,代码来源:dom_document.cpp

示例8: mResource

SpriteResource::SpriteResource(CL_Resource &resource)
: mResource(resource)
{
	GAME_ASSERT(mResource.get_type() == "sprite");

	std::string basePath = mResource.get_manager().get_directory(mResource).get_file_system().get_path();
	for (CL_DomElement element = mResource.get_element().get_first_child_element(); !element.is_null(); element = element.get_next_sibling_element())
		if (element.get_tag_name() == "image")
		{
			std::string fileName = element.get_attribute("file");
			if (fileName.empty())
				throw Exception("Sprite '" + mResource.get_name() + "' has empty or missing 'file' attribute");
			mFrames.insert(std::make_pair(basePath + fileName, Frame(fileName)));
		}

	if (mFrames.empty())
		throw Exception("Sprite '" + mResource.get_name() + "' has no frames");
}
开发者ID:ermachkov,项目名称:Balance_GUI,代码行数:18,代码来源:SpriteResource.cpp

示例9: to_element

CL_DomString CL_DomNode::find_prefix(const CL_DomString &namespace_uri) const
{
	CL_DomElement cur = to_element();
	while (!cur.is_null())
	{
		CL_DomNamedNodeMap attributes = cur.get_attributes();
		int size = attributes.get_length();
		for (int index = 0; index < size; index++)
		{
			CL_DomNode attribute = attributes.item(index);
			if (attribute.get_prefix() == "xmlns" &&
				attribute.get_node_value() == namespace_uri)
			{
				return attribute.get_local_name();
			}
		}
		cur = cur.get_parent_node().to_element();
	}
	return CL_DomString();
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:20,代码来源:dom_node.cpp

示例10: cloneElement

//рекурсивное клонирование XML-элемента
CL_DomElement cloneElement(CL_DomElement &element, CL_DomDocument &doc)
{
	//создаем элемент-клон
	CL_DomElement clone(doc, element.get_tag_name());

	//копируем атрибуты
	CL_DomNamedNodeMap attributes = element.get_attributes();
	unsigned long length = attributes.get_length();
	for (unsigned long i = 0; i < length; ++i)
	{
		CL_DomNode attr = attributes.item(i);
		clone.set_attribute(attr.get_node_name(), attr.get_node_value());
	}

	//рекурсивно копируем дочерние элементы
	for (CL_DomElement child = element.get_first_child_element(); !child.is_null(); child = child.get_next_sibling_element())
		clone.append_child(cloneElement(child, doc));

	//возвращаем клонированный элемент
	return clone;
}
开发者ID:ermachkov,项目名称:bmgui,代码行数:22,代码来源:main.cpp

示例11: map_width

TileMap::TileMap(CL_GraphicContext& gc, CL_ResourceManager& resmgr, const CL_String& tileset)
: map_width(0), map_height(0), cur_map_x(0), cur_map_y(0) {
    CL_Resource res = resmgr.get_resource(tileset);

    if (res.get_type() != "tilemap")
        throw CL_Exception(cl_format("Resource %1 is not a tilemap", tileset));

    CL_DomElement element = res.get_element();
    levelname = element.get_attribute("name");
    CL_String resource_name = element.get_attribute("resource");
    map_width = element.get_attribute_int("width");
    map_height = element.get_attribute_int("height");

    tiles = CL_Sprite(gc, resource_name, &resmgr);
    float scalex, scaley;
    tiles.get_scale(scalex, scaley);
    tile_width = tiles.get_width() * scalex;
    tile_height = tiles.get_height() * scaley;

    auto layer_nodes = element.select_nodes("layer");
    for (CL_DomNode& idx : layer_nodes) {
        CL_DomElement layer_element = idx.to_element();

        CL_String layer_tiles = layer_element.get_first_child().get_node_value();
        std::vector<CL_String> tile_indices = CL_StringHelp::split_text(layer_tiles, ",");

        MapLayer layer;
        layer.map.reserve(tile_indices.size());
        for (auto& tile : tile_indices)
            layer.map.push_back(CL_StringHelp::text_to_int(tile));

        layers.push_back(layer);
    }
}
开发者ID:zeroshade,项目名称:ClanRPG,代码行数:34,代码来源:TileMap.cpp

示例12: resources

void TestApp::test_resources(void)
{
	CL_Console::write_line(" Header: resource.h");
	CL_Console::write_line("  Class: CL_Resource");

	// Construct resource manager. This will cause sig_resource_added() to be signalled for each
	// resource object located in the resource file. This means ResourceApp::on_resource_added will
	// get called for each resource.
	CL_ResourceManager resources("resources.xml");

	// Lets try to access some of the clanlib objects in the resource file:
	CL_String config_name = resources.get_string_resource("Configuration/name", "");
	int config_width = resources.get_integer_resource("Configuration/width", 0 );
	int config_height = resources.get_integer_resource("Configuration/height", 0 );

	CL_Console::write_line(CL_String("name = ") + config_name );
	CL_Console::write_line(CL_String("width = ") + CL_StringHelp::int_to_text(config_width));
	CL_Console::write_line(CL_String("height = ") + CL_StringHelp::int_to_text(config_height));

	// Get a list over all classes
	std::vector<CL_String> v = resources.get_resource_names_of_type("uclass", "Classes");
	std::vector<CL_String>::iterator it;
	for(it = v.begin(); it != v.end(); ++it)
	{
		// Get one of our custom resources:
		CL_Resource resource = resources.get_resource(*it);

		// Its possible to access the dom element object in the resource:
		CL_DomElement element = resource.get_element();
		int strength = CL_StringHelp::text_to_int(element.get_attribute("strength"));
		int magic = CL_StringHelp::text_to_int(element.get_attribute("magic"));

		CL_Console::write_line(CL_String("\n") + "name = " + resource.get_name());
		CL_Console::write_line(CL_String("strength = ") + CL_StringHelp::int_to_text(strength));
		CL_Console::write_line(CL_String("magic = ") + CL_StringHelp::int_to_text(magic) );
	}

}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:38,代码来源:test_resources.cpp

示例13: assert

void Level::loadFromFile(const CL_String& p_filename)
{
	assert(!m_loaded && "level is already loaded");

	try {
		CL_File file(p_filename, CL_File::open_existing, CL_File::access_read);


		CL_DomDocument document(file);
		const CL_DomElement root = document.get_document_element();

		// load meta element
		const CL_DomNode metaNode = root.named_item("meta");
		loadMetaElement(metaNode);

		// gets level's content
		const CL_DomNode contentNode = root.named_item("content");

		// load sand
		const CL_DomNode sandNode = contentNode.named_item("sand");
		loadSandElement(sandNode);

		// load track
		const CL_DomNode trackNode = contentNode.named_item("track");
		loadTrackElement(trackNode);

		// load track bounds
		const CL_DomNode boundsNode = contentNode.named_item("bounds");
		loadBoundsElement(boundsNode);

		file.close();
		m_loaded = true;

	} catch (CL_Exception e) {
		CL_Console::write_line(e.message);
	}

}
开发者ID:ryba616,项目名称:ryba.racer,代码行数:38,代码来源:Level.cpp

示例14: impl

CL_Collada_Triangles::CL_Collada_Triangles(CL_DomElement &element, std::vector<CL_Collada_Source> &sources, CL_Collada_Vertices &vertices, std::vector<CL_Collada_Material> &library_materials) : impl(new CL_Collada_Triangles_Impl())
{
	bool contains_vcount;
	if (element.get_tag_name() == "polylist")
	{
		contains_vcount = true;
	}
	else
	{
		contains_vcount = false;
	}

	impl->load_polylist(element, contains_vcount, sources, vertices, library_materials);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:14,代码来源:collada_triangles.cpp

示例15: CL_Exception

void ReferenceFunction::load(CL_String member_name, CL_DomElement class_element)
{
	if (class_element.get_tag_name() != "compounddef")
		throw CL_Exception("Expected compounddef element");

	name = member_name;

	CL_DomNode cur_node;
	for (cur_node = class_element.get_first_child(); !cur_node.is_null(); cur_node = cur_node.get_next_sibling())
	{
		CL_DomElement cur_element = cur_node.to_element();
		if (cur_element.is_null()) continue;

		CL_String tag_name = cur_element.get_tag_name();
		if ( (tag_name == "sectiondef") && (
			(cur_element.get_attribute("kind") == "user-defined") ||
			(cur_element.get_attribute("kind") == "public-func") ||
			(cur_element.get_attribute("kind") == "public-static-func") ) )
		{
			parse_sectiondef(cur_element);
		}
	}
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:23,代码来源:reference_function.cpp


注:本文中的CL_DomElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。