本文整理汇总了C++中QDomNamedNodeMap::length方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNamedNodeMap::length方法的具体用法?C++ QDomNamedNodeMap::length怎么用?C++ QDomNamedNodeMap::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNamedNodeMap
的用法示例。
在下文中一共展示了QDomNamedNodeMap::length方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findDomNodeScan
/**
* @brief XmlEditWidgetPrivate::findDomNodeScan find the nearest match to a position
* @param node
* @param nodeTarget
* @param lineSearched
* @param columnSearched
* @param lastKnownNode: last known "good" position
* @return
*/
bool XmlEditWidgetPrivate::findDomNodeScan(QDomNode node, QDomNode nodeTarget, const int lineSearched, const int columnSearched, FindNodeWithLocationInfo &info)
{
int row = node.lineNumber();
int col = node.columnNumber();
if(!node.isDocument()) {
if((lineSearched == row) && (columnSearched == col)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched == row) && (columnSearched == col)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched == row) && (columnSearched < col)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched < row)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched <= row)) {
info.lastKnownNode = nodeTarget ;
}
if(node.nodeType() == QDomNode::ElementNode) {
QDomElement element = node.toElement();
QDomNamedNodeMap attributes = element.attributes();
int numAttrs = attributes.length();
for(int i = 0 ; i < numAttrs ; i++) {
QDomNode node = attributes.item(i);
QDomAttr attr = node.toAttr();
if(findDomNodeScan(attr, nodeTarget, lineSearched, columnSearched, info)) {
return true;
}
} // for
}
}
int nodes = node.childNodes().count();
for(int i = 0 ; i < nodes ; i ++) {
QDomNode childNode = node.childNodes().item(i) ;
if(childNode.isText() || childNode.isCDATASection()) {
if(findDomNodeScan(childNode, nodeTarget, lineSearched, columnSearched, info)) {
return true;
}
} else {
if(findDomNodeScan(childNode, childNode, lineSearched, columnSearched, info)) {
return true ;
}
}
}
return false ;
}
示例2: ASCII
Hint *
HintSerializer::createObjectFromDom(const QDomNode &q)
{
QString myValue;
/// simple sanity check first...
if (q.nodeName() != theHintString) {
DEBUG2("createHintFromDom: expected <%s> but got <%s>", ASCII(theHintString), ASCII(q.nodeName()));
return nullptr;
}
Hint *myHPtr = new Hint();
// the nodemap contains all the attributes...
QDomNamedNodeMap myNodeMap = q.attributes();
for (int i = 0; i < myNodeMap.length(); i++) {
QString myAName = myNodeMap.item(i).nodeName();
QString myAValue = myNodeMap.item(i).nodeValue();
DEBUG5(" hint attribute: name %s", ASCII(myAName));
DEBUG5(" hint attribute: value %s", ASCII(myAValue));
if (theNumberString == myAName) {
myHPtr->theHintIndex = myAValue.toInt();
continue;
}
if (theObjectString == myAName) {
myHPtr->theObjectName = myAValue;
continue;
}
myHPtr->theParams.setProperty(myAName, myAValue);
}
// sanity checks:
if (myHPtr->theHintIndex == 0 || myHPtr->theObjectName == "-") {
DEBUG2("Hint parsing failed: mandatory field(s) missing");
goto not_good;
}
if (myHPtr->theParams.getPropertyCount() == 0) {
DEBUG2("Hint parsing failed: no parameter fields, that's just wrong");
goto not_good;
}
DEBUG4("createHintFromDom %d for '%s' successful", myHPtr->theHintIndex,
ASCII(myHPtr->theObjectName));
return myHPtr;
not_good:
delete myHPtr;
return nullptr;
}
示例3: parseNode
void XMLParser::parseNode(IEntity *entity,QDomNode *node)
{
while(!node->isNull())
{
QString namesp;
QString name;
IEntity *auxent = NULL;
QDomElement child = node->toElement();
if(!child.isNull())
{
#ifdef PARSER_DEBUG
qDebug() << child.tagName();
#endif
splitNode(child.tagName(),namesp,name);
if(name.isEmpty())
throw new XMLParserException("Unable to parse node\n");
auxent = new IEntity(namesp,name);
}
if(node->hasAttributes())
{
QDomNamedNodeMap attributes = node->attributes();
for(unsigned int i=0; i<=attributes.length(); i++)
{
QDomNode n = attributes.item(i);
if(n.isAttr())
{
#ifdef PARSER_DEBUG
qDebug() << n.toAttr().name()<< "=" << n.toAttr().value();
#endif
QString attnamesp;
QString attname;
splitNode(n.toAttr().name(),attnamesp,attname);
//TODO: add attribute with namespace
auxent->addAttribute(attname,n.toAttr().value());
}
}
}
if(node->isText())
{
#ifdef PARSER_DEBUG
qDebug() << node->toText().data();
#endif
entity->addValue(node->toText().data());
} else
entity->addEntity(auxent);
if (node->hasChildNodes())
parseNode(auxent,&node->firstChild());
node = &(node->nextSibling());
}
}
示例4: ScriptXmlAttribute
/**
* Returns all attributes of this element.
* @return
* The attributes.
*/
QList<ScriptXmlAttribute*> ScriptXmlElement::attributes()
{
QDomNamedNodeMap attributes = m_node.attributes();
QList<ScriptXmlAttribute*> result;
for(qint32 i = 0; i < attributes.length(); i++)
{
QDomNode node = attributes.item(i);
ScriptXmlAttribute* newAttr = new ScriptXmlAttribute(node.nodeName(), node.nodeValue());
engine()->newQObject(newAttr, QScriptEngine::ScriptOwnership);
result.append(newAttr);
}
return result;
}
示例5: getModAdrFromTag
/**
* Returns the address attribute of a module.
*/
int ConfigParser::getModAdrFromTag(QDomNamedNodeMap map)
{
for(uint j = 1; j <= map.length();j++)
{
if(map.item(j-1).isAttr())
{
QDomAttr attr = map.item(j-1).toAttr();
if(attr.name() == MODULE_ATTR_MOD_ADR)
{
return attr.value().toInt();
}
}
}
return -1;
}
示例6: buildObjects
/**
* This method is designed to parse the object config file
* and to initialize the required objects in the UIObjectHandler
*/
bool ConfigParser::buildObjects(const QString object_cfgv)
{
this->getNodeList(object_cfgv,OBJECT_CFG_TAG);
/*if at least 1 tag was found proceed otherwise return false*/
if(!this->temp_node_list->count() > 0)
{
this->core->configLogError(QString(MISSING_OBJ_TAG));
return false;
}
/*iterate through the dom nodes*/
for(int i = 0;i <this->temp_node_list->count();i++)
{
QDomNode node = this->temp_node_list->item(i);
QDomNamedNodeMap map = node.attributes();
/*iterate through the attributes*/
for(uint i = 1; i <= map.length();i++)
{
if(map.item(i-1).isAttr())
{
QDomAttr attr = map.item(i-1).toAttr();
/* handle the different object types */
if(attr.name() == OBJECT_CFG_TYPE_ATTR)
{
if(attr.value() == OBJECT_TYPE_SCREEN)
{
ScreenObject* temp_screen = new ScreenObject();
temp_screen->buildScreenObject(this,map);
this->screen_list_ref->append(temp_screen);
this->core->configLogInfo(this->screen_list_ref->last()->getObjLogEntry());
}
else if(attr.value() == OBJECT_TYPE_BUTTON_C)
{
ButtonCObject *temp_buttonc = new ButtonCObject();
temp_buttonc->buildButtonCObject(this,map);
this->buttonc_list_ref->append(temp_buttonc);
this->core->configLogInfo(this->buttonc_list_ref->last()->getObjLogEntry());
}
else
{
this->core->configLogWarning(QString(UNHA_OBJ_TYPE_MSG).replace("#_1",attr.value())+"in "+object_cfgv+" on line "+QString::number(node.lineNumber()));
}
}
}
}
}
return true;
}
示例7: isKnown
/**
* Check that the node map doesn't contain any unknown elements
* @param attrs node map to check
* @param names list of known names
* @return false if node map contains unknown elements
*/
bool isKnown(const QDomNamedNodeMap& attrs, const char **names) {
bool ok=true;
for(int i=0;i<attrs.length();++i) {
QDomNode n = attrs.item(i);
const char **name = names;
bool found=false;
while(!found && *name!=0) {
found = n.nodeName() == *name;
++name;
}
if(!found) {
qWarning() << "Unknown attribute" << n.nodeName();
ok=false;
}
}
return ok;
}
示例8: setAttributes
void PdfElement::setAttributes(const QDomNamedNodeMap attr, const QString cdata) {
_attributes.clear();
if (cdata != NULL && !cdata.isEmpty()) {
extractExpressions(const_cast<QString*>(&cdata));
_attributes.insert("cdata", cdata);
}
QString val;
for (uint i = 0; i < attr.length(); i++) {
QDomAttr a = attr.item(i).toAttr();
if (!a.isNull()) {
if (a.name().toLower() == "nth") {
_onlyOnLast = a.value().toLower() == "last";
_onlyOnFirst = a.value().toLower() == "first";
_onlyOnNth = _onlyOnLast || _onlyOnFirst ? 1 : a.value().toInt();
}
val = a.value();
extractExpressions(const_cast<QString*>(&val));
_attributes.insert(a.name().toLower(), val);
}
}
}
示例9: loadPluginPropertiesForElement
/**
* This method is used to load element properties that are stored in plugins
* @param element The Element being loaded
* @param elProperties the xml properties of the element
*/
void CMapFileFilterXML::loadPluginPropertiesForElement(CMapElement *element,QDomElement *elProperties)
{
QDomElement pluginsNode = readChildElement(elProperties,"plugins");
if (!pluginsNode.isNull())
{
QDomNode n = pluginsNode.firstChild();
while (!n.isNull() )
{
QDomElement e = n.toElement();
if (!e.isNull() )
{
for (CMapPluginBase *plugin = m_mapManager->getPluginList()->first(); plugin!=0; plugin = m_mapManager->getPluginList()->next())
{
if (plugin->name()==e.tagName())
{
KMemConfig pluginProperties;
QDomNamedNodeMap attribs = e.attributes();
for (int i=0; i<attribs.length();i++)
{
QDomNode n2 = attribs.item(i);
kDebug() << "Attrib " << n2.nodeName() << " = " << n2.nodeValue();
pluginProperties.group("Properties").writeEntry(n2.nodeName(),n2.nodeValue());
}
plugin->loadElementProperties(element,&pluginProperties);
break;
}
}
}
n = n.nextSibling();
}
}
}
示例10: readSigset
/**** BEE ****/
FileList BEE::readSigset(const File &sigset, bool ignoreMetadata)
{
FileList fileList;
#ifndef BR_EMBEDDED
QDomDocument doc(sigset.fileName());
QFile file(sigset.resolved());
bool success;
success = file.open(QIODevice::ReadOnly); if (!success) qFatal("Unable to open %s for reading.", qPrintable(sigset));
success = doc.setContent(&file);
file.close();
if (!success) {
qWarning("Unable to parse %s.", qPrintable(sigset));
return fileList;
}
QDomElement docElem = doc.documentElement();
if (docElem.nodeName() != "biometric-signature-set")
return fileList;
QDomNode subject = docElem.firstChild();
while (!subject.isNull()) {
// Looping through subjects
QDomNode fileNode = subject.firstChild();
QDomElement d = subject.toElement();
QString name = d.attribute("name");
while (!fileNode.isNull()) {
// Looping through files
File file("", name);
QDomElement e = fileNode.toElement();
QDomNamedNodeMap attributes = e.attributes();
for (int i=0; i<attributes.length(); i++) {
const QString key = attributes.item(i).nodeName();
const QString value = attributes.item(i).nodeValue();
if (key == "file-name") file.name = value;
else if (!ignoreMetadata) file.set(key, value);
}
// add bounding boxes, if they exist (will be child elements of <presentation>)
if (fileNode.hasChildNodes()) {
QList<QRectF> rects;
QDomNodeList bboxes = fileNode.childNodes();
for (int i=0; i<bboxes.length(); i++) {
QDomElement bbox = bboxes.at(i).toElement();
qreal x = bbox.attribute("x").toDouble();
qreal y = bbox.attribute("y").toDouble();
qreal width = bbox.attribute("width").toDouble();
qreal height = bbox.attribute("height").toDouble();
rects += QRectF(x, y, width, height);
}
file.setRects(rects);
}
if (file.name.isEmpty()) qFatal("Missing file-name in %s.", qPrintable(sigset));
fileList.append(file);
fileNode = fileNode.nextSibling();
}
subject = subject.nextSibling();
}
#else // BR_EMBEDDED
(void) sigset;
(void) ignoreMetadata;
#endif // BR_EMBEDDED
return fileList;
}
示例11: buildModuleConfig
/**
* Parser method for the layout module configurations.
* Modules are used to define event handling between objects.
* A module can consist of several seqeuences.
* In order to ensure that behavior module attributes has to
* be append to an existing module with the same adr information.
* If there is no module existing with the current adr a new one will
* be created and append to the module list.
*
*/
bool ConfigParser::buildModuleConfig(const QString mod_cfgv)
{
this->module_list_ref->clear();
this->getNodeList(mod_cfgv,MODULE_CFG_TAG);
if(!this->temp_node_list->count() > 0)
{
this->core->configLogError(QString(MISSING_OBJ_TAG));
return false;
}
/*each module*/
for(int i = 0;i <this->temp_node_list->count();i++)
{
Module *temp_module;
QDomNode node = this->temp_node_list->item(i);
QDomNamedNodeMap map = node.attributes();
int index = 0;
bool new_mod = false;
/*get the adr of the module*/
int adr = this->getModAdrFromTag(map);
/*search for a module with this adr in the module reference list*/
index = this->getModIndexByAdr(adr, this->module_list_ref);
/*if no module was found*/
if( index < 0 )
{
new_mod = true;
temp_module = new Module();
}
/*iterate through the attributes*/
for(uint j = 1; j <= map.length();j++)
{
if(map.item(j-1).isAttr())
{
QDomAttr attr = map.item(j-1).toAttr();
if(attr.name() == MODULE_ATTR_MOD_ADR)
{
if(new_mod)
temp_module->setModAdr(attr.value().toInt());
}
else if(attr.name() == MODULE_ATTR_SEQ)
{
if(new_mod)
temp_module->addModSeq(attr.value().toInt());
else
this->module_list_ref->at(index)->addModSeq(attr.value().toInt());
}
else if(attr.name() == MODULE_ATTR_SOURCE)
{
if(new_mod)
temp_module->addModSource(attr.value().toInt());
else
this->module_list_ref->at(index)->addModSource(attr.value().toInt());
}
else if(attr.name() == MODULE_ATTR_EVENT_IN)
{
if(new_mod)
temp_module->addModEventIn(attr.value());
else
this->module_list_ref->at(index)->addModEventIn(attr.value());
}
else if(attr.name() == MODULE_ATTR_EVENT_OUT)
{
if(new_mod)
temp_module->addModEventOut(attr.value());
else
this->module_list_ref->at(index)->addModEventOut(attr.value());
}
else if(attr.name() == MODULE_ATTR_TARGET)
{
if(new_mod)
temp_module->addModTarget(attr.value().toInt());
else
this->module_list_ref->at(index)->addModTarget(attr.value().toInt());
}
else
this->core->configLogWarning(QString(UNHA_ATT_MSG).replace("#_1",attr.name()).replace("#_2",MODULE_CFG_TAG));
}
}
if(new_mod)
this->module_list_ref->append(temp_module);
}
for(int i = 0; i < this->module_list_ref->count(); i++)
{
this->core->configLogInfo(this->module_list_ref->at(i)->getModLogEntry());
}
return true;
}