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


C++ DomNode类代码示例

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


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

示例1: is_null

	bool DomNode::operator ==(const DomNode &other) const
	{
		if (is_null() || other.is_null())
			return is_null() == other.is_null();
		else
			return impl->node_index == other.impl->node_index;
	}
开发者ID:keigen-shu,项目名称:ClanLib,代码行数:7,代码来源:dom_node.cpp

示例2: get_next_sibling

	DomElement DomElement::get_next_sibling_element() const
	{
		DomNode node = get_next_sibling();
		while (!node.is_null() && !node.is_element())
			node = node.get_next_sibling();
		return node.to_element();
	}
开发者ID:keigen-shu,项目名称:ClanLib,代码行数:7,代码来源:dom_element.cpp

示例3: while

void TexturePacker::process_resource(Canvas &canvas, Resource &item_resource, std::vector<Subtexture> &packed_sub_textures, std::map<Texture, std::string> &generated_texture_filenames, int &generated_texture_index, const std::string &image_pathname )
{
	// Found a sprite resource, lets modify its content!
	Resource resource = item_resource;

	// Iterate through all nodes, and remove all previous image tags
	DomElement &element = resource.get_element();
	DomNode cur = element.get_first_child();
	while (!cur.is_null())
	{
		DomNode next = cur.get_next_sibling();
		DomNode::NodeType nodeType = (DomNode::NodeType)cur.get_node_type();

		// Only remove the <image> tag, as we want to keep the other sprite attributes
		if (cur.get_node_name() == "image")
			element.remove_child(cur);

		cur = next;
	}

	// Add new image tag to resource DOM
	std::vector<Subtexture>::size_type index, size;
	size = packed_sub_textures.size();
	for(index = 0; index < size; ++index)
	{
		Subtexture subtexture = packed_sub_textures[index];

		// Try to find out if we already have created a texture-on-disk for this subtexture
		std::string texture_filename;
		Texture2D texture = subtexture.get_texture();
		std::map<Texture, std::string>::iterator it;
		it = generated_texture_filenames.find(texture);
		if(it == generated_texture_filenames.end())
		{
			// Texture not found, generate a filename and dump texture to disk
			texture_filename = string_format("texture%1.png", ++generated_texture_index);
			PNGProvider::save(texture.get_pixeldata(canvas), image_pathname + texture_filename);
			generated_texture_filenames[texture] = texture_filename;
		}
		else
		{
			// Previously dumped textures, lets reuse the filename
			texture_filename = (*it).second;
		}

		// Add <grid> DOM element
		DomElement new_grid_element = element.get_owner_document().create_element("grid");
		new_grid_element.set_attribute("pos", string_format("%1,%2", subtexture.get_geometry().left + last_border_size, subtexture.get_geometry().top + last_border_size));
		new_grid_element.set_attribute("size", string_format("%1,%2", subtexture.get_geometry().get_width()- last_border_size*2, subtexture.get_geometry().get_height()- last_border_size*2));

		// Add <image> DOM element
		DomElement new_image_element = element.get_owner_document().create_element("image");
		new_image_element.set_attribute("file", texture_filename);
		new_image_element.append_child(new_grid_element);

		// Add <image> element under <sprite> element
		element.append_child(new_image_element);
	}
}
开发者ID:authenticate,项目名称:ClanLib,代码行数:59,代码来源:texture_packer.cpp

示例4: select_node

	std::string DomNode::select_string(const DomString &xpath_expression) const
	{
		DomNode node = select_node(xpath_expression);
		if (node.is_element())
			return node.to_element().get_text();
		else
			return node.get_node_value();
	}
开发者ID:keigen-shu,项目名称:ClanLib,代码行数:8,代码来源:dom_node.cpp

示例5: DomNode

DomNode DomNamedNodeMap::set_named_item_ns(const DomNode &node)
{
	if (!impl)
		return DomNode();
	DomDocument_Impl *doc_impl = (DomDocument_Impl *) impl->owner_document.lock().get();
	DomString namespace_uri = node.get_namespace_uri();
	DomString local_name = node.get_local_name();
	DomTreeNode *new_tree_node = (DomTreeNode *) node.impl->get_tree_node();
	DomTreeNode *tree_node = impl->get_tree_node();
	if (new_tree_node == tree_node)
		return node;
	unsigned int cur_index = tree_node->first_attribute;
	unsigned int last_index = cl_null_node_index;
	DomTreeNode *cur_attribute = tree_node->get_first_attribute(doc_impl);
	while (cur_attribute)
	{
		std::string lname = cur_attribute->get_node_name();
		std::string::size_type lpos = lname.find_first_of(':');
		if (lpos != std::string::npos)
			lname = lname.substr(lpos + 1);

		if (cur_attribute->get_namespace_uri() == namespace_uri && lname == local_name)
		{
			new_tree_node->parent = cur_attribute->parent;
			new_tree_node->previous_sibling = cur_attribute->previous_sibling;
			new_tree_node->next_sibling = cur_attribute->next_sibling;
			if (cur_attribute->previous_sibling == cl_null_node_index)
				tree_node->first_attribute = node.impl->node_index;
			else
				cur_attribute->get_previous_sibling(doc_impl)->next_sibling = node.impl->node_index;
			if (cur_attribute->next_sibling != cl_null_node_index)
				cur_attribute->get_next_sibling(doc_impl)->previous_sibling = node.impl->node_index;
			cur_attribute->parent = cl_null_node_index;
			cur_attribute->previous_sibling = cl_null_node_index;
			cur_attribute->next_sibling = cl_null_node_index;
			return node;
		}
		last_index = cur_index;
		cur_index = cur_attribute->next_sibling;
		cur_attribute = cur_attribute->get_next_sibling(doc_impl);
	}
	if (last_index == cl_null_node_index)
	{
		tree_node->first_attribute = node.impl->node_index;
		new_tree_node->parent = impl->node_index;
		new_tree_node->previous_sibling = cl_null_node_index;
		new_tree_node->next_sibling = cl_null_node_index;
	}
	else
	{
		new_tree_node->parent = impl->node_index;
		new_tree_node->previous_sibling = last_index;
		new_tree_node->next_sibling = cl_null_node_index;
		doc_impl->nodes[last_index]->next_sibling = node.impl->node_index;
	}
	return node;
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:57,代码来源:dom_named_node_map.cpp

示例6: get_first_child

	DomNode DomNode::named_item(const DomString &name) const
	{
		DomNode node = get_first_child();
		while (node.is_null() == false)
		{
			if (node.get_node_name() == name) return node;
			node = node.get_next_sibling();
		}
		return DomNode();
	}
开发者ID:keigen-shu,项目名称:ClanLib,代码行数:10,代码来源:dom_node.cpp

示例7: get_attributes

	bool DomElement::has_attribute_ns(
		const DomString &namespace_uri,
		const DomString &local_name) const
	{
		if (impl)
		{
			DomNode attribute = get_attributes().get_named_item_ns(namespace_uri, local_name);
			return attribute.is_attr();
		}
		return false;
	}
开发者ID:keigen-shu,项目名称:ClanLib,代码行数:11,代码来源:dom_element.cpp

示例8: get_first_child

	DomElement DomDocument::get_document_element()
	{
		DomNode cur = get_first_child();
		while (!cur.is_null())
		{
			if (cur.is_element())
				return cur.to_element();
			cur = cur.get_next_sibling();
		}
		return DomElement();
	}
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:11,代码来源:dom_document.cpp

示例9:

	DomNodeList::DomNodeList(
		DomNode &node,
		const DomString &namespace_uri,
		const DomString &name,
		bool local_name)
	{
		DomNode current_child = node.get_first_child();
		while (!current_child.is_null())
		{
			if (local_name)
			{
				if (current_child.get_namespace_uri() == namespace_uri &&
					current_child.get_local_name() == name)
				{
					add_item(current_child);
				}
			}
			else
			{
				if (current_child.get_namespace_uri() == namespace_uri &&
					current_child.get_node_name() == name)
				{
					add_item(current_child);
				}
			}
			current_child = current_child.get_next_sibling();
		}
	}
开发者ID:tornadocean,项目名称:ClanLib,代码行数:28,代码来源:dom_node_list.cpp

示例10:

int LuaDomElement2::getChildren(lua_State *L)
{
	DomElement* obj = DomElementValue::check2( L, 1 );
	DomNode* n = obj->getFirst();
	lua_newtable( L );
	int t = lua_gettop( L );
	int j = 1;
	while( n )
	{
		if( pushNode( L, n ) )	// Wir wollen nur Text und Element
		{
			lua_rawseti( L, t, j );
			j++;
		}
		n = n->getNext();
	}
	return 1;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:18,代码来源:LuaXml2.cpp

示例11: program_object

ProgramObject ProgramObject::load(
    GraphicContext &gc,
    const std::string &resource_id,
    const XMLResourceDocument &resources)
{
    ProgramObject program_object(gc);

    XMLResourceNode resource = resources.get_resource(resource_id);

    DomNode node = resource.get_element().get_first_child();

    while (!node.is_null())
    {
        if (node.is_element())
        {
            DomElement element = node.to_element();
            if (element.get_tag_name() == "shader")
            {
                ShaderObject shader = ShaderObject::load(gc, element.get_attribute("name"), resources);
                program_object.attach(shader);
            }
            else if (element.get_tag_name() == "bind-attribute")
            {
                program_object.bind_attribute_location(
                    StringHelp::text_to_int(element.get_attribute("index")),
                    element.get_attribute("name"));
            }
        }
        node = node.get_next_sibling();
    }

    if (!resource.get_element().get_attribute("shader").empty())
    {
        ShaderObject shader = ShaderObject::load(gc, resource.get_element().get_attribute("shader"), resources);
        program_object.attach(shader);
    }

    if (resource.get_element().get_attribute("link", "true") == "true")
        if(!program_object.link())
            throw Exception(string_format("Unable to link program object: %1", program_object.get_info_log()));

    return program_object;
}
开发者ID:RobertoMalatesta,项目名称:ClanLib,代码行数:43,代码来源:program_object_xml.cpp

示例12: to_element

	DomString DomNode::find_prefix(const DomString &namespace_uri) const
	{
		DomElement cur = to_element();
		while (!cur.is_null())
		{
			DomNamedNodeMap attributes = cur.get_attributes();
			int size = attributes.get_length();
			for (int index = 0; index < size; index++)
			{
				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 DomString();
	}
开发者ID:keigen-shu,项目名称:ClanLib,代码行数:20,代码来源:dom_node.cpp

示例13: load_sprite

ResourceItem *TexturePacker::load_resource(Canvas &canvas, std::string &resource_id, Resource &resource, ResourceManager &resources)
{
	ResourceItem *item = 0;

	try
	{
		std::string type = resource.get_type();
		if(type == "sprite")
		{
			item = load_sprite(canvas, resource_id, resource, resources);
		}
		else if(type == "image")
		{
			item = load_image(canvas, resource_id, resource, resources);
		}
		else
		{
			throw Exception(string_format("Resourcetype %1 is not supported", type));
		}
	}
	catch(Exception ex)
	{
		item = new NotSupportedResourceItem(resource, ex.message);
	}

	// Find resource path by traversing parents
	DomElement &dom_element = resource.get_element();
	DomNode parent = dom_element.get_parent_node();
	while (!parent.is_null())
	{
		DomElement parent_element = parent.to_element();
		std::string parent_name = parent_element.get_attribute("name");
		if(parent_name.length() > 0)
			item->resource_path = string_format("%1/%2", parent_name, item->resource_path);
		parent = parent.get_parent_node();
	}

	return item;
}
开发者ID:authenticate,项目名称:ClanLib,代码行数:39,代码来源:texture_packer.cpp

示例14: get_first_child

	std::string DomElement::get_text() const
	{
		std::string str;
		if (has_child_nodes() == false)
			return str;

		DomNode cur = get_first_child();
		while (!cur.is_null())
		{
			if (cur.is_text() || cur.is_cdata_section())
				str.append(cur.get_node_value());
			if (cur.is_element())
				str.append(cur.to_element().get_text());
			cur = cur.get_next_sibling();
		}
		return str;
	}
开发者ID:keigen-shu,项目名称:ClanLib,代码行数:17,代码来源:dom_element.cpp

示例15: destroy_resource

void XMLResourceDocument::destroy_resource(const std::string &resource_id)
{
	std::map<std::string, XMLResourceNode>::iterator it;
	it = impl->resources.find(resource_id);
	if (it == impl->resources.end())
		return;
	DomNode cur = it->second.get_element();
	impl->resources.erase(it);
	DomNode parent = cur.get_parent_node();
	while (!parent.is_null())
	{
		parent.remove_child(cur);
		if (parent.has_child_nodes())
			break;
		cur = parent;
		parent = parent.get_parent_node();
	}
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:18,代码来源:xml_resource_document.cpp


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