本文整理汇总了C++中pugi::xml_node::attributes_begin方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::attributes_begin方法的具体用法?C++ xml_node::attributes_begin怎么用?C++ xml_node::attributes_begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_node
的用法示例。
在下文中一共展示了xml_node::attributes_begin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FromXml
static
void FromXml(const pugi::xml_node& xmlNode, DataSetElement& parent)
{
// ignore non-named XML nodes
//
// pugi::xml separates XML parts into more node types than we use
//
const string& label = xmlNode.name();
if (label.empty())
return;
// label & text
DataSetElement e(xmlNode.name(), FromInputXml());
e.Text(xmlNode.text().get());
// iterate attributes
auto attrIter = xmlNode.attributes_begin();
auto attrEnd = xmlNode.attributes_end();
for ( ; attrIter != attrEnd; ++attrIter )
e.Attribute(attrIter->name(), attrIter->value());
// iterate children, recursively building up subtree
auto childIter = xmlNode.begin();
auto childEnd = xmlNode.end();
for ( ; childIter != childEnd; ++childIter ) {
pugi::xml_node childNode = *childIter;
FromXml(childNode, e);
}
// add our element to its parent
parent.AddChild(e);
}
示例2: parseNode
bool Config::parseNode(const pugi::xml_node& node) {
UnicodeString currentPath = StringConverter::fromUtf8(node.path('/'));
currentPath.append("@");
pugi::xml_node::attribute_iterator attrIter = node.attributes_begin();
pugi::xml_node::attribute_iterator attrEnd = node.attributes_end();
for (; attrIter != attrEnd; ++attrIter) {
UnicodeString configKey = currentPath;
configKey.append(attrIter->name());
std::map<UnicodeString, Variable>::iterator itm = variablesMap_.find(configKey);
if (itm != variablesMap_.end()) {
if (!itm->second.parse(attrIter->value())) {
return false;
}
} else {
LOG_WARN << "Ignoring unknown config value " << configKey << std::endl;
}
}
pugi::xml_node::iterator nodeIter = node.begin();
pugi::xml_node::iterator nodeEnd = node.end();
for (; nodeIter != nodeEnd; ++nodeIter) {
if (nodeIter->type() == pugi::node_element) {
if (!parseNode(*nodeIter)) {
return false;
}
}
}
return true;
}
示例3: mergeAttributes
void SettingsManager::mergeAttributes(pugi::xml_node _nodeTarget, pugi::xml_node _nodeSource)
{
for (pugi::xml_node::attribute_iterator attribute = _nodeSource.attributes_begin(); attribute != _nodeSource.attributes_end(); attribute ++)
{
pugi::xml_attribute attributeNode = _nodeTarget.attribute((*attribute).name());
if (attributeNode.empty())
attributeNode = _nodeTarget.append_attribute((*attribute).name());
attributeNode.set_value((*attribute).value());
}
}
示例4: for_each
virtual bool for_each(pugi::xml_node& node) {
Log::log(logModule, level, "XML node type = [%s], name = [%s], value = [%s]",
node_types[node.type()], node.name(),
node.type() == pugi::node_cdata || node.type() == pugi::node_pcdata ? node.text().get() : node.value());
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
Log::log(logModule, level, " attribute name = [%s], value = [%s]",
ait->name(), ait->value());
}
return true;
}
示例5: constraintWithParent
void UIParserChangeTextureDelegate::constraintWithParent(const pugi::xml_node& node, const pugi::xml_node& prev_node, cocos2d::Node* parent, cocos2d::Node* recent)
{
if (parent)
{
std::string src;
std::string atlas;
std::string frame;
cocos2d::Node* target = nullptr;
for (auto it = node.attributes_begin(); it != node.attributes_end(); it++)
{
if (strcmp(it->name(), "src") == 0)
{
src = it->value();
}
else if (strcmp(it->name(), "atlas") == 0)
{
atlas = it->value();
}
else if (strcmp(it->name(), "frame") == 0)
{
frame = it->value();
}
else if (strcmp(it->name(), "target") == 0)
{
std::vector<std::string> ids;
ui_parser_utils::split(it->value(), ':', ids);
target = parent;
for (int i = 0; i < ids.size(); i++)
{
if (ids[i].compare("this") != 0 && target)
{
target = target->getChildByName(ids[i]);
}
}
}
}
auto imageview = dynamic_cast<CustomUIImageView*>(target);
if (imageview)
{
if (!src.empty())
{
imageview->loadTexture(src);
}
else if(!atlas.empty() && !frame.empty())
{
imageview->setSpriteFrame(atlas_cache::getSpriteFrame(atlas, frame));
}
}
}
}
示例6: print_node
void xmlManager::print_node(pugi::xml_node source_node, string prefix) {
cout << prefix << source_node.name() << ": " << source_node.value() << endl;
for (pugi::xml_attribute_iterator it = source_node.attributes_begin();
it != source_node.attributes_end();
it++)
cout << prefix + "\t" << it->name() << " : " << it->value() << endl;
for (pugi::xml_node_iterator it = source_node.begin();
it != source_node.end();
it++)
print_node(*it, prefix + "\t");
}
示例7: setGLCodeFromXml
//Parses XML data into calls to glTexParameteri
void Visitor::setGLCodeFromXml(pugi::xml_node xml_input, Texture& texture)
{
if (std::strcmp(xml_input.name(), "Parameter") == 0)
{
for (pugi::xml_attribute_iterator tex_parameter = xml_input.attributes_begin();
tex_parameter != xml_input.attributes_end(); ++tex_parameter)
{
//Signals whether the parameter passed to openGL is a macro or integer
bool expect_int = false;
//Signals whether the parameter passed to openGL is a float or an integer
bool expect_float = false;
std::string param_id = tex_parameter->name();
std::string param_value = tex_parameter->as_string();
int param_type = 0;
//Filtering options
if (strcmp(param_id.c_str(), "MinFilter") == 0)
param_type = GL_TEXTURE_MIN_FILTER;
else if (strcmp(param_id.c_str(), "MagFilter") == 0)
param_type = GL_TEXTURE_MAG_FILTER;
// Min/Max values for texture
else if (strcmp(param_id.c_str(), "MaxLOD") == 0)
{
param_type = GL_TEXTURE_MAX_LOD;
expect_float = true;
}
else if (strcmp(param_id.c_str(), "MinLOD") == 0)
{
param_type = GL_TEXTURE_MIN_LOD;
expect_float = true;
}
else if (strcmp(param_id.c_str(), "BaseLevel") == 0)
{
param_type = GL_TEXTURE_BASE_LEVEL;
expect_int = true;
}
else if (strcmp(param_id.c_str(), "MaxLevel") == 0)
{
param_type = GL_TEXTURE_MAX_LEVEL;
expect_int = true;
}
//Comparison options
else if (strcmp(param_id.c_str(), "CompareMode") == 0)
param_type = GL_TEXTURE_COMPARE_MODE;
else if (strcmp(param_id.c_str(), "CompareFunc") == 0)
param_type = GL_TEXTURE_COMPARE_FUNC;
//Swizzle options
else if (strcmp(param_id.c_str(), "SwizzleR") == 0)
param_type = GL_TEXTURE_SWIZZLE_R;
else if (strcmp(param_id.c_str(), "SwizzleG") == 0)
param_type = GL_TEXTURE_SWIZZLE_G;
else if (strcmp(param_id.c_str(), "SwizzleB") == 0)
param_type = GL_TEXTURE_SWIZZLE_B;
else if (strcmp(param_id.c_str(), "SwizzleA") == 0)
param_type = GL_TEXTURE_SWIZZLE_A;
//Texture wrapping modes
else if (strcmp(param_id.c_str(), "WrapS") == 0)
param_type = GL_TEXTURE_WRAP_S;
else if (strcmp(param_id.c_str(), "WrapT") == 0)
param_type = GL_TEXTURE_WRAP_T;
else if (strcmp(param_id.c_str(), "WrapR") == 0)
param_type = GL_TEXTURE_WRAP_R;
else
{
//If we are here an unknown identifier was supplied
std::cout << "Unknown parameter type: " << param_id << std::endl;
std::cout << "Check XML Resource file for errors" << std::endl;
return;
}
//Now need to discern the argument to pass
int gl_parameter = 0;
//Regular filter types
if (strcmp(param_value.c_str(), "Linear") == 0)
gl_parameter = GL_LINEAR;
else if (strcmp(param_value.c_str(), "Nearest") == 0)
gl_parameter = GL_NEAREST;
//Mipmap filter types
else if (strcmp(param_value.c_str(), "NearestMipmapNearest") == 0)
gl_parameter = GL_NEAREST_MIPMAP_NEAREST;
else if (strcmp(param_value.c_str(), "NearestMipmapLinear") == 0)
gl_parameter = GL_NEAREST_MIPMAP_LINEAR;
else if (strcmp(param_value.c_str(), "LinearMipmapNearest") == 0)
gl_parameter = GL_LINEAR_MIPMAP_NEAREST;
else if (strcmp(param_value.c_str(), "LinearMipmapLinear") == 0)
gl_parameter = GL_LINEAR_MIPMAP_LINEAR;
//Comparison functions
else if (strcmp(param_value.c_str(), "CompareRefToTexture") == 0)
gl_parameter = GL_COMPARE_REF_TO_TEXTURE;
else if (strcmp(param_value.c_str(), "None") == 0)
gl_parameter = GL_NONE;
//.........这里部分代码省略.........