本文整理汇总了C++中extensionsystem::PluginManager::parseOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ PluginManager::parseOptions方法的具体用法?C++ PluginManager::parseOptions怎么用?C++ PluginManager::parseOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类extensionsystem::PluginManager
的用法示例。
在下文中一共展示了PluginManager::parseOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
#if QT_VERSION < 0x050000
// Removed in Qt5
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
app.setApplicationName(BINARY_NAME);
app.setOrganizationName(BINARY_NAME);
app.setApplicationVersion(PACKAGE_VERSION);
QStringList args = qApp->arguments();
if (args.contains("--version") ||
args.contains("-version") ||
args.contains("-v")) {
std::cout << qPrintable(VERSION_MESSAGE);
return 0;
}
if (args.contains("--help") ||
args.contains("-help") ||
args.contains("-h")) {
std::cout << qPrintable(HELP_MESSAGE);
return 0;
}
// Create plugins manager
ExtensionSystem::PluginManager pluginManager;
pluginManager.setFileExtension(QString("pluginspec"));
// Getting & feeding libraries/plugins path
QStringList libpath;
#ifdef LIBRARY_BASENAME
libpath << Utils::applicationPluginsPath(QString(BINARY_NAME), QString(LIBRARY_BASENAME));
#else
libpath << Utils::applicationPluginsPath(QString(BINARY_NAME), "");
#endif
if (libpath.isEmpty())
return 123;
pluginManager.setPluginPaths(libpath);
// Add some debugging information
Utils::Log::logCompilationConfiguration();
// Manage plugin manager options
QStringList arguments = app.arguments(); // adapted arguments list is passed to plugin manager later
QMap<QString, QString> foundAppOptions;
if (arguments.size() > 1) {
QMap<QString, bool> appOptions;
QString errorMessage;
if (!pluginManager.parseOptions(arguments, appOptions, &foundAppOptions, &errorMessage)) {
// qWarning() << errorMessage;
// qWarning() << HELP_MESSAGE;
// return -1;
}
}
const PluginSpecSet plugins = pluginManager.plugins();
ExtensionSystem::PluginSpec *coreplugin = 0;
if (WarnAllPluginSpecs) {
foreach (ExtensionSystem::PluginSpec *spec, plugins) {
qWarning() << "PluginSpecs :::"<< spec->filePath() << spec->name() << spec->version();
}
}
foreach (ExtensionSystem::PluginSpec *spec, plugins) {
if (spec->name() == QString(COREPLUGINSNAME)) {
coreplugin = spec;
break;
}
}
ExtensionSystem::PluginSpec *userplugin = 0;
foreach (ExtensionSystem::PluginSpec *spec, plugins) {
if (spec->name() == QString(USERPLUGINSNAME)) {
userplugin = spec;
break;
}
}
if (!coreplugin) {
const QString reason = QCoreApplication::translate("Application", "Couldn't find 'Core.pluginspec' in %1").arg(qApp->libraryPaths().join("; "));
qWarning() << reason;
// displayError(msgCoreLoadFailure(reason));
return 1;
}
if (!userplugin) {
const QString reason = QCoreApplication::translate("Application", "Couldn't find 'UserManager.pluginspec' in %1").arg(qApp->libraryPaths().join("; "));
qWarning() << reason;
// displayError(msgCoreLoadFailure(reason));
return 1;
}
if (coreplugin->hasError()) {
qWarning() << coreplugin->errorString();
//.........这里部分代码省略.........
示例2: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
#if QT_VERSION < 0x050000
// Removed in Qt5
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
app.setApplicationName(BINARY_NAME);
app.setOrganizationName(BINARY_NAME);
app.setApplicationVersion(PACKAGE_VERSION);
QStringList args = qApp->arguments();
if (args.contains("--version") ||
args.contains("-version") ||
args.contains("-v")) {
std::cout << qPrintable(VERSION_MESSAGE);
return 0;
}
if (args.contains("--help") ||
args.contains("-help") ||
args.contains("-h")) {
std::cout << qPrintable(HELP_MESSAGE);
return 0;
}
// Create plugins manager
ExtensionSystem::PluginManager pluginManager;
pluginManager.setFileExtension(QString("pluginspec"));
// Getting & feeding libraries/plugins path
QStringList libpath;
#ifdef LIBRARY_BASENAME
libpath << Utils::applicationPluginsPath(QString(BINARY_NAME), QString(LIBRARY_BASENAME));
#else
libpath << Utils::applicationPluginsPath(QString(BINARY_NAME), "");
#endif
if (libpath.isEmpty())
return 123;
pluginManager.setPluginPaths(libpath);
// Add some debugging information
Utils::Log::logCompilationConfiguration();
// Manage plugin manager options
QStringList arguments = app.arguments(); // adapted arguments list is passed to plugin manager later
QMap<QString, QString> foundAppOptions;
if (arguments.size() > 1) {
QMap<QString, bool> appOptions;
QString errorMessage;
if (!pluginManager.parseOptions(arguments, appOptions, &foundAppOptions, &errorMessage)) {
// qWarning() << errorMessage;
// qWarning() << HELP_MESSAGE;
// return -1;
}
}
const PluginSpecSet plugins = pluginManager.plugins();
ExtensionSystem::PluginSpec *coreplugin = 0;
if (WarnAllPluginSpecs) {
foreach (ExtensionSystem::PluginSpec *spec, plugins) {
qWarning() << "PluginSpecs :::"<< spec->filePath() << spec->name() << spec->version();
}
}
foreach (ExtensionSystem::PluginSpec *spec, plugins) {
if (spec->name() == QString(COREPLUGINSNAME)) {
coreplugin = spec;
break;
}
}
if (!coreplugin) {
const QString reason = QCoreApplication::translate("Application", "Couldn't find 'Core.pluginspec' in %1").arg(qApp->libraryPaths().join("; "));
qWarning() << reason;
return 1;
}
if (coreplugin->hasError()) {
qWarning() << coreplugin->errorString();
return 1;
}
pluginManager.loadPlugins();
if (WarnAllPluginSpecs) {
foreach (ExtensionSystem::PluginSpec *spec, plugins) {
qWarning() << "PluginSpecs :::"<< spec->name() << "hasError:" << spec->hasError() << spec->errorString();
}
}
if (coreplugin->hasError()) {
qWarning() << coreplugin->errorString();
return 1;
}
// shutdown plugin manager on the exit
//.........这里部分代码省略.........