本文整理汇总了C++中QXmlSimpleReader::setErrorHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlSimpleReader::setErrorHandler方法的具体用法?C++ QXmlSimpleReader::setErrorHandler怎么用?C++ QXmlSimpleReader::setErrorHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlSimpleReader
的用法示例。
在下文中一共展示了QXmlSimpleReader::setErrorHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyTheme
bool KThemeManager::applyTheme(const KThemeDocument &kd)
{
// kDebug() << "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 {
kDebug() << QObject::tr("I can't analize the theme document") << endl;
ok = false;
}
return ok;
}
示例2: readXMLDir
bool MainHandler::readXMLDir(const char * xmlDirName)
{
m_xmlDirName = xmlDirName;
QString xmlFileName=m_xmlDirName+"/index.xml";
QFile xmlFile(xmlFileName);
//printf("Trying %s xmlFile.exists()=%d isReadable()=%d\n",
// xmlFileName.data(),xmlFile.exists(),xmlFile.isReadable());
if (xmlFile.exists())
{
ErrorHandler errorHandler;
QXmlInputSource source( xmlFile );
QXmlSimpleReader reader;
reader.setContentHandler( this );
reader.setErrorHandler( &errorHandler );
reader.parse( source );
dump();
return TRUE;
}
return FALSE;
}
示例3: load
/**
* \brief Opens the file at the given path
* \author Peter Grasch
* \param QString path
* If no path is given, we use the path given in the path-member
* \param QXmlDefaultHandler* handler
* This handler is used to parse the content. It is adviced to subclass QXmlDefaultHandler to provide the functionality
*/
void XMLSAXReader::load(QXmlDefaultHandler* handler, QString path)
{
if (!handler) return;
if (path.isEmpty()) path = this->path;
QIODevice *sourcefile = KFilterDev::deviceForFile(path,
KMimeType::findByFileContent(path)->name());
if ((!sourcefile) || (!sourcefile->open(QIODevice::ReadOnly)))
return;
QXmlInputSource source(sourcefile);
QXmlSimpleReader *reader = new QXmlSimpleReader();
reader->setContentHandler(handler);
reader->setErrorHandler(handler);
emit (loaded());
reader->parse(source);
}
示例4: mapFile
bool
PercussionMap::loadPercussionMap(const QString &filename)
{
QFile mapFile(filename);
bool ok = mapFile.open(QIODevice::ReadOnly);
// if (!ok)
// QMessageBox::critical(0, tr("Rosegarden"), tr("couldn't open file '%1'").arg(handler.errorString()));
QXmlInputSource source(&mapFile);
QXmlSimpleReader reader;
reader.setContentHandler(this);
reader.setErrorHandler(this);
ok = reader.parse(source);
// if (!ok)
// QMessageBox::critical(0, tr("Rosegarden"), tr("couldn't parse chord dictionary : %1").arg(handler.errorString()));
return ok;
}
示例5: main
int main(int argc, char **argv)
{
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " <filename>" << std::endl;
return 1;
}
QFile *file = new QFile(argv[1]);
//! [0]
QXmlSimpleReader xmlReader;
QXmlInputSource *source = new QXmlInputSource(file);
//! [0]
//! [1]
Handler *handler = new Handler;
xmlReader.setContentHandler(handler);
xmlReader.setErrorHandler(handler);
//! [1]
//! [2]
bool ok = xmlReader.parse(source);
if (!ok)
std::cout << "Parsing failed." << std::endl;
//! [2]
else {
QStringList names = handler->names();
QList<int> indentations = handler->indentations();
int items = names.count();
for (int i = 0; i < items; ++i) {
for (int j = 0; j < indentations[i]; ++j)
std::cout << " ";
std::cout << names[i].toLocal8Bit().constData() << std::endl;
}
}
return 0;
}
示例6: parse
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);
}
示例7: parseCommandPattern
const QString PatternParser::parseCommandPattern(const QString& pattern,
const QString& input, const QString& output,
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, CachedImage *cover,
bool fatcompatible, const QString& tmppath, const QString& encoder, const bool demomode) {
SaxHandler handler;
handler.setInputFile(input);
handler.setOutputFile(output);
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.setCover(cover);
handler.setFAT32Compatible(fatcompatible);
handler.setTMPPath(tmppath);
handler.setDemoMode(demomode);
handler.set2DigitsTrackNum(false);
handler.setEncoder(encoder);
QXmlInputSource inputSource;
inputSource.setData("<commandpattern>"+p_xmlize_pattern(pattern)+"</commandpattern>");
QXmlSimpleReader reader;
reader.setContentHandler(&handler);
reader.setErrorHandler(&handler);
reader.parse(inputSource);
return handler.text();
}
示例8: loadAnnotationConfigurationFile
void AnnoqtConfEditor::loadAnnotationConfigurationFile(const QString& fileName)
{
if (fileName.isEmpty())
return;
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, tr("Annotation Tool"),
tr("Cannot read file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
return;
}
m_currentAnnotationConfigurationFile = fileName;
m_listWidget->clear();
m_colors.clear();
setWindowModified( false );
QList<QString> recursiveEntityTypes;
AnnotationConfigurationHandler handler(m_listWidget, &m_colors, &m_colorNames2EntityTypes, &recursiveEntityTypes, true);
QXmlSimpleReader reader;
reader.setContentHandler(&handler);
reader.setErrorHandler(&handler);
QXmlInputSource xmlInputSource(&file);
if (reader.parse(xmlInputSource))
statusBar()->showMessage(tr("Annotation Configuration File loaded"), 2000);
for (QMap<QString, QString>::const_iterator it=m_colorNames2EntityTypes.begin();
it != m_colorNames2EntityTypes.end(); it++)
{
m_entityNames2Types.insert(it.value(),m_entityNames2Types.size());
m_entityTypes2Names.insert(m_entityNames2Types.size()-1,it.value());
m_entityTypes2ColorNames.insert(m_entityNames2Types[it.value()],it.key());
}
statusBar()->showMessage( tr( "Loaded configuration file " ) + fileName );
}
示例9: open
void Robot::open(const QString& fileName, bool verbose) throw(KinematicModelException)
{
//printf("Robot.Open()\n");
ZPHandler handler( model, this );
QXmlSimpleReader reader;
reader.setContentHandler(&handler);
reader.setErrorHandler(&handler);
QFile file(fileName);
//printf("set up xml parser\n");
if ( !file.open(QFile::ReadOnly | QFile::Text) )
{
QString errStr = "failed to open file '";
errStr.append(fileName);
errStr.append("'");
throw KinematicModelException(errStr);
} //else printf("text file found\n");
QXmlInputSource xmlInputSource( &file );
if ( !reader.parse( xmlInputSource ) )
{
QString errStr = "failed to create robot '";
errStr.append(getName());
errStr.append("' from file '");
errStr.append(fileName);
errStr.append("'");
throw KinematicModelException(errStr);
} //else printf("text file parsed\n");
//printf("Parsed the robot file\n");
ignoreAdjacentPairs();
home();
printf("Created Robot: %s (%d kinematic tree nodes, %d primitives)\n",getName().toStdString().c_str(), numCompositObjects, getNumPrimitives());
isConfigured = true;
}
示例10: 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();
}
示例11: open
void MainWindow::open()
{
#if defined(Q_OS_SYMBIAN)
// Look for bookmarks on the same drive where the application is installed to,
// if drive is not read only. QDesktopServices::DataLocation does this check,
// and returns writable drive.
QString bookmarksFolder =
QDesktopServices::storageLocation(QDesktopServices::DataLocation).left(1);
bookmarksFolder.append(":/Data/qt/saxbookmarks");
QDir::setCurrent(bookmarksFolder);
#endif
QString fileName =
QFileDialog::getOpenFileName(this, tr("Open Bookmark File"),
QDir::currentPath(),
tr("XBEL Files (*.xbel *.xml)"));
if (fileName.isEmpty())
return;
treeWidget->clear();
XbelHandler handler(treeWidget);
QXmlSimpleReader reader;
reader.setContentHandler(&handler);
reader.setErrorHandler(&handler);
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, tr("SAX Bookmarks"),
tr("Cannot read file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
return;
}
QXmlInputSource xmlInputSource(&file);
if (reader.parse(xmlInputSource))
statusBar()->showMessage(tr("File loaded"), 2000);
}
示例12: addSeasons
void CriticalPowerWindow::addSeasons()
{
QFile seasonFile(home.absolutePath() + "/seasons.xml");
QXmlInputSource source( &seasonFile );
QXmlSimpleReader xmlReader;
SeasonParser( handler );
xmlReader.setContentHandler(&handler);
xmlReader.setErrorHandler(&handler);
bool ok = xmlReader.parse( source );
if(!ok)
qWarning("Failed to parse seasons.xml");
seasons = handler.getSeasons();
Season season;
season.setName("All Seasons");
seasons.insert(0,season);
for (int i = 0; i < seasons.size(); ++i)
{
season = seasons.at(i);
cComboSeason->addItem(season.getName());
}
}
示例13: requestFinishedSlot
void QQTMRequester::requestFinishedSlot(QNetworkReply * reply)
{
if(reply->error() == QNetworkReply::NoError)
{
QByteArray data = reply->readAll();
QXmlSimpleReader xmlReader;
QXmlInputSource xmlSource;
xmlSource.setData(data);
xmlReader.setContentHandler(m_xmlParser);
xmlReader.setErrorHandler(m_xmlParser);
xmlReader.parse(xmlSource);
}
else
{
qDebug() << Q_FUNC_INFO << "reply->error() =" << reply->error() << ", " << reply->errorString();
emit requestFinished();
}
m_netReply = NULL;
reply->deleteLater();
}
示例14: parse
//bool Parser::parse(ParserTypes which, QFile &file, MusicCollection *collection) {
bool MusicCollectionIO::parse(QFile &file, MusicCollection *collection) {
/*
switch ( which ) {
case ITUNES: {
*/
iTunesXmlHandler parser(collection);
QXmlSimpleReader reader;
reader.setContentHandler(&parser);
reader.setErrorHandler(&parser);
QXmlInputSource xmlInputSource(&file);
return reader.parse(xmlInputSource);
/*
}
case MARCSV:
case MARXML:
default:
return false;
}
*/
}
示例15: readXMLFile
bool MainFrm::readXMLFile(const QString strFileName)
{
//TODO: add some XML semantic validation?
//SessionFileParser *handler=new SessionFileParser(sSample);
if (handler!=0) {delete handler; handler=0;}
handler=new SessionFileParser(sSample);
QFile file( strFileName );
QXmlInputSource source( &file );
QXmlSimpleReader reader;
reader.setContentHandler( handler );
reader.setErrorHandler(handler);
if (!reader.parse( source )){
//delete handler; handler=0;
return false;
}
//delete handler; handler=0;
return true;
}