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


C++ QXmlSimpleReader类代码示例

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


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

示例1: QString

void MainWindow::readDefinitions( QString filename )
{
  ui->statusBar->showMessage( QString("Loading ADIF definitions from \"%1\"").arg(filename) );

  QFile *file = new QFile(filename);
  if( !file->open(QFile::ReadOnly) )
  {
      qDebug() << "Open Definition file failed." << endl;
  }else{
      qDebug() << "Open Definition file success." << endl;
  }
  QXmlSimpleReader xmlReader;
  QXmlInputSource *source = new QXmlInputSource( file );

  AdifHandler *handler = new AdifHandler();
  xmlReader.setContentHandler(handler);
  xmlReader.setErrorHandler(handler);

  bool ok = xmlReader.parse(source);

  if( !ok )
  {
      qDebug() << "Parsing Definition file failed." << endl;
  }

  ui->statusBar->showMessage( QString("Loading Country definitions from \"%1\"").arg("DXCCcountries.xml") );

  modes = new QStringList( handler->mode );
  country = new QStringList( );
  subdivisions = new QStringList( );
  bands = QHash <QString, Range>( handler->band );
  //qDebug() << bands["160m"].lower;
}
开发者ID:compeoree,项目名称:QtSDR,代码行数:33,代码来源:mainwindow.cpp

示例2: strFileName

bool FrmReports::parseXMLFile(const QString itemName, QString& strName, QString& strAuthor, QString& strPixmap, QString& strDescription)
{
    QString strFileName(qApp->translate("dir", strReportsDir) + tr("\\") + itemName + tr(".bdrt"));

    QFile file(strFileName);
    if (!file.exists()) return false;
    if (!file.open(QFile::ReadOnly | QFile::Text)) return false;

    //Just try to parse the xml
    QXmlSimpleReader xmlReader;
    QXmlInputSource *source = new QXmlInputSource(&file);
    if (!xmlReader.parse(source)) {
        file.close();    //exit, but close the file first!
        return false;
    }
    delete source;

    file.close();

    //Initialize the reader
    if (!file.open(QFile::ReadOnly | QFile::Text)) return false;
    QXmlStreamReader xml(&file);

    if (!readProperties(xml, strName, strAuthor, strPixmap, strDescription)) return false;

    file.close();

    return true;
}
开发者ID:doublebyte1,项目名称:medfisis,代码行数:29,代码来源:frmreports.cpp

示例3: handler

void Model::loadWorld( const QString& fileName, bool verbose )
{
	//printf("Loading world file...\n");
    WorldHandler handler( this );
    QXmlSimpleReader reader;
    reader.setContentHandler(&handler);
    reader.setErrorHandler(&handler);
    QFile file(fileName);
	
    if ( !file.open(QFile::ReadOnly | QFile::Text) )
	{
		QString errStr = "failed to open file '";
		errStr.append(fileName);
		errStr.append("'");
		throw KinematicModelException(errStr);
    }
	
    QXmlInputSource xmlInputSource( &file );
    if ( !reader.parse( xmlInputSource ) )
	{
		QString errStr = "failed to create world from file '";
		errStr.append(fileName);
		errStr.append("'");
		throw KinematicModelException(errStr);
    }
	//printf("success!\n");
}
开发者ID:Juxi,项目名称:iCub,代码行数:27,代码来源:model.cpp

示例4: definitionFile

QSharedPointer<HighlightDefinition> Manager::definition(const QString &id)
{
    if (!id.isEmpty() && !m_definitions.contains(id)) {
        QFile definitionFile(id);
        if (!definitionFile.open(QIODevice::ReadOnly | QIODevice::Text))
            return QSharedPointer<HighlightDefinition>();

        QSharedPointer<HighlightDefinition> definition(new HighlightDefinition);
        HighlightDefinitionHandler handler(definition);

        QXmlInputSource source(&definitionFile);
        QXmlSimpleReader reader;
        reader.setContentHandler(&handler);
        m_isBuildingDefinition.insert(id);
        try {
            reader.parse(source);
        } catch (const HighlighterException &e) {
            MessageManager::write(
                        QCoreApplication::translate("GenericHighlighter",
                                                    "Generic highlighter error: ") + e.message(),
                        MessageManager::WithFocus);
            definition.clear();
        }
        m_isBuildingDefinition.remove(id);
        definitionFile.close();

        m_definitions.insert(id, definition);
    }

    return m_definitions.value(id);
}
开发者ID:AgnosticPope,项目名称:qt-creator,代码行数:31,代码来源:manager.cpp

示例5: statusBar

void SvgCanvas::load_file(QString svg_file_name)
{
	statusBar()->clearMessage();
	
	svg_plot->load(svg_file_name);
	
	QSvgRenderer *renderer=svg_plot->renderer();
	
	if(! renderer->isValid () )
	{
		QFile file(svg_file_name);
		QXmlSimpleReader parser;
		QXmlInputSource source(&file);
		XmlCheckHandler handler(statusBar(), svg_file_name);
		
		file.open(QIODevice::ReadOnly);
		
		parser.setContentHandler(&handler);
		parser.setErrorHandler(&handler);
		
		parser.parse(&source);
		
		file.close();
	}
}
开发者ID:OpticaMonografia,项目名称:QtOctave,代码行数:25,代码来源:svgcanvas.cpp

示例6: printd

void
TrainingsTageBuch::writeFileCompleted()
{
    printd("TrainingStageBuch::writeFileCompleted()\n");

    QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender());

    printd("reply:%s\n", reply->readAll().toStdString().c_str());

    TTBUploadParser handler;
    QXmlInputSource source(reply);

    QXmlSimpleReader reader;
    reader.setContentHandler(&handler);

    bool success = true;
    if(! reader.parse(source)) {
        success = false;
    }

    if(success && handler.error.length() > 0){
        success = false;
    }

    if(success && handler.id.length() == 0 ){
        success = false;
    }

    if (success && reply->error() == QNetworkReply::NoError) {
        notifyWriteComplete(replyName(static_cast<QNetworkReply*>(QObject::sender())), tr("Completed."));
    } else {
        notifyWriteComplete( replyName(static_cast<QNetworkReply*>(QObject::sender())), tr("Error - Upload failed."));
    }
}
开发者ID:GoldenCheetah,项目名称:GoldenCheetah,代码行数:34,代码来源:TrainingsTageBuch.cpp

示例7: clear

bool Filters::load(const QString& filename)
{
  // clear existing 
  clear();

  // load filters
  m_file = filename;

  // create XML content handler
  LoadXmlContentHandler handler(*this, m_types);

  // create a file object on the file
  QFile xmlFile(filename);

  // create an XmlInputSource on the file
  QXmlInputSource source(&xmlFile);
  
  // create an XML parser
  QXmlSimpleReader reader;

  // set the content handler
  reader.setContentHandler(&handler);

  // parse the file
  return reader.parse(source);
}
开发者ID:carriercomm,项目名称:showeq,代码行数:26,代码来源:filter.cpp

示例8: processReadData

void RemoteController::processReadData(const QByteArray &data) {
	QXmlSimpleReader reader;
	RemoteController::XmlHandler *xmlHandler = new RemoteController::XmlHandler();

	reader.setContentHandler(xmlHandler);
	QXmlInputSource buffer;
	buffer.setData(data);
	reader.parse(&buffer);

	isStarted = xmlHandler->my_started;
	isGameOver = xmlHandler->my_gameover;

	if (isStarted == 1) {
		myLeftBtn->setEnabled(true);
		myRightBtn->setEnabled(true);
		myStartBtn->setEnabled(false);
	}
	if (isGameOver == 1) {
		myLeftBtn->setEnabled(false);
		myRightBtn->setEnabled(false);
		--myLostBalls;
		if (myLostBalls > 0) {
			myLostBallsLbl->setText(QString::number(myLostBalls));
			myStartBtn->setEnabled(true);
		} else {
			myLostBallsLbl->setText("The game is over :(");
			myStartBtn->setEnabled(false);
		}
	}
}
开发者ID:bondarevts,项目名称:amse-qt,代码行数:30,代码来源:RemoteController.cpp

示例9: setDefaultGrid

void cbSimulator::setDefaultGrid(void)
{
	QXmlInputSource *source;

    source = new QXmlInputSource;
        source->setData(QByteArray(GRID));

        QXmlSimpleReader xmlParser;

	cbGridHandler *gridHandler = new cbGridHandler;
	xmlParser.setContentHandler(gridHandler);

    cbGrid *grid;
	if(xmlParser.parse(*source))
        grid = gridHandler->parsedGrid();
	else {
        cerr << "Error parsing DEFAULT grid\n";
        gui->appendMessage(QString("Error parsing DEFAULT grid"), true);
		assert(0);
	}

    setGrid(grid);
	delete gridHandler;
	delete source;

	//rebuild graph
	if(lab!=0) {
        buildGraph();
        setDistMaxFromGridToTarget();
	}

    // update parameters
    //param->gridFilename = "";
}
开发者ID:bluemoon93,项目名称:CiberMouse,代码行数:34,代码来源:cbsimulator.cpp

示例10: QFile

bool ZkbConfig::load(const QString& file, Keymap& keymap, const QString& prefix) {
    bool ret;
    QFile *f = new QFile(path+"/"+file);
    QFileInfo fi(*f);

    /* Try */
    if ( !fi.exists() && !path.contains( QPEApplication::qpeDir()) ) {
        delete f;
        f  = new QFile( QPEApplication::qpeDir() + "share/zkb/" + file );
        fi = QFileInfo( *f );
    }

    odebug << "start loading file=" << file << "\n" << oendl;
    if (includedFiles.find(fi.absFilePath()) != includedFiles.end()) {
        return false;
    }

    includedFiles.insert(fi.absFilePath(), 1);
    QXmlInputSource is(*f);
    QXmlSimpleReader reader;
    ZkbHandler h(*this, keymap, prefix);

    reader.setContentHandler(&h);
    reader.setErrorHandler(this);
    ret = reader.parse(is);
    includedFiles.remove(fi.absFilePath());

    odebug << "end loading file=" << file << ": status=" << err << oendl;
    delete f;
    return ret;
}
开发者ID:opieproject,项目名称:opie,代码行数:31,代码来源:zkbcfg.cpp

示例11: FineReaderXMLOutputHandler

void FRXMLCharDataReader::parseSingleImageFile(const std::string fileName, const std::string resultFileName, GrayImage<> *pImage, std::vector<ImageChar> &imageCharVec, const int imageId /*= 0*/) const
{
	// create the finereader xml output handler object need for parsing the files
	FineReaderXMLOutputHandler *pXMLHandler = new FineReaderXMLOutputHandler();
	// create simple reader and set the content/error handler
    QXmlSimpleReader reader;
    reader.setContentHandler(pXMLHandler);
    reader.setErrorHandler(pXMLHandler);

	// create QFile object
    QFile file( QString::fromStdString(resultFileName) );
    if (!file.open(QFile::ReadOnly | QFile::Text)) {
     	throw Exception("Error openening xml-file in FRXMLCharDataReader::parseXMLFiles!");
     }
     // create xml input source from file object
     QXmlInputSource xmlInputSource(&file);
     // parse the file using the simple reader
     reader.parse(xmlInputSource);
     std::cout << "Successfully parsed xml data of file " << resultFileName << std::endl;
 	// store results
     SimpleFineReaderXMLData* pData = pXMLHandler->getFineReaderData();
//     imageCharVec.clear();
     for (int j=0; j<pData->parsedBBoxes.size(); ++j) {
     	ImageChar imChar(pData->parsedBBoxes[j], pImage, imageId, imageCharVec.size());
     	imChar.text = pData->parsedChars[j];
     	imChar.suspicious = pData->isSuspicious[j];

     	imageCharVec.push_back(imChar);
     } // end for j
     pXMLHandler->clearData();
     delete pXMLHandler;

     return;
} // end parseSingleImageFile
开发者ID:hashimmoosavi,项目名称:inventory-extraction,代码行数:34,代码来源:FRXMLCharDataReader.cpp

示例12: qDebug

void BDHServerController::loadConfiguration()
{
    QFile file;

    //! Set XML dir
    file.setFileName(QString("./hmi.xml"));

    //! Open file
    if (!file.open(QFile::ReadOnly | QFile::Text))
    {
        qDebug() << "Not hmi.xml file present and can't configure. \n CLOSING...";
        exit(-1);
    }

    //! Set XML reader
    QXmlSimpleReader reader;
    reader.setContentHandler(m_configurationLoader);
    reader.setErrorHandler(m_configurationLoader);
    QXmlInputSource xmlInputSource(&file);

    //! Parse hmi.xml file for proyect configuration
    if (!reader.parse(xmlInputSource))
    {
        //!Show error parsing hmi.xml
        qDebug() << QString("There was an error while loading the configuration: %1. \n CLOSING...").arg(m_configurationLoader->errorString());
        exit(-1);
    }

}
开发者ID:mujicadiazr,项目名称:BDH,代码行数:29,代码来源:bdhservercontroller.cpp

示例13: loadFromXML

bool KDReports::Report::loadFromXML( QIODevice* iodevice, ErrorDetails* details )
{
    QDomDocument doc;
    // Read document from the QIODevice, check for errors

    // We need to be able to see the space in <text> </text>, this is why
    // we activate the "report-whitespace-only-CharData" feature.
    // Unfortunately this leads to lots of whitespace text nodes in between real
    // elements in the rest of the document, watch out for that.
    if (iodevice->isOpen())
        iodevice->reset(); //need to do that to allow consecutive calls of loadFromXML()
    QXmlInputSource source( iodevice );
    QXmlSimpleReader reader;
    reader.setFeature( QLatin1String( "http://xml.org/sax/features/namespaces" ), false );
    reader.setFeature( QLatin1String( "http://xml.org/sax/features/namespace-prefixes" ), true );
    reader.setFeature( QLatin1String( "http://trolltech.com/xml/features/report-whitespace-only-CharData" ), true );

    QString errorMsg;
    int errorLine = 0, errorColumn = 0;
    bool ret = doc.setContent( &source, &reader, &errorMsg, &errorLine, &errorColumn );
    if( !ret ) {
        if ( details ) {
            details->setLine( errorLine );
            details->setColumn( errorColumn );
            details->setDriverMessage( errorMsg );
        }
        else
            qWarning( "Malformed XML read in KDReports::Report::loadFromXML(): error message = %s, error line = %d, error column = %d", qPrintable( errorMsg ), errorLine, errorColumn );
        return false;
    }
    return loadFromXML( doc, details );
}
开发者ID:DarkDemiurg,项目名称:KDReports,代码行数:32,代码来源:KDReportsReport.cpp

示例14: readObjectXMLFile

Scenegraph* ObjectXMLReader::readObjectXMLFile(string filename, GLint objectColorLocation, GLint modelviewLocation, glm::mat4& modelview)
{
    //Create a file handler and tell it were the color and modelview
    ObjectXMLFileHandler handler;
    handler.setObjectColorLocation(objectColorLocation);
    handler.setModelviewLocation(modelviewLocation);
    //pass the modelview matrix to the handler (the camera position)
    handler.setModelview(modelview);
    //create a simple reader
    QXmlSimpleReader reader;
    //create a Qfile
    QFile xmlFile(QString::fromStdString(filename));
    //specify the source
    QXmlInputSource source(&xmlFile);

    //declare a new scenegraph
    Scenegraph* scene;
    //set the content handler
    reader.setContentHandler(&handler);
    //parse
    bool answer = reader.parse(source);
    //if successful, set the scene
    if (answer)
    {
        scene = handler.getScene();
    }
    //otherwise, print an error
    else
        printf("Parsing unsuccessful because %s\n",handler.errorString().toLatin1().constData());
    return scene;
}
开发者ID:Jornason,项目名称:MyHub,代码行数:31,代码来源:ObjectXMLReader.cpp

示例15: parseSimplePattern

const QString PatternParser::parseSimplePattern(const QString& pattern,
        int cdno, const int nooftracks,
        const QString& artist, const QString& title,
        const QString& date, const QString& genre, const QString& suffix,
        bool fat32compatible) {

  SaxHandler handler;
  handler.setCDNo(cdno);
  handler.setNoOfTracks(nooftracks);
  handler.setArtist(artist);
  handler.setTitle(title);
  handler.setDate(date);
  handler.setGenre(genre);
  handler.setSuffix(suffix);
  handler.setFAT32Compatible(fat32compatible);
  handler.setReplaceSpacesWithUnderscores(false);
  handler.set2DigitsTrackNum(false);

  QXmlInputSource inputSource;
  inputSource.setData("<simplepattern>"+p_xmlize_pattern(pattern)+"</simplepattern>");
  QXmlSimpleReader reader;
  reader.setContentHandler(&handler);
  reader.setErrorHandler(&handler);
  reader.parse(inputSource);

  return handler.text();

}
开发者ID:berniyh,项目名称:audex,代码行数:28,代码来源:patternparser.cpp


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