本文整理汇总了C++中AttributeIterator::next方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeIterator::next方法的具体用法?C++ AttributeIterator::next怎么用?C++ AttributeIterator::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeIterator
的用法示例。
在下文中一共展示了AttributeIterator::next方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeWithNamespaceSupport
bool DomWriter::writeWithNamespaceSupport(
Element& e, OutputStream* os, int level, DynamicObject& nsPrefixMap)
{
bool rval = true;
if(level < 0)
{
level = mIndentLevel;
}
// add any entries to the current namespace prefix map
if(e->hasMember("attributes") && e["attributes"]->getType() == Map)
{
AttributeIterator attrs = e["attributes"].getIterator();
while(attrs->hasNext())
{
Attribute& attr = attrs->next();
// check for an xml namespace prefix definition
const char* attrName = attrs->getName();
if(strncmp(attrName, "xmlns:", 6) == 0)
{
const char* uri = attr["value"]->getString();
nsPrefixMap[uri] = attrName + 6;
}
}
}
// create element name, which may require using the namespace prefix map
string elementName;
if(e->hasMember("namespace"))
{
const char* ns = e["namespace"]->getString();
if(nsPrefixMap->hasMember(ns))
{
// prepend prefix for given namespace
elementName.append(nsPrefixMap[ns]->getString());
elementName.push_back(':');
}
}
elementName.append(e["name"]->getString());
// open start element
rval =
((mCompact || level == 0) ? true : os->write("\n", 1)) &&
writeIndentation(os, level) &&
os->write("<", 1) &&
os->write(elementName.c_str(), elementName.length());
// write attributes
e["attributes"]->setType(Map);
AttributeIterator attrs = e["attributes"].getIterator();
while(rval && attrs->hasNext())
{
Attribute& attr = attrs->next();
// create attribute name, which may require using the namespace prefix map
string attrName;
if(attr->hasMember("namespace"))
{
const char* ns = attr["namespace"]->getString();
if(nsPrefixMap->hasMember(ns))
{
// prepend prefix for given namespace
attrName.append(nsPrefixMap[ns]->getString());
attrName.push_back(':');
}
}
attrName.append(attr["name"]->getString());
rval =
os->write(" ", 1) &&
os->write(attrName.c_str(), attrName.length()) &&
os->write("=\"", 2) &&
os->write(attr["value"]->getString(), attr["value"]->length()) &&
os->write("\"", 1);
}
// close start element, if element is empty, use compact element
e["data"]->setType(String);
e["children"]->setType(Map);
int dataLength = e["data"]->length();
bool empty = (dataLength == 0 && e["children"]->length() == 0);
rval = rval && (empty ? os->write("/>", 2) : os->write(">", 1));
// write element data and children
if(rval && !empty)
{
// write element children
if(rval && e["children"]->length() > 0)
{
// serialize each child
DynamicObjectIterator lists = e["children"].getIterator();
while(rval && lists->hasNext())
{
DynamicObject& list = lists->next();
list->setType(Array);
ElementIterator children = list.getIterator();
while(rval && children->hasNext())
{
//.........这里部分代码省略.........