本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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
}
示例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;
}
示例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();
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}