当前位置: 首页>>代码示例>>C++>>正文


C++ QCommandLineParser::errorText方法代码示例

本文整理汇总了C++中QCommandLineParser::errorText方法的典型用法代码示例。如果您正苦于以下问题:C++ QCommandLineParser::errorText方法的具体用法?C++ QCommandLineParser::errorText怎么用?C++ QCommandLineParser::errorText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QCommandLineParser的用法示例。


在下文中一共展示了QCommandLineParser::errorText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char ** argv)
{
    QUrl source("qrc:view.qml");

    QGuiApplication app(argc, argv);

    QCommandLineParser parser;
#ifndef QT_NO_NETWORKPROXY
    QCommandLineOption proxyHostOption("host", "The proxy host to use.", "host");
    parser.addOption(proxyHostOption);
    QCommandLineOption proxyPortOption("port", "The proxy port to use.", "port", "0");
    parser.addOption(proxyPortOption);
#endif // !QT_NO_NETWORKPROXY
    parser.addPositionalArgument("file", "The file to use.");
    QCommandLineOption helpOption = parser.addHelpOption();
    parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
    QStringList arguments = QCoreApplication::arguments();
    if (!parser.parse(arguments)) {
        qWarning() << parser.helpText() << '\n' << parser.errorText();
        exit(1);
    }
    if (parser.isSet(helpOption)) {
        qWarning() << parser.helpText();
        exit(0);
    }
#ifndef QT_NO_NETWORKPROXY
    if (parser.isSet(proxyHostOption))
        proxyHost = parser.value(proxyHostOption);
    if (parser.isSet(proxyPortOption)) {
        bool ok = true;
        proxyPort = parser.value(proxyPortOption).toInt(&ok);
        if (!ok || proxyPort < 1 || proxyPort > 65535) {
            qWarning() << parser.helpText() << "\nNo valid port given. It should\
                          be a number between 1 and 65535";
            exit(1);
        }
    }
#endif // !QT_NO_NETWORKPROXY
    if (parser.positionalArguments().count() == 1)
        source = QUrl::fromLocalFile(parser.positionalArguments().first());

    QQuickView view;
    view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory);

    view.setSource(source);
    view.show();

    return app.exec();
}
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:49,代码来源:main.cpp

示例2: testUnknownOptionErrorHandling

void tst_QCommandLineParser::testUnknownOptionErrorHandling()
{
    QFETCH(QCommandLineParser::SingleDashWordOptionMode, parsingMode);
    QFETCH(QStringList, args);
    QFETCH(QStringList, expectedUnknownOptionNames);
    QFETCH(QString, expectedErrorText);

    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    parser.setSingleDashWordOptionMode(parsingMode);
    QVERIFY(parser.addOption(QCommandLineOption(QStringList() << "b" << "bool", QStringLiteral("a boolean option"))));
    QCOMPARE(parser.parse(args), expectedErrorText.isEmpty());
    QCOMPARE(parser.unknownOptionNames(), expectedUnknownOptionNames);
    QCOMPARE(parser.errorText(), expectedErrorText);
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:15,代码来源:tst_qcommandlineparser.cpp

示例3: parseCommandLine

void parseCommandLine()
{
  QCommandLineParser parser;
  parser.setApplicationDescription("An Ask Mona browser.");
  const auto helpOption = parser.addHelpOption();
  const auto versionOption = parser.addVersionOption();
  QCommandLineOption dataDirectoryOption(QStringList() << "d" << "datadir", "All data are saved into <directory>. Default is application directory.", "directory");
  parser.addOption(dataDirectoryOption);
  QCommandLineOption langOption(QStringList() << "l" << "lang", "Set application language.", "language");
  parser.addOption(langOption);

  if (!parser.parse(QCoreApplication::arguments())) {
    cout << qPrintable(parser.errorText()) << endl;
    exit(1);
  }
  if (parser.isSet(versionOption)) {
    cout << qPrintable(QCoreApplication::applicationName()) << " " << qPrintable(QCoreApplication::applicationVersion()) << endl;
    exit(0);
  }
  if (parser.isSet(helpOption)) {
    parser.showHelp();
    exit(0);
  }
  if (parser.isSet(dataDirectoryOption)) {
    setDataDir(parser.value(dataDirectoryOption));
  }
  auto translater = new QTranslator();
  QLocale l = QLocale::system();
  if (parser.isSet(langOption)) {
    l = QLocale(parser.value(langOption));
  }
  if (translater->load(l, ":/translations/")) {
    qApp->installTranslator(translater);
  } else {
    qWarning() << "Couldn't load language" << l.name();
  }
}
开发者ID:keystore00,项目名称:AskMona-qt,代码行数:37,代码来源:main.cpp

示例4: parseCommandLine

bool Settings::parseCommandLine()
{
    QCommandLineParser parser;
    parser.setApplicationDescription("MapMaker\n\n"
                                     "Usage: mapmaker -m map.json -i imagesDirectory");
    parser.addHelpOption();
    parser.addVersionOption();

    QCommandLineOption mapFilenameOption(QStringList() << "m" << "map",
                                         tr("Map filename"),
                                         /* valueName */ tr("map.mmj"),
                                         /* defaultValue */ QString());
    parser.addOption(mapFilenameOption);

    QCommandLineOption imagesDirectoryOption(QStringList() << "i" << "imgdir",
                                             tr("Images directory"),
                                             /* valueName */ tr("directory"),
                                             /* defaultValue */ QString());
    parser.addOption(imagesDirectoryOption);

    if (parser.parse(qApp->arguments())) {
        parser.process(qApp->arguments());
    } else {
        qerr << parser.errorText() << endl;
    }

    if (!parser.positionalArguments().isEmpty())
        mapFilename_ = parser.positionalArguments().first();

    QString mapFilename = parser.value(mapFilenameOption);
    if (!mapFilename.isEmpty())
        mapFilename_ = mapFilename;
    commandline_.imagesDirectory_ = parser.value(imagesDirectoryOption);

    return true;
}
开发者ID:zmeyc,项目名称:mapmaker,代码行数:36,代码来源:Settings.cpp

示例5: parseCommandLine

// Parse the command line a use options to override the MapConfig defaults
bool parseCommandLine(MapConfig& config, QString& error)
{
    QCommandLineParser parser;
    const QCommandLineOption helpOption = parser.addHelpOption();

    QCommandLineOption server(QStringList() << "s" << "server-url",
            QCoreApplication::translate("main", "Map tile server URL with trailing /"),
            QCoreApplication::translate("main", "URL"));
    parser.addOption(server);

    QCommandLineOption format(QStringList() << "f" << "image-format",
            QCoreApplication::translate("main", "Map tile image format (e.g. png)"),
            QCoreApplication::translate("main", "format"));
    parser.addOption(format);
    
    QCommandLineOption min_zoom(QStringList() << "min-zoom",
            QCoreApplication::translate("main", "Map minimum zoom level"),
            QCoreApplication::translate("main", "zoom"));
    parser.addOption(min_zoom);

    QCommandLineOption max_zoom(QStringList() << "max-zoom",
            QCoreApplication::translate("main", "Map maximum zoom level"),
            QCoreApplication::translate("main", "zoom"));
    parser.addOption(max_zoom);

    QCommandLineOption tile_size(QStringList() << "t" << "tile-size",
            QCoreApplication::translate("main", "Map tile size in pixels (e.g. 256)"),
            QCoreApplication::translate("main", "size"));
    parser.addOption(tile_size);

    QCommandLineOption cache_size(QStringList() << "c" << "cache-size",
            QCoreApplication::translate("main", "Map tile cache size in tiles (e.g. 512)"),
            QCoreApplication::translate("main", "cache"));
    parser.addOption(cache_size);

    if (!parser.parse(QGuiApplication::arguments())) {
        error = parser.errorText();
        return true;
    }

    if (parser.isSet(helpOption)) {
        parser.showHelp();
        return false;
    }

    if (parser.isSet(server)) {
        QString s = parser.value(server);
        QHostInfo info = QHostInfo::fromName(s);
        if (info.error() == QHostInfo::NoError) {
            config.server = s;
        } else {
            qDebug() << "Invalid map tile server URL: " << s;
        }
    }
    if (parser.isSet(format)) {
        config.format = parser.value(format);
    }
    if (parser.isSet(min_zoom)) {
        QVariant range(parser.value(min_zoom));
        config.min_zoom = range.toInt();
    }
    if (parser.isSet(max_zoom)) {
        QVariant range(parser.value(max_zoom));
        config.max_zoom = range.toInt();
    }
    if (parser.isSet(tile_size)) {
        QVariant range(parser.value(tile_size));
        config.tile_size = range.toInt();
    }
    if (parser.isSet(cache_size)) {
        QVariant range(parser.value(cache_size));
        config.cache_size = size_t(range.toInt());
    }
    return false;
}
开发者ID:QtOpenGL,项目名称:qtmapviewer_with_OpenGL,代码行数:76,代码来源:main.cpp

示例6: splitOption

VHACDUtilApp::VHACDUtilApp(int argc, char* argv[]) :
    QCoreApplication(argc, argv)
{
    vhacd::VHACDUtil vUtil;

    // parse command-line
    QCommandLineParser parser;
    parser.setApplicationDescription("High Fidelity Object Decomposer");
    parser.addHelpOption();

    const QCommandLineOption helpOption = parser.addHelpOption();

    const QCommandLineOption splitOption("split", "split input-file into one mesh per output-file");
    parser.addOption(splitOption);

    const QCommandLineOption fattenFacesOption("f", "fatten faces");
    parser.addOption(fattenFacesOption);

    const QCommandLineOption generateHullsOption("g", "output convex hull approximations");
    parser.addOption(generateHullsOption);

    const QCommandLineOption inputFilenameOption("i", "input file", "filename.fbx");
    parser.addOption(inputFilenameOption);

    const QCommandLineOption outputFilenameOption("o", "output file", "filename.obj");
    parser.addOption(outputFilenameOption);

    const QCommandLineOption outputCentimetersOption("c", "output units are centimeters");
    parser.addOption(outputCentimetersOption);

    const QCommandLineOption startMeshIndexOption("s", "start-mesh index", "0");
    parser.addOption(startMeshIndexOption);

    const QCommandLineOption endMeshIndexOption("e", "end-mesh index", "0");
    parser.addOption(endMeshIndexOption);

    const QCommandLineOption minimumMeshSizeOption("m", "minimum mesh (diagonal) size to consider", "0");
    parser.addOption(minimumMeshSizeOption);

    const QCommandLineOption maximumMeshSizeOption("x", "maximum mesh (diagonal) size to consider", "0");
    parser.addOption(maximumMeshSizeOption);

    const QCommandLineOption vHacdResolutionOption("resolution", "Maximum number of voxels generated during the "
                                                   "voxelization stage (range=10,000-16,000,000)", "100000");
    parser.addOption(vHacdResolutionOption);

    const QCommandLineOption vHacdDepthOption("depth", "Maximum number of clipping stages. During each split stage, parts "
                                              "with a concavity higher than the user defined threshold are clipped "
                                              "according the \"best\" clipping plane (range=1-32)", "20");
    parser.addOption(vHacdDepthOption);


    const QCommandLineOption vHacdAlphaOption("alpha", "Controls the bias toward clipping along symmetry "
                                              "planes (range=0.0-1.0)", "0.05");
    parser.addOption(vHacdAlphaOption);

    const QCommandLineOption vHacdBetaOption("beta", "Controls the bias toward clipping along revolution "
                                             "axes (range=0.0-1.0)", "0.05");
    parser.addOption(vHacdBetaOption);

    const QCommandLineOption vHacdGammaOption("gamma", "Controls the maximum allowed concavity during the "
                                              "merge stage (range=0.0-1.0)", "0.00125");
    parser.addOption(vHacdGammaOption);

    const QCommandLineOption vHacdDeltaOption("delta", "Controls the bias toward maximaxing local "
                                              "concavity (range=0.0-1.0)", "0.05");
    parser.addOption(vHacdDeltaOption);

    const QCommandLineOption vHacdConcavityOption("concavity", "Maximum allowed concavity (range=0.0-1.0)", "0.0025");
    parser.addOption(vHacdConcavityOption);

    const QCommandLineOption vHacdPlanedownsamplingOption("planedownsampling", "Controls the granularity of the search for"
                                                          " the \"best\" clipping plane (range=1-16)", "4");
    parser.addOption(vHacdPlanedownsamplingOption);

    const QCommandLineOption vHacdConvexhulldownsamplingOption("convexhulldownsampling", "Controls the precision of the "
                                                               "convex-hull generation process during the clipping "
                                                               "plane selection stage (range=1-16)", "4");
    parser.addOption(vHacdConvexhulldownsamplingOption);

    // pca
    // mode

    const QCommandLineOption vHacdMaxVerticesPerCHOption("maxvertices", "Controls the maximum number of triangles per "
                                                         "convex-hull (range=4-1024)", "64");
    parser.addOption(vHacdMaxVerticesPerCHOption);

    // minVolumePerCH
    // convexhullApproximation


    if (!parser.parse(QCoreApplication::arguments())) {
        qCritical() << parser.errorText() << endl;
        parser.showHelp();
        Q_UNREACHABLE();
    }

    if (parser.isSet(helpOption)) {
        parser.showHelp();
        Q_UNREACHABLE();
//.........这里部分代码省略.........
开发者ID:CryptArc,项目名称:hifi,代码行数:101,代码来源:VHACDUtilApp.cpp

示例7: main

int main(int argc, char* argv[])
{
    qInstallMessageHandler(messageHandler);

    Application application(argc, argv);
    application.setApplicationName("CasparCG Client");
    application.setApplicationVersion(QString("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION).arg(REVISION_VERSION).arg(BUILD_VERSION));

    qDebug("Starting %s %s", qPrintable(application.applicationName()), qPrintable(application.applicationVersion()));

    CommandLineArgs args;
    QCommandLineParser parser;
    switch (parseCommandLine(parser, &args))
    {
        case CommandLineOk:
            break;
        case CommandLineError:
            qCritical("Unable to parse command line: %s", qPrintable(parser.errorText()));
            parser.showHelp();
            return 0;
        case CommandLineVersionRequested:
            parser.showVersion();
            return 0;
        case CommandLineHelpRequested:
            parser.showHelp();
            return 0;
    }

    QSplashScreen splashScreen(QPixmap(":/Graphics/Images/SplashScreen.png"));
    splashScreen.show();

    loadDatabase(&args);
    DatabaseManager::getInstance().initialize();

    loadStyleSheets(application);
    loadFonts(application);

    EventManager::getInstance().initialize();
    GpiManager::getInstance().initialize();

    MainWindow window;
    splashScreen.finish(&window);

    loadConfiguration(application, window, &args);

    window.show();

    LibraryManager::getInstance().initialize();
    DeviceManager::getInstance().initialize();
    AtemDeviceManager::getInstance().initialize();
    TriCasterDeviceManager::getInstance().initialize();
    OscDeviceManager::getInstance().initialize();
    OscWebSocketManager::getInstance().initialize();

    int returnValue = application.exec();

    EventManager::getInstance().uninitialize();
    DatabaseManager::getInstance().uninitialize();
    GpiManager::getInstance().uninitialize();
    OscWebSocketManager::getInstance().uninitialize();
    OscDeviceManager::getInstance().uninitialize();
    TriCasterDeviceManager::getInstance().uninitialize();
    AtemDeviceManager::getInstance().uninitialize();
    DeviceManager::getInstance().uninitialize();
    LibraryManager::getInstance().uninitialize();

    return returnValue;
}
开发者ID:gdsellerPd,项目名称:Client,代码行数:68,代码来源:Main.cpp

示例8: out

bool
parseCommandLine( QCoreApplication& app, QCommandLineParser& parser, CliOptions& options, qint32& profileId,
                  QString& errmsg )
{
    parser.setApplicationDescription( "RedTimer Command Line Interface" );

    // Commands
    QMap<QString,QString> commands;
    commands.insert( "create", "Create a new issue" );
    commands.insert( "issue",  "Get the current issue ID" );
    commands.insert( "start",  "Start issue tracking" );
    commands.insert( "stop",   "Stop issue tracking" );

    QStringList descr;
    QMapIterator<QString, QString> cmd( commands );
    while( cmd.hasNext() )
    {
        cmd.next();

        QString data;
        QTextStream out( &data );
        out.setFieldAlignment( QTextStream::AlignLeft );
        out << qSetFieldWidth(10) << cmd.key() << cmd.value();
        descr.push_back( data );
    }

    parser.addPositionalArgument( "command", descr.join("\n"), "create|issue|start|stop" );

    // Program parameters
    parser.addOption( {"profile-id", "Redmine instance to send the command to", "ID"} );

    // Command parameters
    parser.addOption( {"assignee-id",        "Redmine assignee ID",      "ID"} );
    parser.addOption( {"issue-id",           "Redmine issue ID",         "ID"} );
    parser.addOption( {"parent-id",          "Redmine parent issue ID",  "ID"} );
    parser.addOption( {"project-id",         "Redmine project ID",       "ID"} );
    parser.addOption( {"tracker-id",         "Redmine tracker ID",       "ID"} );
    parser.addOption( {"version-id",         "Redmine version ID",       "ID"} );
    parser.addOption( {"external-id",        "External issue ID",        "text"} );
    parser.addOption( {"external-parent-id", "External parent issue ID", "text"} );
    parser.addOption( {"subject",            "Issue subject",            "text"} );
    parser.addOption( {"description",        "Issue description",        "text"} );

    // General parameters
    parser.addHelpOption();
    parser.addVersionOption();

    // Process command line options
    if( !parser.parse(app.arguments()) )
    {
        errmsg = parser.errorText();
        return false;
    }

    if( parser.isSet("help") )
        return false;


    // Get the command

    const QStringList positionalArguments = parser.positionalArguments();

    if( positionalArguments.isEmpty() )
    {
        errmsg = "No command specified.";
        return false;
    }

    if( positionalArguments.size() > 1 )
    {
        errmsg = "Several commands specified.";
        return false;
    }

    options.command = positionalArguments.first();

    if( commands.find(options.command) == commands.end() )
    {
        errmsg = QString("Command '%1' not found.").arg(options.command);
        return false;
    }

    auto getNumericId = [&]( const QString& option, qint32& id )
    {
        if( !parser.isSet(option) )
            return true;

        QString idString = parser.value( option );
        bool ok;
        id = idString.toInt( &ok );

        if( !ok )
        {
            errmsg = QString("Option '--%1' expects a numeric ID.").arg(option);
            return false;
        }

        return true;
    };

//.........这里部分代码省略.........
开发者ID:fathomssen,项目名称:redtimer,代码行数:101,代码来源:main.cpp

示例9: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QCommandLineParser parser;
    parser.addHelpOption();
    parser.addOptions({
            { "nogui", QString("Using command line arguments, do not show GUI.") },
            { { "p", "path" }, QString("Path for job files or shape files."), QString("path") },
            { { "g", "align" }, QString("Input is not aligned. Find lowest cost alignment.") },
            { { "s", "sourceShape" }, QString("Path for source shape file."), QString("source") },
            { { "t", "targetShape" }, QString("Path for target shape file."), QString("target") },
            { { "a", "auto" }, QString("Automatically try to find initial correspondence. Not used for job files.") },
			{ { "j", "job" }, QString("Job file to load."), QString("job") },
			{ { "f", "folder" }, QString("Folder for a shape dataset."), QString("folder") },
            { { "z", "output" }, QString("Folder for output JSON file."), QString("output") },
			{ { "q", "quiet" }, QString("Skip visualization.") },
            { { "m", "asymmetry" }, QString("Ignore symmetry groups. Used for evaluation.") },

            /* Actual paramteres */
            { { "k", "k" }, QString("(k) parameter for DP search."), QString("k") },
            { { "o", "roundtrip" }, QString("Compute least cost from source to target, and target to source.") },
            { { "c", "cut" }, QString("Allow part cuts/joins.") },

			/* Experiments */
			{ { "e", "experiment" }, QString("Perform hard coded experiments.") },
	});

    if (!parser.parse(QCoreApplication::arguments())) {
        QString errorText = parser.errorText();
        std::cout << qPrintable(errorText);
        return CommandLineError;
    }
	else
		parser.process(a);

	QString path = parser.value("p");
	QDir::setCurrent(path);

	/// Experiments:
	if (parser.isSet("e"))
	{
		QVariantMap options;
        //options["k"].setValue(6);
        //options["isQuietMode"].setValue(true);
		options["isOutputMatching"].setValue(true);
		options["isSaveReport"].setValue(true);
		options["isLogJobs"].setValue(true);

		QString sourceShape = "C:/Development/GeoTopo/standalone/ChairWood2/Woodchair2.xml";
		QString targetShape = "C:/Development/GeoTopo/standalone/chairVK2110/chair2110.xml";

		srand(time(nullptr));

        for (int i = 0; i < 1; i++)
		{
			auto bp = QSharedPointer<BatchProcess>(new BatchProcess(sourceShape, targetShape, options));
			bp->jobUID = (double(rand()) / RAND_MAX) * 10;
			bp->run();

			for (auto & report : bp->jobReports){
				int time = report["search_time"].toInt();
				double c = report["min_cost"].toDouble();

				std::cout << "cost = " << c << " , time = " << time << std::endl;
			}

			//std::swap(sourceShape, targetShape);
		}

		return 0;
	}

    /// Process shape sets:
    if(parser.isSet("folder"))
    {
		QElapsedTimer timer; timer.start();

        QString dataset = parser.value("folder");
        QDir d("");
        QString dir_name = QDir(dataset).dirName();

		// 1) get sorted set of pairs to compare
        QVector< QPair<int, int> > shapePairs;
		auto folders = shapesInDataset(dataset);
		auto folderKeys = folders.keys();
		for (int i = 0; i < folderKeys.size(); i++)
			for (int j = i + 1; j < folderKeys.size(); j++)
                shapePairs << qMakePair(i,j);
		int shapePairsCount = shapePairs.size();
		int curShapePair = 0;

        QMap< QString,QPair<int,int> > pair_idx;

		// 2) perform correspondence for shape pairs
		{
			// Remove previous log file
			d.remove("log.txt");

			// go over pairs
//.........这里部分代码省略.........
开发者ID:gideonmay,项目名称:GeoTopo,代码行数:101,代码来源:main.cpp

示例10: parseCommandLine

CommandLineParseResult parseCommandLine(QCommandLineParser &parser, CLOptions *options, QString *errorMessage)
{

    parser.addPositionalArgument("log", QCoreApplication::translate("main", "File where the log will be saved."));

    // A file bname (-f, --force)
    const QCommandLineOption forceOption(QStringList() << "f" << "force",
                                         QCoreApplication::translate("main", "Force log file overwrite if applicable."));

    parser.addOption(forceOption);

    // The voltageToCurrent gain (-g, --gain)
    const QCommandLineOption gainOption(QStringList() << "g" << "gain",
                                        QCoreApplication::translate("main", "Microamps per volt setting for electrode activation circuit."),
                                        QCoreApplication::translate("main", "currentGain"));
    parser.addOption(gainOption);

    // Help and version options
    const QCommandLineOption helpOption = parser.addHelpOption();
    const QCommandLineOption versionOption = parser.addVersionOption();

    if (!parser.parse(QCoreApplication::arguments())) {
        *errorMessage = parser.errorText();
        return CommandLineError;
    }

    if (parser.isSet(versionOption))
        return CommandLineVersionRequested;

    if (parser.isSet(helpOption))
        return CommandLineHelpRequested;

    if (parser.isSet(forceOption)) {
        options->force = true;
    }
    else
    {
        options->force = false;
    }


    const QStringList positionalArguments = parser.positionalArguments();
    if (positionalArguments.isEmpty()) {
        *errorMessage = "A save location for the log file was not provided.";
        return CommandLineError;
    }
    if (positionalArguments.size() > 1) {
        *errorMessage = "Several 'log' arguments specified.";
        return CommandLineError;
    }

    QString fname = positionalArguments.first();
    if (!fname.endsWith(".json")) {
        fname.append(".json");
    }

    options->fid = QFileInfo(fname);

    if (!QDir(options->fid.absoluteDir()).exists() ) {
        *errorMessage = "Selected log file save directory does not exist: " + options->fid.path();
        return CommandLineError;
    }
    if (options->fid.exists() && options->fid.isFile() && !options->force) {
        *errorMessage = "Selected log file already exists, use the -f option if you wish to overwrite: " + options->fid.absoluteFilePath();
        return CommandLineError;
    }

    if (parser.isSet(gainOption)) {
        const double gain = parser.value(gainOption).toDouble();
        if (gain < 0) {
            *errorMessage = "The voltage to current gain cannot be negative,";
            return CommandLineError;
        }
        options->currentGain = gain;
    }
    else
    {
        cout << "Warning: no current gain was not provided. Assuming 10uA/3.3V." << endl;
        options->currentGain = 10.0/3.3;
    }

    return CommandLineOk;
}
开发者ID:balajisriram,项目名称:impedance,代码行数:83,代码来源:main.cpp

示例11: parseCommandLine

CommandLineParseResult parseCommandLine(QCommandLineParser &parser, const QStringList &arguments, ParsedOptions &options) {
    QCommandLineOption basePackageOption(QStringList() << "b" << "base-package",
                                        "Path to the base package dir",
                                        "directory");
    parser.addOption(basePackageOption);

    QCommandLineOption newPackageOption(QStringList() << "n" << "new-package",
                                        "Path to the new package dir",
                                        "directory");
    parser.addOption(newPackageOption);

    QCommandLineOption outputOption(QStringList() << "o" << "output",
                                        "Path to the result package file",
                                        "filepath");
    parser.addOption(outputOption);

    const QCommandLineOption helpOption = parser.addHelpOption();

    CommandLineParseResult result = CommandLineError;

    do {
        if (!parser.parse(arguments)) {
            std::cerr << parser.errorText().toStdString();
            break;
        }

        if (parser.isSet(helpOption)) {
            result = CommandLineHelpRequested;
            break;
        }

        if (parser.isSet(basePackageOption)) {
            const QString baseDir = parser.value(basePackageOption);
            if (!QDir(baseDir).exists()) {
                std::cerr << "Directory not found: " << baseDir.toStdString();
                break;
            } else {
                options.m_BaseDir = baseDir;
            }
        } else {
            std::cerr << "Base package path is missing" << std::endl;
            break;
        }

        if (parser.isSet(newPackageOption)) {
            const QString newDir = parser.value(newPackageOption);
            if (!QDir(newDir).exists()) {
                std::cerr << "Directory not found: " << newDir.toStdString();
                break;
            } else {
                options.m_NewDir = newDir;
            }
        } else {
            std::cerr << "New package path is missing" << std::endl;
            break;
        }

        if (parser.isSet(outputOption)) {
            options.m_JsonPath = parser.value(outputOption);
        } else {
            options.m_JsonPath = DEFAULT_OUTPUT_NAME;
        }
    } while (false);

    return result;
}
开发者ID:Ribtoks,项目名称:heap,代码行数:66,代码来源:main.cpp

示例12: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
	
	QCommandLineParser parser;
    parser.addHelpOption();
    parser.addPositionalArgument("file", QCoreApplication::translate("main", "The file to open."));
    parser.addOptions({
        { { "c", "curve" }, QString("Extract a curve.") },
        { { "s", "sheet" }, QString("Extract a sheet.") },
        { { "b", "box" }, QString("Uses bounding box.") },
		{ { "n", "nonmanifold" }, QString("Object is not clean.") },
		{ { "h", "concavehull" }, QString("Reconstruct using concavehull.") },
		{ { "v", "voxelize" }, QString("Reconstruct using voxels.") },
		{ { "r", "remesh" }, QString("Remesh to increase density.") },
		{ { "m", "medial" }, QString("Follow medial axis during skeletonization.") },
		{ { "f", "features" }, QString("Respect small features.") },
		{ { "V", "voxelparam" }, QString("Voxels size."), QString("voxel_param") },
		{ { "R", "remeshparam" }, QString("Remesh size."), QString("remesh_param") }
    });

	if (!parser.parse(QCoreApplication::arguments())) {
        QString errorText = parser.errorText();
        std::cout << qPrintable(errorText);
        return CommandLineError;
    }
	else
		parser.process(a);

    if(QCoreApplication::arguments().size() == 1)
    {
        std::cout << qPrintable(parser.helpText());
        return CommandLineHelpRequested;
    }

    // Perform operations
    {
		double VoxelParam = 0.05, RemeshParam = 0.02;

		if (parser.isSet("voxelparam")) VoxelParam = parser.value("voxelparam").toDouble();
		if (parser.isSet("remeshparam")) RemeshParam = parser.value("remeshparam").toDouble();

        QString filename = parser.positionalArguments().at(0);
        nurbs_plugin plugin(filename, !parser.isSet("nonmanifold"), 
			parser.isSet("b"), parser.isSet("h"), parser.isSet("v"), 
			parser.isSet("r"), parser.isSet("m"), parser.isSet("f"),
			VoxelParam, RemeshParam);

		if (parser.isSet("curve"))
		{
			auto c = plugin.toCurve();

			// Save control points
			QFile file("curve_output.points");
			if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return CommandLineError;
			QTextStream out(&file);
			out << QString("%1\n").arg(c.GetNumCtrlPoints());
			for (auto p : c.mCtrlPoint) out << QString("%1 %2 %3\n").arg(p.x()).arg(p.y()).arg(p.z());
		}

		if (parser.isSet("sheet"))
		{
			auto s = plugin.toSheet();

			// Save control points
			QFile file("sheet_output.points");
			if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return CommandLineError;
			QTextStream out(&file);
			out << QString("%1\n").arg(s.mNumUCtrlPoints);
			out << QString("%1\n").arg(s.mNumVCtrlPoints);
			for (auto row : s.mCtrlPoint) 
				for (auto p : row)
					out << QString("%1 %2 %3\n").arg(p.x()).arg(p.y()).arg(p.z());
		}
    }

    return CommandLineOk;
}
开发者ID:aaronzou,项目名称:ddtt-dev,代码行数:78,代码来源:objToSkeleton.cpp

示例13: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QCoreApplication::setApplicationVersion(QT_VERSION_STR);
    QCoreApplication::setApplicationName(QStringLiteral("imagegestures"));
    QGuiApplication::setApplicationDisplayName(QStringLiteral("Image Gestures Example"));

    QCommandLineParser commandLineParser;
    const QCommandLineOption disablePanOption("no-pan", "Disable pan gesture");
    commandLineParser.addOption(disablePanOption);
    const QCommandLineOption disablePinchOption("no-pinch", "Disable pinch gesture");
    commandLineParser.addOption(disablePinchOption);
    const QCommandLineOption disableSwipeOption("no-swipe", "Disable swipe gesture");
    commandLineParser.addOption(disableSwipeOption);
    const QCommandLineOption helpOption = commandLineParser.addHelpOption();
    commandLineParser.addPositionalArgument(QStringLiteral("Directory"),
                                            QStringLiteral("Directory to display"));

    const QString description = QGuiApplication::applicationDisplayName()
        + QLatin1String("\n\nEnable \"debug\" on the logging category \"qt.examples.imagegestures\" in order to\n"
                        "in order to obtain verbose information about Qt's gesture event processing,\n"
                        "for example by setting the environment variables QT_LOGGING_RULES to\n"
                        "qt.examples.imagegestures.debug=true\n");
    commandLineParser.setApplicationDescription(description);

    if (!commandLineParser.parse(QCoreApplication::arguments())) {
        showHelp(commandLineParser, commandLineParser.errorText());
        return -1;
    }
    if (commandLineParser.isSet(helpOption)) {
        showHelp(commandLineParser);
        return 0;
    }

    QStringList arguments = commandLineParser.positionalArguments();
    if (!arguments.isEmpty() && !QFileInfo(arguments.front()).isDir()) {
        showHelp(commandLineParser,
                 QLatin1Char('"') + QDir::toNativeSeparators(arguments.front())
                 + QStringLiteral("\" is not a directory."));
        return -1;
    }

    QList<Qt::GestureType> gestures;
    if (!commandLineParser.isSet(disablePanOption))
        gestures << Qt::PanGesture;
    if (!commandLineParser.isSet(disablePinchOption))
        gestures << Qt::PinchGesture;
    if (!commandLineParser.isSet(disableSwipeOption))
        gestures << Qt::SwipeGesture;

    MainWidget w;
    w.grabGestures(gestures);
    w.show();

    if (arguments.isEmpty()) {
        const QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
        const QString directory =
            QFileDialog::getExistingDirectory(&w, "Select image folder",
                                              picturesLocations.isEmpty() ? QString() : picturesLocations.front());
        if (directory.isEmpty())
            return 0;
        arguments.append(directory);
    }

    w.openDirectory(arguments.front());

    return app.exec();
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:68,代码来源:main.cpp

示例14: verboseOutput

ATPClientApp::ATPClientApp(int argc, char* argv[]) :
    QCoreApplication(argc, argv)
{
    // parse command-line
    QCommandLineParser parser;
    parser.setApplicationDescription("High Fidelity ATP-Client");

    const QCommandLineOption helpOption = parser.addHelpOption();

    const QCommandLineOption verboseOutput("v", "verbose output");
    parser.addOption(verboseOutput);

    const QCommandLineOption uploadOption("T", "upload local file", "local-file-to-send");
    parser.addOption(uploadOption);

    const QCommandLineOption authOption("u", "set usename and pass", "username:password");
    parser.addOption(authOption);

    const QCommandLineOption outputFilenameOption("o", "output filename", "output-file-name");
    parser.addOption(outputFilenameOption);

    const QCommandLineOption domainAddressOption("d", "domain-server address", "127.0.0.1");
    parser.addOption(domainAddressOption);

    const QCommandLineOption listenPortOption("listenPort", "listen port", QString::number(INVALID_PORT));
    parser.addOption(listenPortOption);

    if (!parser.parse(QCoreApplication::arguments())) {
        qCritical() << parser.errorText() << endl;
        parser.showHelp();
        Q_UNREACHABLE();
    }

    if (parser.isSet(helpOption)) {
        parser.showHelp();
        Q_UNREACHABLE();
    }

    _verbose = parser.isSet(verboseOutput);
    if (!_verbose) {
        QLoggingCategory::setFilterRules("qt.network.ssl.warning=false");

        const_cast<QLoggingCategory*>(&networking())->setEnabled(QtDebugMsg, false);
        const_cast<QLoggingCategory*>(&networking())->setEnabled(QtInfoMsg, false);
        const_cast<QLoggingCategory*>(&networking())->setEnabled(QtWarningMsg, false);

        const_cast<QLoggingCategory*>(&shared())->setEnabled(QtDebugMsg, false);
        const_cast<QLoggingCategory*>(&shared())->setEnabled(QtInfoMsg, false);
        const_cast<QLoggingCategory*>(&shared())->setEnabled(QtWarningMsg, false);
    }

    QStringList posArgs = parser.positionalArguments();
    if (posArgs.size() != 1) {
        qDebug() << "give remote url argument";
        parser.showHelp();
        Q_UNREACHABLE();
    }

    _url = QUrl(posArgs[0]);
    if (_url.scheme() != "atp") {
        qDebug() << "url should start with atp:";
        parser.showHelp();
        Q_UNREACHABLE();
    }

    int domainPort = 40103;
    if (_url.port() != -1) {
        domainPort = _url.port();
    }

    if (parser.isSet(outputFilenameOption)) {
        _localOutputFile = parser.value(outputFilenameOption);
    }

    if (parser.isSet(uploadOption)) {
        _localUploadFile = parser.value(uploadOption);
    }

    if (parser.isSet(authOption)) {
        QStringList pieces = parser.value(authOption).split(":");
        if (pieces.size() != 2) {
            qDebug() << "-u should be followed by username:password";
            parser.showHelp();
            Q_UNREACHABLE();
        }

        _username = pieces[0];
        _password = pieces[1];
        _waitingForLogin = true;
    }

    if (parser.isSet(listenPortOption)) {
        _listenPort = parser.value(listenPortOption).toInt();
    }

    _domainServerAddress = QString("127.0.0.1") + ":" + QString::number(domainPort);
    if (parser.isSet(domainAddressOption)) {
        _domainServerAddress = parser.value(domainAddressOption);
    } else if (!_url.host().isEmpty()) {
        QUrl domainURL;
//.........这里部分代码省略.........
开发者ID:howard-stearns,项目名称:hifi,代码行数:101,代码来源:ATPClientApp.cpp

示例15: verboseOutput

ACClientApp::ACClientApp(int argc, char* argv[]) :
    QCoreApplication(argc, argv)
{
    // parse command-line
    QCommandLineParser parser;
    parser.setApplicationDescription("High Fidelity AC client");

    const QCommandLineOption helpOption = parser.addHelpOption();

    const QCommandLineOption verboseOutput("v", "verbose output");
    parser.addOption(verboseOutput);

    const QCommandLineOption authOption("u", "set usename and pass", "username:password");
    parser.addOption(authOption);

    const QCommandLineOption domainAddressOption("d", "domain-server address", "127.0.0.1");
    parser.addOption(domainAddressOption);

    const QCommandLineOption cacheSTUNOption("s", "cache stun-server response");
    parser.addOption(cacheSTUNOption);

    const QCommandLineOption listenPortOption("listenPort", "listen port", QString::number(INVALID_PORT));
    parser.addOption(listenPortOption);

    if (!parser.parse(QCoreApplication::arguments())) {
        qCritical() << parser.errorText() << endl;
        parser.showHelp();
        Q_UNREACHABLE();
    }

    if (parser.isSet(helpOption)) {
        parser.showHelp();
        Q_UNREACHABLE();
    }

    _verbose = parser.isSet(verboseOutput);
    if (!_verbose) {
        QLoggingCategory::setFilterRules("qt.network.ssl.warning=false");

        const_cast<QLoggingCategory*>(&networking())->setEnabled(QtDebugMsg, false);
        const_cast<QLoggingCategory*>(&networking())->setEnabled(QtInfoMsg, false);
        const_cast<QLoggingCategory*>(&networking())->setEnabled(QtWarningMsg, false);

        const_cast<QLoggingCategory*>(&shared())->setEnabled(QtDebugMsg, false);
        const_cast<QLoggingCategory*>(&shared())->setEnabled(QtInfoMsg, false);
        const_cast<QLoggingCategory*>(&shared())->setEnabled(QtWarningMsg, false);
    }
    

    QString domainServerAddress = "127.0.0.1:40103";
    if (parser.isSet(domainAddressOption)) {
        domainServerAddress = parser.value(domainAddressOption);
    }

    if (_verbose) {
        qDebug() << "domain-server address is" << domainServerAddress;
    }

    int listenPort = INVALID_PORT;
    if (parser.isSet(listenPortOption)) {
        listenPort = parser.value(listenPortOption).toInt();
    }

    if (parser.isSet(authOption)) {
        QStringList pieces = parser.value(authOption).split(":");
        if (pieces.size() != 2) {
            qDebug() << "-u should be followed by username:password";
            parser.showHelp();
            Q_UNREACHABLE();
        }

        _username = pieces[0];
        _password = pieces[1];
    }

    DependencyManager::registerInheritance<LimitedNodeList, NodeList>();

    DependencyManager::set<AccountManager>([&]{ return QString("Mozilla/5.0 (HighFidelityACClient)"); });
    DependencyManager::set<AddressManager>();
    DependencyManager::set<NodeList>(NodeType::Agent, listenPort);

    auto accountManager = DependencyManager::get<AccountManager>();
    accountManager->setIsAgent(true);
    accountManager->setAuthURL(NetworkingConstants::METAVERSE_SERVER_URL());

    auto nodeList = DependencyManager::get<NodeList>();

    // setup a timer for domain-server check ins
    QTimer* domainCheckInTimer = new QTimer(nodeList.data());
    connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn);
    domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);

    // start the nodeThread so its event loop is running
    // (must happen after the checkin timer is created with the nodelist as it's parent)
    nodeList->startThread();

    const DomainHandler& domainHandler = nodeList->getDomainHandler();
    connect(&domainHandler, SIGNAL(domainURLChanged(QUrl)), SLOT(domainChanged(QUrl)));
    connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ACClientApp::domainConnectionRefused);

//.........这里部分代码省略.........
开发者ID:Menithal,项目名称:hifi,代码行数:101,代码来源:ACClientApp.cpp


注:本文中的QCommandLineParser::errorText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。