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


C++ QXmlStreamAttributes::hasAttribute方法代码示例

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


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

示例1: CmdAbstract

CmdDelete::CmdDelete (MainWindow &mainWindow,
                      Document &document,
                      const QString &cmdDescription,
                      QXmlStreamReader &reader) :
  CmdAbstract (mainWindow,
               document,
               cmdDescription)
{
  LOG4CPP_INFO_S ((*mainCat)) << "CmdDelete::CmdDelete";

  QXmlStreamAttributes attributes = reader.attributes();

  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
      ENGAUGE_ASSERT (false);
  }

  QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();

  m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
  m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
  m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
  m_curvesGraphs.loadXml(reader);
}
开发者ID:wvulej,项目名称:engauge6,代码行数:25,代码来源:CmdDelete.cpp

示例2: CmdPointChangeBase

CmdAddPointGraph::CmdAddPointGraph (MainWindow &mainWindow,
                                    Document &document,
                                    const QString &cmdDescription,
                                    QXmlStreamReader &reader) :
  CmdPointChangeBase (mainWindow,
                      document,
                      cmdDescription)
{
  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::CmdAddPointGraph";

  QXmlStreamAttributes attributes = reader.attributes();

  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_X) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_Y) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_CURVE_NAME) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_ORDINAL) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER)) {
    xmlExitWithError (reader,
                      QString ("Missing attribute(s) %1, %2, %3, %4 and/or %5")
                      .arg (DOCUMENT_SERIALIZE_SCREEN_X)
                      .arg (DOCUMENT_SERIALIZE_SCREEN_Y)
                      .arg (DOCUMENT_SERIALIZE_CURVE_NAME)
                      .arg (DOCUMENT_SERIALIZE_ORDINAL)
                      .arg (DOCUMENT_SERIALIZE_IDENTIFIER));
  }

  m_posScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X).toDouble());
  m_posScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y).toDouble());
  m_curveName = attributes.value(DOCUMENT_SERIALIZE_CURVE_NAME).toString();
  m_identifierAdded = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
  m_ordinal = attributes.value(DOCUMENT_SERIALIZE_ORDINAL).toDouble();
}
开发者ID:TobiasWinchen,项目名称:engauge-digitizer,代码行数:32,代码来源:CmdAddPointGraph.cpp

示例3: QString

DriApplication::DriApplication(QXmlStreamReader *xml)
{
    QXmlStreamAttributes attributes = xml->attributes();

    options.clear();
    if (attributes.hasAttribute("name"))
        name = attributes.value("name").toString();
    else
        name.clear();

    if (attributes.hasAttribute("executable"))
        executable = attributes.value("executable").toString();
    else
        executable.clear();

    if (name.isNull() && !executable.isNull()) {
        std::cout << "application found with no name. One has been given.";
        name = QString(executable);
    }

    if (!name.isNull() && executable.isNull()) {
        std::cout << "application found with no executable. Options ignored";
        name.clear();
        while (xml->readNextStartElement())
            xml->skipCurrentElement();
        return;
    }

    while (xml->readNextStartElement()) {
        if (xml->name() == "option")
            DriOptionValue::insertList(&options, new DriOptionValue(xml));
        else
            xml->skipCurrentElement();
    }
}
开发者ID:axeldavy,项目名称:driCenter,代码行数:35,代码来源:drixml.cpp

示例4: loadXML

bool ShowFunction::loadXML(QXmlStreamReader &root)
{
    if (root.name() != KXMLShowFunction)
    {
        qWarning() << Q_FUNC_INFO << "ShowFunction node not found";
        return false;
    }

    QXmlStreamAttributes attrs = root.attributes();

    if (attrs.hasAttribute(KXMLShowFunctionID))
        setFunctionID(attrs.value(KXMLShowFunctionID).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionStartTime))
        setStartTime(attrs.value(KXMLShowFunctionStartTime).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionDuration))
        setDuration(attrs.value(KXMLShowFunctionDuration).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionColor))
        setColor(QColor(attrs.value(KXMLShowFunctionColor).toString()));
    if (attrs.hasAttribute(KXMLShowFunctionLocked))
        setLocked(true);

    root.skipCurrentElement();

    return true;
}
开发者ID:janosvitok,项目名称:qlcplus,代码行数:25,代码来源:showfunction.cpp

示例5: loadXml

void DocumentModelPointMatch::loadXml(QXmlStreamReader &reader)
{
  LOG4CPP_INFO_S ((*mainCat)) << "DocumentModelPointMatch::loadXml";

  bool success = true;

  QXmlStreamAttributes attributes = reader.attributes();

  if (attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED)) {

    setMaxPointSize (attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_POINT_SIZE).toDouble());
    setPaletteColorAccepted ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_ACCEPTED).toInt());
    setPaletteColorCandidate ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_CANDIDATE).toInt());
    setPaletteColorRejected ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_MATCH_COLOR_REJECTED).toInt());

    // Read until end of this subtree
    while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
    (reader.name() != DOCUMENT_SERIALIZE_POINT_MATCH)){
      loadNextFromReader(reader);
      if (reader.atEnd()) {
        success = false;
        break;
      }
    }
  }

  if (!success) {
    reader.raiseError (QObject::tr ("Cannot read point match data"));
  }
}
开发者ID:TobiasWinchen,项目名称:engauge-digitizer,代码行数:33,代码来源:DocumentModelPointMatch.cpp

示例6: EnumLangInfo

DescriptionLangInfo::DescriptionLangInfo(QXmlStreamReader *xml)
{
    QXmlStreamAttributes attributes = xml->attributes();

    if (attributes.hasAttribute("lang"))
        language = attributes.value("lang").toString();
    else
        throw "Missing lang element to description";

    if (attributes.hasAttribute("text"))
        text = attributes.value("text").toString();
    else
        throw "Missing text element to description";

    enum_info.clear();
    if (!xml->readNextStartElement()) {
        return;
    }
    do {
        if (xml->name() == "enum")
            enum_info.append(new EnumLangInfo(xml));
        else
            xml->skipCurrentElement();
    } while (xml->readNextStartElement());
}
开发者ID:axeldavy,项目名称:driCenter,代码行数:25,代码来源:drixml.cpp

示例7: parseXml

void ctkXnatResourceCatalogXmlParser::parseXml(QList<QVariantMap>& result)
{
    Q_D(ctkXnatResourceCatalogXmlParser);

    while (!d->xmlReader.atEnd())
    {
        if (d->xmlReader.name().compare("entry") == 0)
        {
            QVariantMap map;
            QXmlStreamAttributes attributes = d->xmlReader.attributes();

            if( attributes.hasAttribute("name") && attributes.hasAttribute("digest"))
            {
                QString name("");
                name += attributes.value("name");
                QString md5("");
                md5 += attributes.value("digest");
                map[name] = md5;
                result.append(map);
            }
        }
        d->xmlReader.readNext();
    }
    if (d->xmlReader.hasError())
    {
        qWarning()<<"Error parsing XNAT resource catalog xml!";
    }
}
开发者ID:ZeneticX,项目名称:CTK,代码行数:28,代码来源:ctkXnatResourceCatalogXmlParser.cpp

示例8: CmdPointChangeBase

CmdCut::CmdCut (MainWindow &mainWindow,
                Document &document,
                const QString &cmdDescription,
                QXmlStreamReader &reader) :
  CmdPointChangeBase (mainWindow,
                      document,
                      cmdDescription)
{
  LOG4CPP_INFO_S ((*mainCat)) << "CmdCut::CmdCut";

  QXmlStreamAttributes attributes = reader.attributes();

  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
      !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
    xmlExitWithError (reader,
                      QString ("%1 %2, %3 %4 %5")
                      .arg (QObject::tr ("Missing argument(s)"))
                      .arg (DOCUMENT_SERIALIZE_TRANSFORM_DEFINED)
                      .arg (DOCUMENT_SERIALIZE_CSV)
                      .arg (QObject::tr ("and/or"))
                      .arg (DOCUMENT_SERIALIZE_HTML));
  }

  QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();

  m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
  m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
  m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
  m_curvesGraphsRemoved.loadXml(reader);
}
开发者ID:m2pathan,项目名称:engauge-digitizer,代码行数:31,代码来源:CmdCut.cpp

示例9: loadXml

void PointStyle::loadXml(QXmlStreamReader &reader)
{
  LOG4CPP_INFO_S ((*mainCat)) << "PointStyle::loadXml";

  QXmlStreamAttributes attributes = reader.attributes();

  if (attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_RADIUS) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_LINE_WIDTH) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_COLOR) &&
      attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE)) {

    setRadius (attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_RADIUS).toInt());
    setLineWidth (attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_LINE_WIDTH).toInt());
    setPaletteColor ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_COLOR).toInt());
    setShape ((PointShape) attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE).toInt());

    // Read until end of this subtree
    while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
    (reader.name() != DOCUMENT_SERIALIZE_POINT_STYLE)){
      loadNextFromReader(reader);
    }
  } else {
    reader.raiseError ("Cannot read point style data");
  }
}
开发者ID:keszybz,项目名称:engauge6,代码行数:25,代码来源:PointStyle.cpp

示例10: if

DriOptionInfo::DriOptionInfo(QXmlStreamReader *xml)
{
    QXmlStreamAttributes attributes = xml->attributes();

    if (attributes.hasAttribute("name"))
        name = attributes.value("name").toString();
    else
        throw "Missing name element to option info";

    if (attributes.hasAttribute("type")) {
        QString type_string = attributes.value("type").toString();
        if (type_string == "bool")
            type = OptionBool;
        else if (type_string == "int")
            type = OptionInt;
        else if (type_string == "enum")
            type = OptionEnum;
        else if (type_string == "string")
            type = OptionString;
        else
            throw "Unknown type element to option info";
    } else
        throw "Missing type element to option info";

    if (attributes.hasAttribute("default"))
        default_value = attributes.value("default").toString();
    else
        default_value.clear();

    if (type == OptionEnum) {
        if (!attributes.hasAttribute("valid"))
            throw "Missing valid element to option info with enum";

        QString valid_string = attributes.value("valid").toString();
        QStringList valid_string_list = valid_string.split(':');
        bool ok = 0;

        if (!valid_string_list.count() == 2)
            throw "Invalid valid element to option info with enum";

        min_valid = valid_string_list[0].toInt(&ok);
        if (!ok)
            throw "Invalid valid element to option info with enum";
        max_valid = valid_string_list[1].toInt(&ok);
        if (!ok || min_valid > max_valid)
            throw "Invalid valid element to option info with enum";
    }

    descriptions.clear();
    if (!xml->readNextStartElement()) {
        return;
    }
    do {
        if (xml->name() == "description")
            descriptions.append(new DescriptionLangInfo(xml));
        else
            xml->skipCurrentElement();
    } while (xml->readNextStartElement());
}
开发者ID:axeldavy,项目名称:driCenter,代码行数:59,代码来源:drixml.cpp

示例11: loadCardsFromXml

void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
{
    while (!xml.atEnd()) {
        if (xml.readNext() == QXmlStreamReader::EndElement)
            break;
        if (xml.name() == "card") {
            QString name, manacost, type, pt, text;
            QStringList colors;
            QStringMap customPicURLs, customPicURLsHq;
            MuidMap muids;
            SetList sets;
            int tableRow = 0;
            int loyalty = 0;
            bool cipt = false;
            bool isToken = false;
            while (!xml.atEnd()) {
                if (xml.readNext() == QXmlStreamReader::EndElement)
                    break;
                if (xml.name() == "name")
                    name = xml.readElementText();
                else if (xml.name() == "manacost")
                    manacost = xml.readElementText();
                else if (xml.name() == "type")
                    type = xml.readElementText();
                else if (xml.name() == "pt")
                    pt = xml.readElementText();
                else if (xml.name() == "text")
                    text = xml.readElementText();
                else if (xml.name() == "set") {
                    QXmlStreamAttributes attrs = xml.attributes();
                    QString setName = xml.readElementText();
                    sets.append(getSet(setName));
                    if (attrs.hasAttribute("muId")) {
                        muids[setName] = attrs.value("muId").toString().toInt();
                    }
                    if (attrs.hasAttribute("picURL")) {
                        customPicURLs[setName] = attrs.value("picURL").toString();
                    }
                    if (attrs.hasAttribute("picURLHq")) {
                        customPicURLsHq[setName] = attrs.value("picURLHq").toString();
                    }
                } else if (xml.name() == "color")
                    colors << xml.readElementText();
                else if (xml.name() == "tablerow")
                    tableRow = xml.readElementText().toInt();
                else if (xml.name() == "cipt")
                    cipt = (xml.readElementText() == "1");
                else if (xml.name() == "loyalty")
                    loyalty = xml.readElementText().toInt();
                else if (xml.name() == "token")
                    isToken = xml.readElementText().toInt();
            }

            if (isToken == tokens) {
                addCard(new CardInfo(this, name, isToken, manacost, type, pt, text, colors, loyalty, cipt, tableRow, sets, customPicURLs, customPicURLsHq, muids));
            }
        }
    }
}
开发者ID:MadsMorsing,项目名称:Cockatrice,代码行数:59,代码来源:carddatabase.cpp

示例12: loadQtd

bool QmlProfilerFileReader::loadQtd(QIODevice *device)
{
    QXmlStreamReader stream(device);

    bool validVersion = true;

    while (validVersion && !stream.atEnd() && !stream.hasError()) {
        if (isCanceled())
            return false;
        QXmlStreamReader::TokenType token = stream.readNext();
        const QStringRef elementName = stream.name();
        switch (token) {
        case QXmlStreamReader::StartDocument :  continue;
        case QXmlStreamReader::StartElement : {
            if (elementName == _("trace")) {
                QXmlStreamAttributes attributes = stream.attributes();
                if (attributes.hasAttribute(_("version")))
                    validVersion = attributes.value(_("version")) == _(PROFILER_FILE_VERSION);
                else
                    validVersion = false;
                if (attributes.hasAttribute(_("traceStart")))
                    m_traceStart = attributes.value(_("traceStart")).toLongLong();
                if (attributes.hasAttribute(_("traceEnd")))
                    m_traceEnd = attributes.value(_("traceEnd")).toLongLong();
            }

            if (elementName == _("eventData")) {
                loadEventTypes(stream);
                emit typesLoaded(m_eventTypes);
                break;
            }

            if (elementName == _("profilerDataModel")) {
                loadEvents(stream);
                break;
            }

            if (elementName == _("noteData")) {
                loadNotes(stream);
                emit notesLoaded(m_notes);
                break;
            }

            break;
        }
        default: break;
        }
    }

    if (stream.hasError()) {
        emit error(tr("Error while parsing trace data file: %1").arg(stream.errorString()));
        return false;
    } else {
        emit success();
        return true;
    }
}
开发者ID:qtproject,项目名称:qt-creator,代码行数:57,代码来源:qmlprofilertracefile.cpp

示例13: load

bool Board::load(std::string cells_param)
{
    ROS_DEBUG("Ready to read xml data of cells");

    std::string xml_cells;

    if (ros::param::get(cells_param, xml_cells)) //reading the xml data from the parameter server
    {
        cells.clear(); //cleaning all previous cells

        QXmlStreamReader xml;
        xml.addData(QString::fromStdString(xml_cells)); //adding the xml content to the input stream
        while(!xml.atEnd() && !xml.hasError()) {
            /* Read next element.*/
            QXmlStreamReader::TokenType token = xml.readNext();
            ROS_DEBUG_STREAM("name=" << xml.name().toString().toStdString());
            /* If token is just StartDocument, we'll go to next.*/
            if(token == QXmlStreamReader::StartDocument) {
                continue;
            }
            /* If token is StartElement, we'll see if we can read it.*/
            if(token == QXmlStreamReader::StartElement) {
                /* If it's named cell, we'll add a new cell to the board.*/
                if(xml.name() == "cell") {
                    cells.push_back(Cell());
                    continue;
                }
                /* If it's named vertex, we'll dig the information from there.*/
                if(xml.name() == "vertex") {
                    /* Let's get the attributes for vertex */
                    QXmlStreamAttributes attributes = xml.attributes();
                    /* Let's check that vertex has x and y attribute. */
                    if(attributes.hasAttribute("x") && attributes.hasAttribute("y")) {
                        /* We'll add it to the cell */
                        cells.back().contours.push_back(cv::Point(attributes.value("x").toString().toInt(), attributes.value("y").toString().toInt()));
                    }
                    else xml.raiseError("Vertex corrupted: x and/or y value is missing");
                }
            }
        }
        ROS_WARN_COND(xml.hasError(),"Error parsing xml data (l.%d, c.%d):%s", (int)xml.lineNumber(), (int)xml.columnNumber(), xml.errorString().toStdString().c_str());

        ROS_INFO("Xml data successfully loaded. %i cells loaded.", (int)cells.size());

        for (int i = 0; i < cells.size(); ++i)
        {
            ROS_INFO("Cell %i:  %s",i,cells[i].toString().c_str());
        }
        return true;
    }
    else
    {
        ROS_FATAL_STREAM("xml cell data not loaded!");
        return false;
    }
}
开发者ID:debasmitdas,项目名称:baxter_tictactoe,代码行数:56,代码来源:tictactoe_utils.cpp

示例14: optional_assign

bool optional_assign(const QXmlStreamAttributes &attr, const char *key, T &v, const QXmlStreamReader &reader) {
	if ( attr.hasAttribute(XmlUtil::XML_NS, key) ) {
		v = checked_convert<T>(attr.value(XmlUtil::XML_NS, key).toString(), key, reader);
		return true;
	} else if ( attr.hasAttribute("", key) ) {
		v = checked_convert<T>(attr.value("", key).toString(), key, reader);
		return true;
	}
	return false;
}
开发者ID:trigger-happy,项目名称:Cerberus,代码行数:10,代码来源:xml_util.cpp

示例15: stop

// Constructor for parser function
Message::Message(XmlStreamReader& xml)
 :  QObject(),
    m_timeStamp(),
    m_timeStampPresent( false ),
    m_code( 0 ),
    m_codePresent( false ),
    m_version( "1.0.0" ), // initialize fixed value
    m_versionPresent( true ),
    m_changed(true)
{
    QXmlStreamAttributes attr = xml.attributes();
    if ( attr.hasAttribute( "TimeStamp" ) )
    {
        if ( !setTimeStamp( QDateTime::fromString(attr.value( "TimeStamp" ).toString(), Qt::ISODate)) )
            xml.validationError( "error set TimeStamp = " + attr.value( "TimeStamp" ).toString() );
    }
    if ( attr.hasAttribute( "Code" ) )
    {
        if ( !setCode( attr.value( "Code" ).toString().toInt() ) )
            xml.validationError( "error set Code = " + attr.value( "Code" ).toString() );
    }
    if ( attr.hasAttribute( "Version" ) )
    {
        if ( !setVersion( attr.value( "Version" ).toString() ) )
            xml.validationError( "error set Version = " + attr.value( "Version" ).toString() );
    }
    bool stop(false);
    while(!xml.atEnd() && !stop)
    {
        QXmlStreamReader::TokenType token = xml.readNext();
        switch ( token )
        {
        case QXmlStreamReader::EndElement:
            if (  xml.name() == "Message" )
                stop = true;
            break;
        case QXmlStreamReader::StartElement:
            if ( xml.name() == "Argument" )
            {
                QString val = xml.readElementText();
                if ( xml.name() != "Argument" )
                    xml.raiseError( "tag mismatch Argument" );
                else if ( !addArgument( val ) )
                    xml.validationError( "error add Argument"  );
            }
            else
            {
                xml.validationError( "unexpected element " + xml.name().toString() );
            }
            break;
        default:
            break;
        }
    }
}
开发者ID:liyuqing1202,项目名称:ivef-sdk,代码行数:56,代码来源:TSTMessage.cpp


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