本文整理汇总了C++中QXmlInputSource类的典型用法代码示例。如果您正苦于以下问题:C++ QXmlInputSource类的具体用法?C++ QXmlInputSource怎么用?C++ QXmlInputSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QXmlInputSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xmlParser
/// 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();
}
示例2: parse
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;
}
示例3: ReadSensors
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;
}
示例4: parseStyleFile
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;
}
示例5: 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();
}
示例6: parseInfoText
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');
}
示例7: applyTheme
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;
}
示例8: parseFilenamePattern
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();
}
示例9: setDefaultParameters
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";
}
示例10: parse_server_reply
/*!
* 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());
}
示例11: 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 = "";
}
示例12: 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);
}
}
}
示例13: ext_file
/* 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);
}
}
示例14: QXmlInputSource
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;
}
示例15: updateStats
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);
}