本文整理汇总了C++中XmlParser::exception方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlParser::exception方法的具体用法?C++ XmlParser::exception怎么用?C++ XmlParser::exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlParser
的用法示例。
在下文中一共展示了XmlParser::exception方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EngineException
Engine::Engine(QFileInfo& fileAlbum) throw(EngineException*) :
m_dirty(false),
m_fileAlbum(new QFileInfo(fileAlbum)),
m_uid(0),
m_fileSystemScanner(new FileSystemScanner(this)),
m_nextSourceDirId(1),
m_sourceDirDict(new QIntDict<Folder>()),
m_sourceDirs(new QPtrList<Folder>()),
m_nextTagNodeId(1),
m_tagNodeDict(new QIntDict<TagNode>()),
m_tagForest(new QPtrList<TagNode>()),
m_exifTitleTag(0),
m_fileDict(new QDict<File>()),
m_fileList(new QPtrList<File>()),
m_fileList2display(new QPtrList<File>())
{
tracer->sinvoked(__func__) << "with file '" << m_fileAlbum->absFilePath() << "'" << endl;
// if file does not exist, we have nothing to do
//if (!m_fileAlbum->exists()) {
QString msg = QString("File '%1' does not exist.").arg(m_fileAlbum->absFilePath());
tracer->serror(__func__) << msg << endl;
throw new EngineException(msg, "no detailmessage");
//}
QFile file(m_fileAlbum->absFilePath());
// close the file if it is open already
if (file.isOpen()) {
file.close();
}
// open the file for reading
if (!file.open( IO_ReadOnly )) {
QString msg = QString("Could not open file '%1'.").arg(file.name());
tracer->serror(__func__) << msg << ": " << file.errorString() << endl;
throw new EngineException(msg, file.errorString());
}
// prepare input source
QXmlInputSource xmlInputSource(file);
// instantiate the parser
XmlParser parser = XmlParser(this);
// prepare the xml reader
QXmlSimpleReader reader;
// set the handler on the reader
reader.setContentHandler(&parser);
reader.setErrorHandler(&parser);
// parse the document
bool success = reader.parse(&xmlInputSource, false);
// close the file
file.close();
if (!success) {
tracer->serror(__func__) << "Error occured during parsing the file '" << file.name() << "'" << endl;
cleanUp();
if (parser.exception()) {
tracer->serror(__func__) << "exception occured: " << parser.exception()->message() << endl;
throw parser.exception();
} else {
throw new EngineException(i18n("Unknown error while parsing the xml file occured!"));
}
}
// generate a uid if the file does not contain one (for compatibility reason with version 0.0.5)
if (!m_uid) {
m_uid = generateUid();
}
// create the EXIF tagnode if it was not contained in the database (for compatibility reason with version 0.0.6)
if (m_exifTitleTag == 0) {
createExifTagNode();
}
// read the files in all sourcedirectories
if (Settings::generalRescanWhileStartup()) {
m_fileSystemScanner->rescan();
}
// trace a little
tracer->sdebug(__func__) << m_fileList->count() << " images added" << endl;
}