int main(int argc, char *argv[]) { IQmol::IQmolApplication iqmol(argc, argv); Q_INIT_RESOURCE(IQmol); // Setup logging; QsLogging::Logger& logger = QsLogging::Logger::instance(); logger.setLoggingLevel(QsLogging::TraceLevel); QString const logFile(IQmol::Preferences::LogFilePath()); // Weird scoping going on here QsLogging::DestinationPtr fileDestination; if (IQmol::Preferences::LoggingEnabled()) { fileDestination = QsLogging::DestinationFactory::MakeFileDestination(logFile); logger.addDestination(fileDestination.get()); #ifdef Q_WS_WIN if (Preferences::LogFileHidden()) { int fileHidden(0x2); // Where is FILE_ATTRIBUTE_HIDDEN defined? WCHAR* fnam = (WCHAR*)logFile.constData(); SetFileAttributes(fnam, fileHidden); } #endif } QLOG_INFO() << "---------- Session Started ----------"; QLOG_INFO() << "IQmol Version: " << IQMOL_VERSION; QStringList args(QCoreApplication::arguments()); args.removeFirst(); // This ensures we always have something to open if (args.isEmpty()) args.push_back(""); iqmol.queueOpenFiles(args); int ret(iqmol.exec()); QLOG_INFO() << "Return code:" << ret; QLOG_INFO() << "----------- Session Ended -----------"; return ret; }
void parse(int argc, char* argv[]) { QApplication app(argc, argv); QStringList args(QCoreApplication::arguments()); const QString usage("Usage:\n Parser [-a][-d] filename"); QString input; bool debugLogFile(false); bool archiveFile(false); if (args.size() <= 1) throw usage; for (int i = 1; i < args.size(); ++i) { if (args[i] == "-d") { debugLogFile = true; }else if (args[i] == "-a") { archiveFile = true; }else { input = args[i]; break; } } if (input.isEmpty()) throw usage; // Setup logging. There is some weird scoping problem if we add any of the // following into the if (debugLogFile) clause. QsLogging::Logger& logger = QsLogging::Logger::instance(); logger.setLoggingLevel(QsLogging::TraceLevel); logger.setDateStamp(false); QString logFile(input + ".log"); QsLogging::DestinationPtr fileDestination; if (debugLogFile) { fileDestination = QsLogging::DestinationFactory::MakeFileDestination(logFile); logger.addDestination(fileDestination.get()); qInstallMsgHandler(myMessageHandler); } initOpenBabel(); Parser::ParseFile parseFile(input); parseFile.start(); parseFile.wait(); QStringList errors(parseFile.errors()); if (!errors.isEmpty()) { qDebug() << "Error parsing file:" << input; QStringList::iterator iter; for (iter = errors.begin(); iter != errors.end(); ++iter) { qDebug() << " " << *iter; } return; } Data::Bank const& data (parseFile.data()); data.dump(); // Save an IQmol archive if (archiveFile) { QString output(input + ".iqmol"); Parser::IQmol iqmol; iqmol.saveData(output, const_cast<Data::Bank&>(data)); } }