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


C++ xml_node::name方法代码示例

本文整理汇总了C++中pugi::xml_node::name方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::name方法的具体用法?C++ xml_node::name怎么用?C++ xml_node::name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pugi::xml_node的用法示例。


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

示例1: readColor

static inline bool readVizAttribute(
	GraphAttributes &GA,
	node v,
	const pugi::xml_node tag)
{
	const long attrs = GA.attributes();

	if(string(tag.name()) == "viz:position") {
		if(attrs & GraphAttributes::nodeGraphics) {
			pugi::xml_attribute xAttr = tag.attribute("x");
			pugi::xml_attribute yAttr = tag.attribute("y");
			pugi::xml_attribute zAttr = tag.attribute("z");

			if(!xAttr || !yAttr) {
				GraphIO::logger.lout() << "Missing \"x\" or \"y\" in position tag." << std::endl;
				return false;
			}

			GA.x(v) = xAttr.as_int();
			GA.y(v) = yAttr.as_int();

			// z attribute is optional and avaliable only in \a threeD mode
			GA.y(v) = yAttr.as_int();
			if (zAttr && (attrs & GraphAttributes::threeD)) {
				GA.z(v) = zAttr.as_int();
			}
		}
	} else if(string(tag.name()) == "viz:size") {
		if(attrs & GraphAttributes::nodeGraphics) {
			pugi::xml_attribute valueAttr = tag.attribute("value");
			if (!valueAttr) {
				GraphIO::logger.lout() << "\"size\" attribute is missing a value." << std::endl;
				return false;
			}

			double size = valueAttr.as_double();
			GA.width(v) = size * LayoutStandards::defaultNodeWidth();
			GA.height(v) = size * LayoutStandards::defaultNodeHeight();
		}
	} else if(string(tag.name()) == "viz:shape") {
		if(attrs & GraphAttributes::nodeGraphics) {
			pugi::xml_attribute valueAttr = tag.attribute("value");
			if(!valueAttr) {
				GraphIO::logger.lout() << "\"shape\" attribute is missing a value." << std::endl;
				return false;
			}

			GA.shape(v) = toShape(valueAttr.value());
		}
	} else if(string(tag.name()) == "viz:color") {
		if(attrs & GraphAttributes::nodeStyle) {
			return readColor(GA.fillColor(v), tag);
		}
	} else {
		GraphIO::logger.lout() << "Incorrect tag: \"" << tag.name() << "\"." << std::endl;
		return false;
	}

	return true;
}
开发者ID:ogdf,项目名称:ogdf,代码行数:60,代码来源:GexfParser.cpp

示例2: Load

bool Ref::Load(const pugi::xml_node& node)
{
    if (strcmp(node.name(), "bone_ref") && strcmp(node.name(), "object_ref"))
        return false;

    id_ = node.attribute("id").as_int();
    parent_ = node.attribute("parent").as_int(-1);
    timeline_ = node.attribute("timeline").as_int();
    key_ = node.attribute("key").as_int();
    zIndex_ = node.attribute("z_index").as_int();

    return true;
}
开发者ID:TheComet93,项目名称:Urho3D,代码行数:13,代码来源:SpriterData2D.cpp

示例3: mergeNodes

void mergeNodes(pugi::xml_node toNode, pugi::xml_node& fromNode)
{
  // Base case = both nodes are text nodes
  pugi::xml_text fromNodeText = fromNode.text();
  pugi::xml_text toNodeText = toNode.text();
  if (fromNodeText && toNodeText) {
    SBLog::info() << "Overwriting template value of \"" << toNode.name() << "\" from \"" << toNodeText.get() << "\" to \"" << fromNodeText.get() << "\"." << std::endl;
    toNodeText.set(fromNodeText.get());
    return;
  }

  // Calculate number of children in toNode
  unsigned maxDistance = std::distance(toNode.begin(), toNode.end());

  // Merge children
  for (pugi::xml_node fromNodeChild = fromNode.first_child(); fromNodeChild; fromNodeChild = fromNodeChild.next_sibling()) {
    // Find appropriate merge point
    pugi::xml_node toNodeChild = findSimilarNode(fromNodeChild, toNode, maxDistance);
    if (toNodeChild) {
      mergeNodes(toNodeChild, fromNodeChild);
    } else {
      toNode.append_copy(fromNodeChild);
    }
  }

  // Erase fromNode
  removeNode(fromNode);
}
开发者ID:netroby,项目名称:WinObjC,代码行数:28,代码来源:vshelpers.cpp

示例4: findSimilarNode

static pugi::xml_node findSimilarNode(pugi::xml_node searchNode, pugi::xml_node searchRoot, unsigned maxDistance)
{
  std::string searchNodeName = searchNode.name();
  pugi::xml_node match;

  // Examine children of searchRoot that have matching names to searchNode
  unsigned i = 0;
  pugi::xml_node child = searchRoot.first_child();
  for (; child && i < maxDistance && !match; child = child.next_sibling(), i++) {
    // Ignore nodes with non-matching names
    if (searchNodeName != child.name())
      continue;

    // Assume child is a match, until shown otherwise
    match = child;

    // Check that all attributes of searchNode match the child node's attributes
    for (pugi::xml_attribute attr : searchNode.attributes()) {
      std::string searchNodeAttr = attr.value();
      std::string matchAttr = child.attribute(attr.name()).value();
      if (searchNodeAttr != matchAttr) {
        match = pugi::xml_node();
        break;
      }
    }
  }

  return match;
}
开发者ID:netroby,项目名称:WinObjC,代码行数:29,代码来源:vshelpers.cpp

示例5: parseAtomAuthor

void parseAtomAuthor(FeedAuthor& author, const pugi::xml_node &authorNode) {
  string nodeName = authorNode.name();
  if (nodeName != "author") {
    throw ParseError("expected author node.");
  }
  bool haveDetailedAuthor = false;
  for (auto child: authorNode.children()) {
    haveDetailedAuthor = true;
    nodeName = child.name();
    if (nodeName == "name") {
      getNodeContent(author.name, child);
    } else if (nodeName == "email") {
      getNodeContent(author.email, child);
    } else if (nodeName == "uri") {
      getNodeContent(author.link.url, child);
    } else if (nodeName == "link") {
      if (author.link.url.empty()) {
        getNodeContent(author.link.url, child);
      }
    }
  }
  if (!haveDetailedAuthor) {
    // the node is just a bare <author>NAME</author> element.
    getNodeContent(author.name, authorNode);
  }
}
开发者ID:CurataEng,项目名称:cyrss,代码行数:26,代码来源:atom.cpp

示例6: for_each

    virtual bool for_each(pugi::xml_node &node) {
        for (int i = 0; i < depth(); ++i) std::cout << "  "; // indentation

        std::cout << node_types[node.type()] << ": name='" << node.name() << "', value='" << node.value() << "'\n";

        return true; // continue traversal
    }
开发者ID:isee15,项目名称:awesome-simple-and-reliable,代码行数:7,代码来源:traverse_walker.cpp

示例7:

int32_t
GCConfigTest::triggerOperation(pugi::xml_node node)
{
	OMRPORT_ACCESS_FROM_OMRPORT(gcTestEnv->portLib);
	int32_t rt = 0;
	for (; node; node = node.next_sibling()) {
		if (0 == strcmp(node.name(), "systemCollect")) {
			const char *gcCodeStr = node.attribute("gcCode").value();
			if (0 == strcmp(gcCodeStr, "")) {
				/* gcCode defaults to J9MMCONSTANT_IMPLICIT_GC_DEFAULT */
				gcCodeStr = "0";
			}
			uint32_t gcCode = (uint32_t)atoi(gcCodeStr);
			omrtty_printf("Invoking gc system collect with gcCode %d...\n", gcCode);
			rt = (int32_t)OMR_GC_SystemCollect(exampleVM->_omrVMThread, gcCode);
			if (OMR_ERROR_NONE != rt) {
				omrtty_printf("%s:%d Failed to perform OMR_GC_SystemCollect with error code %d.\n", __FILE__, __LINE__, rt);
				goto done;
			}
			OMRGCTEST_CHECK_RT(rt);
			verboseManager->getWriterChain()->endOfCycle(env);
		}
	}
done:
	return rt;
}
开发者ID:DanHeidinga,项目名称:omr,代码行数:26,代码来源:GCConfigTest.cpp

示例8: parseContainer

	void EmmaParser::parseContainer(EmmaDoc &doc, pugi::xml_node containerNode)
	{
		std::string containerName = containerNode.name();

		if(containerName == "emma:interpretation")
		{
			doc.setContainerType("interpretation");
			parseInterpretation(doc, containerNode);
		}
		else if(containerName == "emma:sequence")
		{
			doc.setContainerType("sequence");
			for (pugi::xml_node interpretation = containerNode.first_child(); interpretation; interpretation = interpretation.next_sibling())
			{
				parseInterpretation(doc, interpretation);
			}
		}
		else if(containerName == "emma:one-of")
		{
			doc.setContainerType("one-of");

			for (pugi::xml_node interpretation = containerNode.first_child(); interpretation; interpretation = interpretation.next_sibling())
			{
				parseInterpretation(doc, interpretation);
			}
		}
        doc.sortInputs();
	}
开发者ID:pandatautau,项目名称:Fusion-Engine,代码行数:28,代码来源:EmmaParser.cpp

示例9: read_array_uint

//-----------------------------------------------------------------------------
void XMLMesh::read_array_uint(std::vector<std::size_t>& array,
                              const pugi::xml_node xml_array)
{
  // Check that we have an array
  const std::string name = xml_array.name();
  if (name != "array")
  {
    dolfin_error("XMLMesh.cpp",
                 "read mesh array data from XML file",
                 "Expecting an XML array node");
  }

  // Check type is unit
  const std::string type = xml_array.attribute("type").value();
  if (type != "uint")
  {
    dolfin_error("XMLMesh.cpp",
                 "read mesh array data from XML file",
                 "Expecting an XML array node");
  }

  // Get size and resize vector
  const std::size_t size = xml_array.attribute("size").as_uint();
  array.resize(size);

  // Iterate over array entries
  for (pugi::xml_node_iterator it = xml_array.begin(); it !=xml_array.end();
       ++it)
  {
    const std::size_t index = it->attribute("index").as_uint();
    const double value = it->attribute("value").as_uint();
    dolfin_assert(index < size);
    array[index] = value;
  }
}
开发者ID:YannCobigo,项目名称:dolfin,代码行数:36,代码来源:XMLMesh.cpp

示例10: loadOTBInfo

void ClientVersion::loadOTBInfo(pugi::xml_node otbNode)
{
	if (as_lower_str(otbNode.name()) != "otb") {
		return;
	}

	pugi::xml_attribute attribute;
	OtbVersion otb = {"", OTB_VERSION_3, CLIENT_VERSION_NONE};
	if (!(attribute = otbNode.attribute("client"))) {
		wxLogError(wxT("Node 'otb' must contain 'client' tag."));
		return;
	}

	otb.name = attribute.as_string();
	if (!(attribute = otbNode.attribute("id"))) {
		wxLogError(wxT("Node 'otb' must contain 'id' tag."));
		return;
	}

	otb.id = pugi::cast<int32_t>(attribute.value());
	if (!(attribute = otbNode.attribute("version"))) {
		wxLogError(wxT("Node 'otb' must contain 'version' tag."));
		return;
	}

	OtbFormatVersion versionId = static_cast<OtbFormatVersion>(pugi::cast<int32_t>(attribute.value()));
	if (versionId < OTB_VERSION_1 || versionId > OTB_VERSION_3) {
		wxLogError(wxT("Node 'otb' unrecognized format version (version 1..3 supported)."));
		return;
	}

	otb.format_version = versionId;
	otb_versions[otb.name] = otb;
}
开发者ID:edubart,项目名称:rme,代码行数:34,代码来源:client_version.cpp

示例11: read_xml_node

    void read_xml_node( pugi::xml_node node, Ptree &pt, int flags)
    {
        typedef typename Ptree::key_type::value_type Ch;

        switch ( node.type() )
        {
            case pugi::node_element:
                {
                    Ptree &tmp = pt.push_back(std::make_pair( node.name(), Ptree()))->second;
                    for ( pugi::xml_attribute attr = node.first_attribute(); attr; attr = attr.next_attribute() )
                        tmp.put( xmlattr<Ch>() + "." + attr.name(), attr.value());
                    for ( pugi::xml_node child = node.first_child(); child; child = child.next_sibling())
                        read_xml_node(child, tmp, flags);
                }
                break;
            case pugi::node_pcdata:
                {
                    if (flags & no_concat_text)
                        pt.push_back(std::make_pair(xmltext<Ch>(), Ptree( node.value() )));
                    else
                        pt.data() += node.value();
                }
                break;
            case pugi::node_comment:
                {
                    if (!(flags & no_comments))
                        pt.push_back(std::make_pair(xmlcomment<Ch>(), Ptree( node.value() )));
                }
                break;
            default:
                // skip other types
                break;
        }
    }
开发者ID:gbucknell,项目名称:fsc-sdk,代码行数:34,代码来源:xml_parser_read_pugixml.hpp

示例12: checkAttribute

void Spellbooks::checkAttribute(pugi::xml_node& node, const char* name) const {
    if (!node.attribute(name)) {
        std::string str("Missing attribute ");
        str += name;
        str += " in node ";
        str += node.name();
        throw XmlLoadException(str);
    }
}
开发者ID:abnr,项目名称:fluorescence,代码行数:9,代码来源:spellbooks.cpp

示例13: loadTextureFromXml

//Creates and initializes a texture object from xml
Texture Visitor::loadTextureFromXml(pugi::xml_node& xml_text_data)
{
	Texture to_return;// = nullptr;
	if (std::strcmp(xml_text_data.name(), "Texture") == 0)
	{
		pugi::xml_attribute tex_path = xml_text_data.attribute("TexturePath");
		to_return = scene_objects.loadTexture(tex_path.as_string());
		if (glGetError() != 0)
			std::cout << "Illegal arguments set for texture";
		for (pugi::xml_node_iterator tex_parameter = xml_text_data.begin(); tex_parameter != xml_text_data.end(); ++tex_parameter)
			setGLCodeFromXml(*tex_parameter, to_return);
	}
	//TODO: Fix this, does not work because load3DTexture returns a pointer
	else if (std::strcmp(xml_text_data.name(), "Texture3D") == 0)
	{
		pugi::xml_attribute tex_path = xml_text_data.attribute("TexturePath");
		//to_return = scene_objects.load3DTexture(tex_path.as_string());
		for (pugi::xml_node_iterator tex_parameter = xml_text_data.begin(); tex_parameter != xml_text_data.end(); ++tex_parameter)
			setGLCodeFromXml(*tex_parameter, to_return);
	}
	else if (std::strcmp(xml_text_data.name(), "FrameBufferTexture") == 0)
	{
		int left = xml_text_data.attribute("left").as_int();
		int bottom = xml_text_data.attribute("Bottom").as_int();
		int width = xml_text_data.attribute("Width").as_int();
		int height = xml_text_data.attribute("Height").as_int();
		std::string name = xml_text_data.attribute("Name").as_string();

		//to_return = scene_objects.loadFramebufferTexture(left, bottom, width, height, name);

		for (pugi::xml_node_iterator tex_parameter = xml_text_data.begin(); tex_parameter != xml_text_data.end(); ++tex_parameter)
			setGLCodeFromXml(*tex_parameter, to_return);
		for (pugi::xml_node_iterator tex_parameter = xml_text_data.begin(); tex_parameter != xml_text_data.end(); ++tex_parameter)
		{
			//if (strcmp(tex_parameter->name(), "TriangleMesh") == 0)
			//	(static_cast<FrameBufferTexture*>(to_return))->addMesh(loadMeshFromXml(*tex_parameter));
		}
	}
	else
		std::cout << "Undefined XML node type, check resource file for errors." << std::endl;

	return to_return;
}
开发者ID:J-norton,项目名称:Cuda-Game-Engine,代码行数:44,代码来源:Visitor.cpp

示例14: SetMsgTemplate

    BOOL SMessageBoxImpl::SetMsgTemplate( pugi::xml_node uiRoot )
    {
        if(wcscmp(uiRoot.name(),L"SOUI")!=0 ) return FALSE;
        if(!uiRoot.attribute(L"frameSize").value()[0]) return FALSE;
        if(!uiRoot.attribute(L"minSize").value()[0]) return FALSE;

        s_xmlMsgTemplate.reset();
        s_xmlMsgTemplate.append_copy(uiRoot);
        return TRUE;
    }
开发者ID:435420057,项目名称:soui,代码行数:10,代码来源:SMessageBox.cpp

示例15: deser

	spActor deserializedata::deser(pugi::xml_node node, const creator* factory)
	{
		deserializedata d;
		d.node = node;
		d.factory = factory;
		const char *name = node.name();
		spActor actor = factory->create(name);
		actor->deserialize(&d);
		return actor;
	}
开发者ID:luiseduardohdbackup,项目名称:oxygine-framework,代码行数:10,代码来源:Serialize.cpp


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