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


C++ QXmlSimpleReader::setFeature方法代码示例

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


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

示例1: fetchtr_ui

void fetchtr_ui( const char *fileName, MetaTranslator *tor,
		 const char * /* defaultContext */, bool mustExist )
{
    QFile f( fileName );
    if ( !f.open(IO_ReadOnly) ) {
	if ( mustExist )
	    fprintf( stderr, "lupdate error: cannot open UI file '%s': %s\n",
		     fileName, strerror(errno) );
	return;
    }

    QTextStream t( &f );
    QXmlInputSource in( t );
    QXmlSimpleReader reader;
    reader.setFeature( "http://xml.org/sax/features/namespaces", FALSE );
    reader.setFeature( "http://xml.org/sax/features/namespace-prefixes", TRUE );
    reader.setFeature( "http://trolltech.com/xml/features/report-whitespace"
		       "-only-CharData", FALSE );
    QXmlDefaultHandler *hand = new UiHandler( tor, fileName );
    reader.setContentHandler( hand );
    reader.setErrorHandler( hand );

    if ( !reader.parse(in) )
	fprintf( stderr, "%s: Parse error in UI file\n", fileName );
    reader.setContentHandler( 0 );
    reader.setErrorHandler( 0 );
    delete hand;
    f.close();
}
开发者ID:opieproject,项目名称:opie,代码行数:29,代码来源:fetchtr.cpp

示例2: source

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:KDAB,项目名称:KDReports,代码行数:32,代码来源:KDReportsReport.cpp

示例3: load

bool MetaTranslator::load( const QString& filename )
{
    QFile f( filename );
    if ( !f.open(QIODevice::ReadOnly) )
        return false;

    QXmlInputSource in( &f );
    QXmlSimpleReader reader;
    reader.setFeature( "http://xml.org/sax/features/namespaces", false );
    reader.setFeature( "http://xml.org/sax/features/namespace-prefixes", true );
    TsHandler *hand = new TsHandler( this );
    reader.setContentHandler( static_cast<QXmlDefaultHandler*>(hand) );
    reader.setErrorHandler( static_cast<QXmlDefaultHandler*>(hand) );

    bool ok = reader.parse( in );
    reader.setContentHandler( 0 );
    reader.setErrorHandler( 0 );

    m_language = hand->language();
    makeFileNamesAbsolute(QFileInfo(filename).absoluteDir());

    delete hand;
    f.close();
    return ok;
}
开发者ID:nmelchior,项目名称:Tools,代码行数:25,代码来源:metatranslator.cpp

示例4: loadUI

bool loadUI(Translator &translator, const QString &filename, ConversionData &cd)
{
    cd.m_sourceFileName = filename;
    QFile file(filename);
    if (!file.open(QIODevice::ReadOnly)) {
        cd.appendError(QString::fromLatin1("Cannot open %1: %2")
            .arg(filename, file.errorString()));
        return false;
    }
    QXmlInputSource in(&file);
    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"), false);
    UiReader handler(translator, cd);
    reader.setContentHandler(&handler);
    reader.setErrorHandler(&handler);
    bool result = reader.parse(in);
    if (!result)
        cd.appendError(QLatin1String("Parse error in UI file"));
    reader.setContentHandler(0);
    reader.setErrorHandler(0);
    return result;
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:25,代码来源:ui.cpp

示例5: load

bool PhraseBook::load( const QString& filename )
{
    QFile f( filename );
    if ( !f.open(IO_ReadOnly) )
	return FALSE;

    QTextStream t( &f );
    QXmlInputSource in( t );
    QXmlSimpleReader reader;
    // don't click on these!
    reader.setFeature( "http://xml.org/sax/features/namespaces", FALSE );
    reader.setFeature( "http://xml.org/sax/features/namespace-prefixes", TRUE );
    reader.setFeature( "http://trolltech.com/xml/features/report-whitespace"
		       "-only-CharData", FALSE );
    QXmlDefaultHandler *hand = new QphHandler( this );
    reader.setContentHandler( hand );
    reader.setErrorHandler( hand );

    bool ok = reader.parse( in );
    reader.setContentHandler( 0 );
    reader.setErrorHandler( 0 );
    delete hand;
    f.close();
    if ( !ok )
	clear();
    return ok;
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:27,代码来源:phrase.cpp

示例6: main

int main( int argc, char **argv )
{
    QApplication app( argc, argv );

    QFile xmlFile( argc == 2 ? argv[1] : "fnord.xml" );
    QXmlInputSource source( &xmlFile );

    QXmlSimpleReader reader;

    QGrid * container = new QGrid( 3 );

    QListView * nameSpace = new QListView( container, "table_namespace" );
    StructureParser * handler = new StructureParser( nameSpace );
    reader.setContentHandler( handler );
    reader.parse( source );

    QListView * namespacePrefix = new QListView( container,
                                                 "table_namespace_prefix" );
    handler->setListView( namespacePrefix );
    reader.setFeature( "http://xml.org/sax/features/namespace-prefixes",
                       TRUE );
    source.reset();
    reader.parse( source );

    QListView * prefix = new QListView( container, "table_prefix");
    handler->setListView( prefix );
    reader.setFeature( "http://xml.org/sax/features/namespaces", FALSE );
    source.reset();
    reader.parse( source );

    // namespace label
    (void) new QLabel(
             "Default:\n"
             "http://xml.org/sax/features/namespaces: TRUE\n"
             "http://xml.org/sax/features/namespace-prefixes: FALSE\n",
             container );

    // namespace prefix label
    (void) new QLabel(
             "\n"
             "http://xml.org/sax/features/namespaces: TRUE\n"
             "http://xml.org/sax/features/namespace-prefixes: TRUE\n",
             container );

    // prefix label
    (void) new QLabel(
             "\n"
             "http://xml.org/sax/features/namespaces: FALSE\n"
             "http://xml.org/sax/features/namespace-prefixes: TRUE\n",
             container );


    app.setMainWidget( container );
    container->show();
    return app.exec();
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:56,代码来源:tagreader.cpp

示例7: load

bool PhraseBook::load(const QString &fileName, bool *langGuessed)
{
    QFile f(fileName);
    if (!f.open(QIODevice::ReadOnly))
        return false;

    m_fileName = fileName;

    QXmlInputSource in(&f);
    QXmlSimpleReader reader;
    // don't click on these!
    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"), false);
    QphHandler *hand = new QphHandler(this);
    reader.setContentHandler(hand);
    reader.setErrorHandler(hand);

    bool ok = reader.parse(in);
    reader.setContentHandler(0);
    reader.setErrorHandler(0);

    Translator::languageAndCountry(hand->language(), &m_language, &m_country);
    *langGuessed = false;
    if (m_language == QLocale::C) {
        QLocale sys;
        m_language = sys.language();
        m_country = sys.country();
        *langGuessed = true;
    }

    QString lang = hand->sourceLanguage();
    if (lang.isEmpty()) {
        m_sourceLanguage = QLocale::C;
        m_sourceCountry = QLocale::AnyCountry;
    } else {
        Translator::languageAndCountry(lang, &m_sourceLanguage, &m_sourceCountry);
    }

    delete hand;
    f.close();
    if (!ok) {
        qDeleteAll(m_phrases);
        m_phrases.clear();
    } else {
        emit listChanged();
    }

    return ok;
}
开发者ID:Suneal,项目名称:qt,代码行数:51,代码来源:phrase.cpp

示例8: download

void Compiler::download()
{
  FileProvider provider;

  QString fileName;
  if ( provider.get( Settings::self()->wsdlUrl(), fileName, Settings::self()->ignoreSslErrors() ) ) {
    QFile file( fileName );
    if ( !file.open( QIODevice::ReadOnly ) ) {
      qDebug("Unable to download file %s", Settings::self()->wsdlUrl().toEncoded().constData());
      provider.cleanUp();
      QCoreApplication::exit( 1 );
      return;
    }

    //qDebug() << "parsing" << fileName;
    QXmlInputSource source( &file );
    QXmlSimpleReader reader;
    reader.setFeature( QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true );

    QString errorMsg;
    int errorLine, errorCol;
    QDomDocument doc;
    if ( !doc.setContent( &source, &reader, &errorMsg, &errorLine, &errorCol ) ) {
      qDebug( "%s at (%d,%d)", qPrintable( errorMsg ), errorLine, errorCol );
      QCoreApplication::exit( 2 );
      return;
    }

    parse( doc.documentElement() );

    provider.cleanUp();
  }
}
开发者ID:fstbl,项目名称:KDSoap,代码行数:33,代码来源:compiler.cpp

示例9: loadAiml

bool AIMLParser::loadAiml(const QString &filename)
{
    QDomDocument doc( "mydocument" );
    QFile file( filename );
    if ( !file.open( IO_ReadOnly ) )
        return false;

    QXmlInputSource src(&file);
    QXmlSimpleReader reader;
    reader.setFeature("http://trolltech.com/xml/features/report-whitespace-only-CharData", true);

    QString msg;
    int line, col;
    if ( !doc.setContent( &src, &reader, &msg, &line, &col ) )
    {
        file.close();
        _logStream << QString("Error while parsing %1: %2 (line %3 - col %4)\n").arg(filename).arg(msg).arg(line).arg(col);
        return false;
    }
    file.close();

    parseCategories(doc);

    return true;
}
开发者ID:devartis,项目名称:chatbot,代码行数:25,代码来源:aimlparser.cpp

示例10: readFile

bool GpxFile::readFile(QString fname, bool pe) {
    GpxParser handler(*this);
    QFile file( fname );
    QXmlInputSource source( &file );

    QXmlSimpleReader reader;
    reader.setFeature("http://trolltech.com/xml/features/report-whitespace-only-CharData", false);
    reader.setContentHandler( &handler );
    reader.parse( source );

    if (pe) purgeEmptyTracks();

    return true;
}
开发者ID:Paulxia,项目名称:gpx_tools,代码行数:14,代码来源:gpxfile.cpp

示例11: fetchtr_ui

void fetchtr_ui( const char *fileName, MetaTranslator *tor,
                 const char * /* defaultContext */, bool mustExist )
{
    QFile f( fileName );
    if ( !f.open(QIODevice::ReadOnly) ) {
        if ( mustExist ) {
#if defined(_MSC_VER) && _MSC_VER >= 1400
            char buf[100];
            strerror_s(buf, sizeof(buf), errno);
            fprintf( stderr, "pylupdate5 error: cannot open UI file '%s': %s\n",
                     fileName, buf );
#else
            fprintf( stderr, "pylupdate5 error: cannot open UI file '%s': %s\n",
                     fileName, strerror(errno) );
#endif
        }
        return;
    }

    QXmlInputSource in( &f );
    QXmlSimpleReader reader;
    reader.setFeature( "http://xml.org/sax/features/namespaces", false );
    reader.setFeature( "http://xml.org/sax/features/namespace-prefixes", true );
    reader.setFeature( "http://trolltech.com/xml/features/report-whitespace"
                       "-only-CharData", false );
    QXmlDefaultHandler *hand = new UiHandler( tor, fileName );
    reader.setContentHandler( hand );
    reader.setErrorHandler( hand );

    if ( !reader.parse(in) )
        fprintf( stderr, "%s: Parse error in UI file\n", fileName );
    reader.setContentHandler( 0 );
    reader.setErrorHandler( 0 );
    delete hand;
    f.close();
}
开发者ID:imxiaohui,项目名称:pyqt5,代码行数:36,代码来源:fetchtr.cpp

示例12: asDomDocument

QDomDocument DocumentSource::asDomDocument() const
{
    if (!d->parsed)
    {
        QXmlInputSource source;
        source.setData(d->array);
        
        QXmlSimpleReader reader;
        reader.setFeature(QLatin1String("http://xml.org/sax/features/namespaces"), true);
        
        if (!d->domDoc.setContent(&source, &reader))
            d->domDoc.clear();

        d->parsed = true;
    }

    return d->domDoc;
}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:18,代码来源:documentsource.cpp

示例13: parse

// currently unused
bool Parser::parse( ParserContext *context, QXmlInputSource *source )
{
  QXmlSimpleReader reader;
  reader.setFeature( QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true );

  QString errorMsg;
  int errorLine, errorCol;
  QDomDocument doc;
  if ( !doc.setContent( source, &reader, &errorMsg, &errorLine, &errorCol ) ) {
    qDebug( "%s at (%d,%d)", qPrintable( errorMsg ), errorLine, errorCol );
    return false;
  }

  QDomElement element = doc.documentElement();
  const QName name( element.tagName() );
  if ( name.localName() != QLatin1String("schema") ) {
    qDebug( "document element is '%s'", qPrintable( element.tagName() ) );
    return false;
  }

  return parseSchemaTag( context, element );
}
开发者ID:mbahar94,项目名称:KDSoap,代码行数:23,代码来源:parser.cpp

示例14: load

void XmlSync::load(QString path, quint32 order)
{
    QFile structFile(path);
    QXmlSimpleReader simpleread;
    QXmlInputSource input;
    QDomDocument *xmlData;
    QDomElement *root;

    if(!structFile.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        fatalExit("Failed to open input file!");
    }

    if (order == 0) //Input file
    {
        xmlData = &xmlData_in;
        root = &root_in;
    }
    else //Template file
    {
        xmlData = &xmlData_out;
        root = &root_out;
    }

    //Use QXmlSimpleReader to read document since the default kills whitespace nodes which are needed.
    simpleread.setFeature(QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData"), true);
    input.setData(structFile.readAll());
    xmlData->setContent(&input, &simpleread);

    structFile.close();

    // Get root
    *root = xmlData->documentElement();

    if(root->isNull())
    {
        fatalExit("Root of the input XML file was not detected!");
    }
}
开发者ID:bureg,项目名称:amg-codec-tool,代码行数:39,代码来源:xmlsync.cpp

示例15: load

	void load( const QString& filename )
	{
		QFile file( filename );

		if ( !file.open( IO_ReadOnly ) )
		{
			Console::instance()->send( tr( "Unable to open %1!\n" ).arg( filename ) );
			return;
		}

		filenames.push_back( filename );

		QXmlInputSource input( &file );
		QXmlSimpleReader reader;
		reader.setFeature( "http://trolltech.com/xml/features/report-whitespace-only-CharData", false );

		reader.setContentHandler( this );
		reader.setErrorHandler( this );
		reader.parse( &input, false );

		filenames.pop_back();
	}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:22,代码来源:definitions.cpp


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