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


C++ xmlWriter函数代码示例

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


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

示例1: writeXml

bool writeXml(const QString &fileName, QTreeWidget *treeWidget)
{
    QFile file(fileName);
    if (!file.open(QFile::WriteOnly | QFile::Text)) {
        std::cerr << "Error: Cannot write file "
                  << qPrintable(fileName) << ": "
                  << qPrintable(file.errorString()) << std::endl;
        return false;
    }

    QXmlStreamWriter xmlWriter(&file);
    xmlWriter.setAutoFormatting(true);
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("bookindex");
    for (int i = 0; i < treeWidget->topLevelItemCount(); ++i)
        writeIndexEntry(&xmlWriter, treeWidget->topLevelItem(i));
    xmlWriter.writeEndDocument();

    file.close();
    if (file.error()) {
        std::cerr << "Error: Cannot write file "
                  << qPrintable(fileName) << ": "
                  << qPrintable(file.errorString()) << std::endl;
        return false;
    }
    return true;
}
开发者ID:GaoHongchen,项目名称:CPPGUIProgrammingWithQt4,代码行数:27,代码来源:xmlstreamwriter.cpp

示例2: file

void FileManager::salvaUtenti(QMap<QString, Utente*>* utenti) const
{
    QFile file(_fileNameUtenti);
    file.open(QIODevice::WriteOnly);

    QXmlStreamWriter xmlWriter(&file);
    xmlWriter.setAutoFormatting(true);
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("Utenti");

    QMap<QString, Utente*>::iterator it = utenti->begin();
    for(; it != utenti->end(); ++it)
    {
        xmlWriter.writeStartElement("Utente");

        xmlWriter.writeTextElement("Username", (*it)->getUsername());
        xmlWriter.writeTextElement("Password", (*it)->getPassword());        
        xmlWriter.writeTextElement("IsAdmin", (*it)->getIsAmministratore() ? "true" : "false");
        xmlWriter.writeTextElement("Nome", (*it)->getNome());
        xmlWriter.writeTextElement("Cognome", (*it)->getCognome());

        if(typeid(*(*it)) == typeid(UtenteBasic))
            xmlWriter.writeTextElement("Tipo", "1");
        else if(typeid(*(*it)) == typeid(UtenteBusiness))
            xmlWriter.writeTextElement("Tipo", "2");
        else
            xmlWriter.writeTextElement("Tipo", "3");

        xmlWriter.writeEndElement();
    }

    xmlWriter.writeEndElement();
    file.close();
}
开发者ID:matteobortolazzo,项目名称:oop-school-project,代码行数:34,代码来源:filemanager.cpp

示例3: xmlWriter

void AlarmRestData::ackAlarm(int id)
{
    QString data;
    QXmlStreamWriter xmlWriter(&data);

    /* Writes a document start with the XML version number. */
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("Alarms");
    xmlWriter.writeAttribute("name","PPM 300");
    xmlWriter.writeAttribute("version","PPM 300");
    xmlWriter.writeAttribute("revision","PPM 300");
    xmlWriter.writeAttribute("rest_version","PPM 300");
    xmlWriter.writeStartElement("Alarm");
    xmlWriter.writeAttribute("id",QString::number(id));
    xmlWriter.writeEndElement();
    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();


    HttpRequest * postrequest = new HttpRequest;
    postrequest->setMethod("POST");
    postrequest->addQueryVariable("cmd","Alarms");
    postrequest->setData(data);

    qDebug() << data;
//    dispatchRequest(postrequest);

}
开发者ID:jcgcecilia,项目名称:QtApps,代码行数:28,代码来源:alarmrestdata.cpp

示例4: file

bool GaussianBeamWindow::writeFile(const QString& fileName)
{
	QFile file(fileName);
	if (!file.open(QFile::WriteOnly | QFile::Text))
	{
		QMessageBox::warning(this, tr("Saving file"), tr("Cannot write file %1:\n%2.").arg(fileName).arg(file.errorString()));
		return false;
	}

	QXmlStreamWriter xmlWriter(&file);
	xmlWriter.setAutoFormatting(true);
	xmlWriter.writeStartDocument("1.0");
	xmlWriter.writeDTD("<!DOCTYPE gaussianBeam>");
	xmlWriter.writeStartElement("gaussianBeam");
	xmlWriter.writeAttribute("version", "1.1");
		xmlWriter.writeStartElement("bench");
		xmlWriter.writeAttribute("id", "0");
			writeBench(xmlWriter);
		xmlWriter.writeEndElement();
		xmlWriter.writeStartElement("view");
		xmlWriter.writeAttribute("id", "0");
		xmlWriter.writeAttribute("bench", "0");
			writeView(xmlWriter);
		xmlWriter.writeEndElement();
	xmlWriter.writeEndElement();
	xmlWriter.writeEndDocument();

	file.close();
	return true;
}
开发者ID:lrunze,项目名称:MyDocuments,代码行数:30,代码来源:GaussianBeamSave.cpp

示例5: xmlWriter

bool XbelModel::slot_new(QFile *file_new)
{
    QXmlStreamWriter xmlWriter(file_new);
    xmlWriter.setAutoFormatting(true);
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("xbel");
    xmlWriter.writeAttribute(tr("version"),tr("1.0"));
    xmlWriter.writeStartElement("folder");
    xmlWriter.writeAttribute("title",tr("Эргономичность"));
    xmlWriter.writeAttribute("value_ergo","");
    xmlWriter.writeAttribute("value_ves","");
    xmlWriter.writeAttribute("value_number",QString::number(value_number));
    xmlWriter.writeAttribute("folded","1");

    xmlWriter.writeEndDocument();

    file_new->close();

    if(file_new->error())
    {
       return false;
    }

    if(!read(file_new))
    return false;

    return true;
}
开发者ID:iukash,项目名称:ergo-tree,代码行数:28,代码来源:xbelmodel.cpp

示例6: file

bool ProjectFile::Write(const QString &filename)
{
    if (!filename.isEmpty())
        mFilename = filename;

    QFile file(mFilename);
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;

    QXmlStreamWriter xmlWriter(&file);
    xmlWriter.setAutoFormatting(true);
    xmlWriter.writeStartDocument("1.0");
    xmlWriter.writeStartElement(ProjectElementName);
    xmlWriter.writeAttribute(ProjectVersionAttrib, ProjectFileVersion);

    if (!mRootPath.isEmpty())
    {
        xmlWriter.writeStartElement(RootPathName);
        xmlWriter.writeAttribute(RootPathNameAttrib, mRootPath);
        xmlWriter.writeEndElement();
    }

    if (!mIncludeDirs.isEmpty())
    {
        xmlWriter.writeStartElement(IncludDirElementName);
        QString incdir;
        foreach(incdir, mIncludeDirs)
        {
            xmlWriter.writeStartElement(DirElementName);
            xmlWriter.writeAttribute(DirNameAttrib, incdir);
            xmlWriter.writeEndElement();
        }
开发者ID:malife,项目名称:cppcheck,代码行数:32,代码来源:projectfile.cpp

示例7: pageLayout

void KoPAMasterPage::saveOdf( KoShapeSavingContext & context ) const
{
    KoPASavingContext &paContext = static_cast<KoPASavingContext&>( context );

    KoGenStyle pageLayoutStyle = pageLayout().saveOdf();
    pageLayoutStyle.setAutoStyleInStylesDotXml( true );
    pageLayoutStyle.addAttribute( "style:page-usage", "all" );
    QString pageLayoutName( paContext.mainStyles().insert( pageLayoutStyle, "pm" ) );

    KoGenStyle pageMaster( KoGenStyle::MasterPageStyle );
    pageMaster.addAttribute( "style:page-layout-name", pageLayoutName );
    pageMaster.addAttribute( "style:display-name", name() );
    pageMaster.addAttribute( "draw:style-name", saveOdfPageStyle( paContext ) );

    KoXmlWriter &savedWriter = paContext.xmlWriter();

    QBuffer buffer;
    buffer.open( QIODevice::WriteOnly );
    KoXmlWriter xmlWriter( &buffer );

    paContext.setXmlWriter( xmlWriter );

    saveOdfPageContent( paContext );

    paContext.setXmlWriter( savedWriter );

    QString contentElement = QString::fromUtf8( buffer.buffer(), buffer.buffer().size() );
    pageMaster.addChildElement( paContext.masterPageElementName(), contentElement );
    paContext.addMasterPage( this, paContext.mainStyles().insert( pageMaster, "Default" ) );
}
开发者ID:KDE,项目名称:calligra-history,代码行数:30,代码来源:KoPAMasterPage.cpp

示例8: style

const QString Filterkpr2odf::createMasterPageStyle(const KXmlNode & objects, const KXmlElement & masterBackground)
{
    //KXmlElement header( m_mainDoc.namedItem( "DOC" ).namedItem( "HEADER" ).toElement() );
    //KXmlElement footer( m_mainDoc.namedItem( "DOC" ).namedItem( "FOOTER" ).toElement() );

    // set that we work on master
    m_sticky = true;

    KOdfGenericStyle style(KOdfGenericStyle::MasterPageStyle, "");
    style.addAttribute("style:page-layout-name", createPageLayout());

    style.addAttribute("draw:style-name", createPageStyle(masterBackground));

    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly);
    KXmlWriter xmlWriter(&buffer);

    convertObjects(&xmlWriter, objects);

    m_sticky = false;

    QString contentElement = QString::fromUtf8(buffer.buffer(), buffer.buffer().size());
    style.addChildElement("master", contentElement);

    return m_styles.insert(style, "Default");
}
开发者ID:KDE,项目名称:koffice,代码行数:26,代码来源:StylesFilterkpr2odf.cpp

示例9: xmlWriter

bool XbelTree::slot_new(QFile *file_new)
{
//    QFile *file_ex = new QFile(file_new);
//    file_ex->~QFile();
//    file_ex->setFileName("bla bla bla");

    QXmlStreamWriter xmlWriter(file_new);
    xmlWriter.setAutoFormatting(true);
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("xbel");
    xmlWriter.writeAttribute(tr("version"),tr("1.0"));

    xmlWriter.writeStartElement("folder");
    xmlWriter.writeAttribute("title",tr("Эргономичность"));
    xmlWriter.writeAttribute("value_ergo","");
    xmlWriter.writeAttribute("value_ves","");
    xmlWriter.writeAttribute("value_number","");
    xmlWriter.writeAttribute("folded","");

    xmlWriter.writeEndDocument();

    file_new->close();

    if(file_new->error())
    {
       return false;
    }

    if(!read(file_new))
    return false;

    return true;
}
开发者ID:iukash,项目名称:ergo-tree,代码行数:33,代码来源:xbeltree.cpp

示例10: xmlWriter

void Fixture_Test::loadWrongID()
{
    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly | QIODevice::Text);
    QXmlStreamWriter xmlWriter(&buffer);

    xmlWriter.writeStartElement("Fixture");

    xmlWriter.writeTextElement("Channels", "9");
    xmlWriter.writeTextElement("Name", "Foobar");
    xmlWriter.writeTextElement("Universe", "0");
    xmlWriter.writeTextElement("Model", "MAC250+");
    xmlWriter.writeTextElement("Mode", "Mode 1");
    xmlWriter.writeTextElement("Manufacturer", "Martin");
    xmlWriter.writeTextElement("ID", QString::number(Fixture::invalidId()));
    xmlWriter.writeTextElement("Address", "21");

    xmlWriter.writeEndDocument();
    xmlWriter.setDevice(NULL);
    buffer.close();

    buffer.open(QIODevice::ReadOnly | QIODevice::Text);
    QXmlStreamReader xmlReader(&buffer);
    xmlReader.readNextStartElement();

    Fixture fxi(this);
    QVERIFY(fxi.loadXML(xmlReader, m_doc, m_doc->fixtureDefCache()) == false);
}
开发者ID:PML369,项目名称:qlcplus,代码行数:28,代码来源:fixture_test.cpp

示例11: KILE_DEBUG

bool UserMenuTree::writeXml(const QString &filename)
{
	KILE_DEBUG() << "write xml file " << filename;

	QFile file(filename);
	if ( !file.open(QFile::WriteOnly | QFile::Text) ) {
		KMessageBox::error(this, i18n("File '%1' could not be opened to save the usermenu file.", filename));
		return false;
	}

	QXmlStreamWriter xmlWriter(&file);
	xmlWriter.setAutoFormatting(true);
	xmlWriter.setAutoFormattingIndent(2) ;

	xmlWriter.writeStartDocument();
	xmlWriter.writeStartElement("UserMenu");

	for (int i = 0; i < topLevelItemCount(); ++i) {
		writeXmlItem(&xmlWriter, dynamic_cast<UserMenuItem *>(topLevelItem(i)) );
	}
	xmlWriter.writeEndDocument();

	file.close();
	return true;
}
开发者ID:fagu,项目名称:kileip,代码行数:25,代码来源:usermenutree.cpp

示例12: xmlWriter

void QLCInputProfile_Test::load()
{
    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly | QIODevice::Text);
    QXmlStreamWriter xmlWriter(&buffer);

    xmlWriter.writeStartDocument();
    xmlWriter.writeDTD("<!DOCTYPE InputProfile>");
    xmlWriter.writeStartElement("InputProfile");
    xmlWriter.writeTextElement("Manufacturer", "Behringer");
    xmlWriter.writeTextElement("Model", "BCF2000");
    xmlWriter.writeStartElement("Channel");
    xmlWriter.writeAttribute("Number", "492");
    xmlWriter.writeTextElement("Name", "Foobar");
    xmlWriter.writeTextElement("Type", "Slider");
    xmlWriter.writeEndDocument();
    xmlWriter.setDevice(NULL);
    buffer.close();

    buffer.open(QIODevice::ReadOnly | QIODevice::Text);
    QXmlStreamReader xmlReader(&buffer);

    QLCInputProfile ip;
    QVERIFY(ip.loadXML(xmlReader) == true);
    QVERIFY(ip.manufacturer() == "Behringer");
    QVERIFY(ip.model() == "BCF2000");
    QVERIFY(ip.channels().size() == 1);
    QVERIFY(ip.channel(492) != NULL);
    QVERIFY(ip.channel(492)->name() == "Foobar");
    QVERIFY(ip.channel(492)->type() == QLCInputChannel::Slider);
}
开发者ID:PML369,项目名称:qlcplus,代码行数:31,代码来源:qlcinputprofile_test.cpp

示例13: file

bool XmlStreamReader::writeXml(const QString &fileName)
{

    //std::cout << "1"<< std::endl;
    QFile file(fileName);
    if (!file.open(QFile::WriteOnly | QFile::Text)) {
        std::cerr << "Error: Cannot write file "
                  << qPrintable(fileName) << ": "
                  << qPrintable(file.errorString()) << std::endl;
        return false;
    }
    QXmlStreamWriter xmlWriter(&file);
    xmlWriter.setAutoFormatting(true);
    xmlWriter.writeStartDocument();
    xmlWriter.writeStartElement("highscore");
    for (int i = 0; i < this->persons->persons.length(); ++i){
        Person *pers = new Person();
        pers->error = this->persons->persons.at(i).error;
        pers->memberSince = this->persons->persons.at(i).memberSince;
        pers->name = this->persons->persons.at(i).name;
        pers->bestScoreTime = this->persons->persons.at(i).bestScoreTime;
        pers->runs = this->persons->persons.at(i).runs;
            writePersonEntry(&xmlWriter,pers);
    }
    xmlWriter.writeEndDocument();
    file.close();
    if (file.error()) {
        std::cerr << "Error: Cannot write file "
                  << qPrintable(fileName) << ": "
                  << qPrintable(file.errorString()) << std::endl;
        return false;
    }
    return true;
}
开发者ID:Hasenkrug,项目名称:CPlusPlus,代码行数:34,代码来源:xmlstreamreader.cpp

示例14: xmlWriter

void QLCFixtureHead_Test::load()
{
    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly | QIODevice::Text);
    QXmlStreamWriter xmlWriter(&buffer);

    xmlWriter.writeStartElement("Head");
    xmlWriter.writeTextElement("Channel", "0");
    xmlWriter.writeTextElement("Channel", "1");
    xmlWriter.writeTextElement("Channel", "15");
    xmlWriter.writeTextElement("Foo", "25");
    xmlWriter.writeTextElement("Channel", "42");
    xmlWriter.writeEndDocument();
    xmlWriter.setDevice(NULL);
    buffer.close();

    buffer.open(QIODevice::ReadOnly | QIODevice::Text);
    QXmlStreamReader xmlReader(&buffer);
    xmlReader.readNextStartElement();

    QLCFixtureHead head;
    QVERIFY(head.loadXML(xmlReader));
    QCOMPARE(head.channels().size(), 4);
    QVERIFY(head.channels().contains(0));
    QVERIFY(head.channels().contains(1));
    QVERIFY(head.channels().contains(15));
    QVERIFY(head.channels().contains(42));
}
开发者ID:PML369,项目名称:qlcplus,代码行数:28,代码来源:qlcfixturehead_test.cpp

示例15: xmlWriter

void VCProperties_Test::loadXMLSad()
{
    QBuffer buffer;
    buffer.open(QIODevice::ReadWrite | QIODevice::Text);
    QXmlStreamWriter xmlWriter(&buffer);

    xmlWriter.writeStartElement("VirtualConsole");

    xmlWriter.writeStartElement("Properties");
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("Frame");
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("Foo");
    xmlWriter.writeEndElement();

    xmlWriter.writeEndDocument();
    xmlWriter.setDevice(NULL);

    buffer.seek(0);
    QXmlStreamReader xmlReader(&buffer);
    xmlReader.readNextStartElement();

    VCProperties p;
    QVERIFY(p.loadXML(xmlReader) == false);
}
开发者ID:PML369,项目名称:qlcplus,代码行数:27,代码来源:vcproperties_test.cpp


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