/* Append fragment or a real xml file QXmlInputSource source; */ QDomElement UnionXml::insertFragmentorFile(const QString fragment) { bool check; /* if is a file insert dom tree and convert to element */ if (is_file(fragment)) { QFile ext_file(fragment); ext_file.open(QIODevice::ReadOnly); QXmlInputSource sxml; sxml.setData(ext_file.readAll()); QDomElement eimport = fromdevice(sxml); ext_file.close(); return eimport; } else { /* is not a file */ /// make buffer null clear QXmlInputSource fxml; /// setBuffer setData const QString heads = fragment.mid(0, 100); if (heads.contains("encoding") || heads.contains("?xml")) { fxml.setData(fragment); } else { QString dd = QString("<?xml version=\"1.0\"?>\n<dummyroot>%1</dummyroot>").arg(fragment); fxml.setData(dd); } return fromdevice(fxml); } }
bool VOCatalogDataParser::parse(const QByteArray &data, QList<VOCatalogHeader> &catalogs, QList<VOCooSys> &cooSys, QList<QStringList> &dataOut) { QXmlInputSource xmlInputStream; QXmlSimpleReader xml; if (data.isEmpty()) { return false; } xmlInputStream.setData(data); xml.setContentHandler(this); xml.setErrorHandler(this); if (xml.parse(&xmlInputStream)) { catalogs = m_list; cooSys = m_cooSys; dataOut = m_data; return true; } return false; }
int CRobLink::ReadSensors() { char xml[4096]; int n = port.recv_info(xml, 4096); if (n == -1) return n; //cerr << "ReadSensors: " << "\"" << xml << "\""; /* set source of xml document */ QXmlInputSource source; source.setData(QString(xml)); /* set parser handler */ StructureParser handler(simParam.nBeacons); //cerr << "ReadSensors: nBeacons=" << simParam.nBeacons << "\n"; /* parse xml document with handler */ QXmlSimpleReader reader; reader.setContentHandler(&handler); reader.parse(source); /////////////////////////////////////////////////// measures = *(handler.getMeasures()); //measures.showValues(); /////////////////////////////////////////////////// // for(unsigned int i=0; i<5;i++) // if (measures.hearMessage[i]!=QString()) // printf("ReadSensors: Message From %d: \"%s\"\n", i, measures.hearMessage[i].latin1()); return n; }
bool StyleParser::parseStyleFile() { QXmlSimpleReader reader; QXmlInputSource source; source.setData( mDocument->styles() ); QString errorMsg; int errorLine, errorCol; QDomDocument document; if ( !document.setContent( &source, &reader, &errorMsg, &errorLine, &errorCol ) ) { qDebug( "%s at (%d,%d)", qPrintable( errorMsg ), errorLine, errorCol ); return false; } const QDomElement documentElement = document.documentElement(); QDomElement element = documentElement.firstChildElement(); while ( !element.isNull() ) { if ( element.tagName() == QLatin1String( "styles" ) ) { if ( !parseAutomaticStyles( element ) ) return false; } else if ( element.tagName() == QLatin1String( "automatic-styles" ) ) { if ( !parseAutomaticStyles( element ) ) return false; } else if ( element.tagName() == QLatin1String( "master-styles" ) ) { if ( !parseMasterStyles( element ) ) return false; } element = element.nextSiblingElement(); } return true; }
/*! * Waits for server reply and parses status, simulation parameters and * assigns the new UDP port to this robot. */ void CRobLink::parse_server_reply(void) { // get reply confirming or denying registration char xml[MSGMAXSIZE]; int recv_ret = port.recv_info(xml, MSGMAXSIZE); if(recv_ret == -1) { cerr << "Failed Init confirmation" << recv_ret << endl; Status = -1; return; } //cerr << "XML=\"" << xml <<"\"\nXMLEND\n"; /* set source of xml document */ QXmlInputSource source; source.setData(QString(xml)); /* set parser handler */ StructureParser handler(simParam.nBeacons); /* parse xml document with handler */ QXmlSimpleReader reader; reader.setContentHandler(&handler); if( !reader.parse(source) ) { Status=-1; return; } simParam = *(handler.getSimParam()); simParam.showValues(); port.SetRemote(port.GetLastSender()); }
void PatternParser::parseInfoText(QStringList& text, const QString& artist, const QString& title, const QString& date, const QString& genre, const quint32 discid, const qreal size, const int length, const int nooftracks) { SaxHandler handler; handler.setArtist(artist); handler.setTitle(title); handler.setDate(date); handler.setGenre(genre); handler.setDiscid(discid); handler.setSize(size); handler.setLength(length); handler.setNoOfTracks(nooftracks); handler.set2DigitsTrackNum(false); QXmlInputSource inputSource; inputSource.setData("<textpattern>"+p_xmlize_pattern(text.join("\n"))+"</textpattern>"); QXmlSimpleReader reader; reader.setContentHandler(&handler); reader.setErrorHandler(&handler); reader.parse(inputSource); text = handler.text().split('\n'); }
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(); }
const QString PatternParser::parseFilenamePattern(const QString& pattern, int trackno, int cdno, int trackoffset, int nooftracks, const QString& artist, const QString& title, const QString& tartist, const QString& ttitle, const QString& date, const QString& genre, const QString& suffix, bool fat32compatible, bool replacespaceswithunderscores, bool _2digitstracknum) { SaxHandler handler; handler.setTrackNo(trackno); handler.setCDNo(cdno); handler.setTrackOffset(trackoffset); handler.setNoOfTracks(nooftracks); handler.setArtist(artist); handler.setTitle(title); handler.setTrackArtist(tartist); handler.setTrackTitle(ttitle); handler.setDate(date); handler.setGenre(genre); handler.setSuffix(suffix); handler.setFAT32Compatible(fat32compatible); handler.setReplaceSpacesWithUnderscores(replacespaceswithunderscores); handler.set2DigitsTrackNum(_2digitstracknum); QXmlInputSource inputSource; inputSource.setData("<filenamepattern>"+p_xmlize_pattern(pattern)+"</filenamepattern>"); QXmlSimpleReader reader; reader.setContentHandler(&handler); reader.setErrorHandler(&handler); reader.parse(inputSource); return handler.text(); }
bool ThemeManager::applyTheme(const ThemeDocument &kd) { // tDebug() << "Applying theme" << endl; bool ok = false; QXmlSimpleReader reader; reader.setContentHandler(this); reader.setErrorHandler(this); QXmlInputSource xmlsource; xmlsource.setData(kd.toString()); if (reader.parse(&xmlsource)) { ok = true; } else { #ifdef K_DEBUG QString msg = "ThemeManager::applyTheme() - Fatal Error: Can't process theme document"; #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif ok = false; } return ok; }
void cbSimulator::setDefaultParameters(void) { QXmlInputSource *source; source = new QXmlInputSource; source->setData(QByteArray(SIMPARAM)); QXmlSimpleReader xmlParser; cbParamHandler *paramHandler = new cbParamHandler(param); xmlParser.setContentHandler(paramHandler); cbParameters *param; if(xmlParser.parse(*source)) param = paramHandler->parsedParameters(); else { cerr << "Error parsing DEFAULT parameters\n"; gui->appendMessage(QString("Error parsing DEFAULT parameters"), true); assert(0); } setParameters(param); delete paramHandler; delete source; //cout << " done.\n"; }
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 = ""; }
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); } } }
bool CTConfToyRing::setParameters(QString xml) { // qDebug() << xml; int num_stimuli = NUM_LIGHTS + NUM_SPEAKERS; int num_actions = NUM_LIGHTS + NUM_SPEAKERS; QXmlSimpleReader xmlReader; QXmlInputSource *source = new QXmlInputSource(); source->setData(xml); CTXmlHandler *handler = new CTXmlHandler; /* *Passing pointer of the class to the xml parser handler, *in order to set the parsed values into it's input fields */ handler->setWidget(2, this, num_stimuli, num_actions); QList<CTLight*> empty1; QList<CTScreen*> empty2; QList<CTBigLight*> empty3; QList<CTButton*> empty4; handler->setStimuli(light_stimuli, speaker_stimuli, empty1, empty2,empty3,empty4); handler->setActions(light_actions, speaker_actions, empty2,empty3,empty4, empty1); xmlReader.setContentHandler(handler); xmlReader.setErrorHandler(handler); bool ok = xmlReader.parse(source); qDebug() << "The parsing went ok? " << ok; block_duration = handler->getBlockDuration(); if(ok) { updateBlockRuntime(1.0); } return true; }
/// converting <mtable> ... </mtable> void CMathMLToTeX::mtableNode(QString &text) { int sumCols = 0; if (text.contains("<mtr>")) { int posA = text.indexOf("<mtr>"); int posB = text.indexOf("</mtr>"); QString mtrText = text.mid(posA, posB - posA + 6); sumCols = mtrText.count("<mtd"); } CStructureParser xmlParser(sumCols); QXmlSimpleReader xmlReader; xmlReader.setContentHandler(&xmlParser); QXmlInputSource xmlSource; xmlSource.setData(text); xmlReader.parse(xmlSource); text = xmlParser.getTeX(); }
void StatCrewScanner::updateStats(QNetworkReply * reply) { // QFile file(statFile); QXmlSimpleReader r; r.setContentHandler(statCrew); r.setErrorHandler(statCrew); QXmlInputSource src; src.setData(reply->readAll()); r.parse(src); }
QString NewsFeed::parseFeed(const QString &feed, int limit) { QXmlSimpleReader reader; RssReader handler(limit); reader.setContentHandler(&handler); QXmlInputSource source; source.setData(feed); reader.parse(&source); return handler.getOutput(); }
static PyObject *meth_QXmlInputSource_setData(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; bool sipSelfWasArg = (!sipSelf || sipIsDerived((sipSimpleWrapper *)sipSelf)); { const QString* a0; int a0State = 0; QXmlInputSource *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QXmlInputSource, &sipCpp, sipType_QString,&a0, &a0State)) { Py_BEGIN_ALLOW_THREADS (sipSelfWasArg ? sipCpp->QXmlInputSource::setData(*a0) : sipCpp->setData(*a0)); Py_END_ALLOW_THREADS sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State); Py_INCREF(Py_None); return Py_None; } } { const QByteArray* a0; int a0State = 0; QXmlInputSource *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QXmlInputSource, &sipCpp, sipType_QByteArray, &a0, &a0State)) { Py_BEGIN_ALLOW_THREADS (sipSelfWasArg ? sipCpp->QXmlInputSource::setData(*a0) : sipCpp->setData(*a0)); Py_END_ALLOW_THREADS sipReleaseType(const_cast<QByteArray *>(a0),sipType_QByteArray,a0State); Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QXmlInputSource, sipName_setData, doc_QXmlInputSource_setData); return NULL; }
void Digester::parseMemory(const char* data, unsigned int length) { DigesterParser handler(this); QXmlInputSource source; source.setData(QString::fromUtf8(data, length)); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); reader.parse( source ); }
QXmlAttributes XMLAttributeReader::readAttrs(bool &ok) { // parse xml file QXmlInputSource source; source.setData("<?xml version=\"1.0\"?><attrs "+m_attrString+" />"); QXmlSimpleReader reader; reader.setContentHandler( this ); ok = reader.parse( source ); return attrs; }
void Digester::parseMemory(const Xml_string& data) { DigesterParser handler(this); QXmlInputSource source; source.setData(data); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); reader.parse( source ); }
void Parser::parse(QString msg){ Handler h; QXmlInputSource input; input.setData(msg); reader->setContentHandler(&h); reader->parse(&input,false); reader->setErrorHandler(&h); update = h.getUpdate(); theReply=h.getReply(); }
Pult::State* Pult::State::createInstance(const QByteArray &str) { Pult::State *state = new Pult::State(); Pult::PultXmlHandler* handler = new Pult::PultXmlHandler(state); QXmlSimpleReader reader; reader.setContentHandler(handler); QXmlInputSource buf; buf.setData(str); reader.parse(&buf); delete handler; return state; }
bool FbReadThread::parse() { QXmlStreamWriter writer(&m_html); FbReadHandler handler(*this, writer); QXmlSimpleReader reader; reader.setContentHandler(&handler); reader.setLexicalHandler(&handler); reader.setErrorHandler(&handler); QXmlInputSource source; if (m_xml.isEmpty()) { QFile file(m_filename); if (!file.open(QFile::ReadOnly | QFile::Text)) { qCritical() << QObject::tr("Cannot read file %1: %2.").arg(m_filename).arg(file.errorString()); return false; } source.setData(file.readAll()); } else { source.setData(m_xml); } return reader.parse(source); }
/*! \internal \since 4.4 See task 166278. */ void tst_QXmlInputSource::resetSimplified() const { const QString input(QString::fromLatin1("<element/>")); QXmlSimpleReader reader; QXmlInputSource source; source.setData(input); QVERIFY(reader.parse(source)); source.reset(); QCOMPARE(source.data(), input); }
QDomDocument FoxGroundDocument::xmltoken() { QXmlSimpleReader reader; QXmlInputSource source; source.setData(d->data()); QString errorMsg; QDomDocument document; if (!document.setContent(&source, &reader, &errorMsg)) { setError(QString("Invalid XML document: %1").arg(errorMsg)); setError(QString("Invalid XML Size: %1").arg(d->data().size())); return QDomDocument(); } return document; }
bool WebContentManager::parseReply(const QString &str) { QXmlSimpleReader reader; QXmlInputSource source; parser.reset(new XMLParser); source.setData(str.toAscii()); reader.setContentHandler(parser.data()); reader.setErrorHandler(parser.data()); return reader.parse(&source); }
bool TupXmlParserBase::parse(const QString &doc) { QXmlSimpleReader reader; reader.setContentHandler(this); reader.setErrorHandler(this); QXmlInputSource xmlsource; xmlsource.setData(doc); k->document = doc; return reader.parse(&xmlsource); }
/// normal equation node void CMathMLToTeX::mNode(QString &text) { CStructureParser xmlParser(0); QXmlSimpleReader xmlReader; xmlReader.setContentHandler(&xmlParser); QXmlInputSource xmlSource; xmlSource.setData(text); xmlReader.parse(xmlSource); text = xmlParser.getTeX(); }
bool StyleParser::parseMetaFile() { QXmlSimpleReader reader; QXmlInputSource source; source.setData( mDocument->meta() ); QString errorMsg; int errorLine, errorCol; QDomDocument document; if ( !document.setContent( &source, &reader, &errorMsg, &errorLine, &errorCol ) ) { qDebug( "%s at (%d,%d)", qPrintable( errorMsg ), errorLine, errorCol ); return false; } const QDomElement documentElement = document.documentElement(); QDomElement element = documentElement.firstChildElement(); while ( !element.isNull() ) { if ( element.tagName() == QLatin1String( "meta" ) ) { QDomElement child = element.firstChildElement(); while ( !child.isNull() ) { if ( child.tagName() == QLatin1String( "generator" ) ) { mStyleInformation->addMetaInformation( "producer", child.text(), i18n( "Producer" ) ); } else if ( child.tagName() == QLatin1String( "creation-date" ) ) { const QDateTime dateTime = QDateTime::fromString( child.text(), Qt::ISODate ); qDebug() << "### dateTime ... " << dateTime << " file" << __FILE__ << ":" << __LINE__; //// mStyleInformation->addMetaInformation( "creationDate", KGlobal::locale()->formatDateTime( dateTime, KLocale::LongDate, true ),i18n( "Created" ) ); } else if ( child.tagName() == QLatin1String( "initial-creator" ) ) { mStyleInformation->addMetaInformation( "creator", child.text(), i18n( "Creator" ) ); } else if ( child.tagName() == QLatin1String( "creator" ) ) { mStyleInformation->addMetaInformation( "author", child.text(), i18n( "Author" ) ); } else if ( child.tagName() == QLatin1String( "date" ) ) { const QDateTime dateTime = QDateTime::fromString( child.text(), Qt::ISODate ); qDebug() << "### dateTime ... " << dateTime << " file" << __FILE__ << ":" << __LINE__; //// mStyleInformation->addMetaInformation( "modificationDate", KGlobal::locale()->formatDateTime( dateTime, KLocale::LongDate, true ), i18n( "Modified" ) ); } child = child.nextSiblingElement(); } } element = element.nextSiblingElement(); } return true; }
void PlaylistModel::requestReceived(QNetworkReply*reply) { if(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()==401) { DataItem *item = new DataItem; item->name="Authentication error, check settings"; item->id="-1"; dataItems.append(*item); insertRows(0,1,QModelIndex()); return; } QXmlInputSource *xInSrc = new QXmlInputSource(); xInSrc->setData(reply->readAll()); QXmlSimpleReader *reader = new QXmlSimpleReader(); reader->setContentHandler(m_handler); reader->setErrorHandler(m_handler); reader->parse(xInSrc); }