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


C++ ProgramArgs类代码示例

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


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

示例1: addArgs

void QfitReader::addArgs(ProgramArgs& args)
{
    args.add("flip_coordinates", "Flip coordinates from 0-360 to -180-180",
        m_flip_x);
    args.add("scale_z", "Z scale. Use 0.001 to go from mm to m",
        m_scale_z, 0.001);
}
开发者ID:Rafaelaniemann,项目名称:PDAL,代码行数:7,代码来源:QfitReader.cpp

示例2: validateSwitches

void TIndexKernel::validateSwitches(ProgramArgs& args)
{
    if (m_merge)
    {
        if (!m_wkt.empty() && !m_bounds.empty())
            throw pdal_error("Can't specify both 'polygon' and "
                "'bounds' options.");
        if (!m_bounds.empty())
            m_wkt = m_bounds.toWKT();
        if (m_filespec.empty())
            throw pdal_error("No output filename provided.");
        StringList invalidArgs;
        invalidArgs.push_back("a_srs");
        invalidArgs.push_back("src_srs_name");
        for (auto arg : invalidArgs)
            if (args.set(arg))
            {
                std::ostringstream out;

                out << "option '" << arg << "' not supported during merge.";
                throw pdal_error(out.str());
            }
    }
    else
    {
        if (m_filespec.empty() && !m_usestdin)
            throw pdal_error("No input pattern specified");
        if (args.set("polygon"))
            throw pdal_error("'polygon' option not supported when building "
                "index.");
        if (args.set("bounds"))
            throw pdal_error("'bounds' option not supported when building "
                "index.");
    }
}
开发者ID:jasonoverland,项目名称:PDAL,代码行数:35,代码来源:TIndexKernel.cpp

示例3: addArgs

void NumpyReader::addArgs(ProgramArgs& args)
{
    args.add("dimension", "In an unstructured array, the dimension name to "
        "map to values.", m_defaultDimension, "Intensity");
    m_orderArg = &args.add("order", "Order of dimension interpretation "
        "of the array.  Either 'row'-major (C) or 'column'-major (Fortran)",
        m_order);
}
开发者ID:connormanning,项目名称:PDAL,代码行数:8,代码来源:NumpyReader.cpp

示例4: addArgs

void MyWriter::addArgs(ProgramArgs& args)
{
    // setPositional() Makes the argument required.
    args.add("filename", "Output filename", m_filename).setPositional();
    args.add("newline", "Line terminator", m_newline, "\n");
    args.add("datafield", "Data field", m_datafield, "UserData");
    args.add("precision", "Precision", m_precision, 3);
}
开发者ID:gadomski,项目名称:PDAL,代码行数:8,代码来源:MyWriter.cpp

示例5: addSwitches

void HeightAboveGroundKernel::addSwitches(ProgramArgs& args)
{
    args.add("use_classification,c", "Use existing classification labels?",
        m_use_classification);
    args.add("input,i", "Input filename", m_input_file).setPositional();
    args.add("ground,g", "Ground filename", m_ground_file).setPositional();
    args.add("output,o",
        "Output filename", m_output_file).setOptionalPositional();
}
开发者ID:EricAlex,项目名称:PDAL,代码行数:9,代码来源:HeightAboveGroundKernel.cpp

示例6: outputHelp

void Kernel::outputHelp(ProgramArgs& args)
{
    std::cout << "usage: " << "pdal " << m_appName << " [options] " <<
        args.commandLine() << std::endl;

    std::cout << "options:" << std::endl;
    args.dump(std::cout, 2, Utils::screenWidth());

    //ABELL - Fix me.

    std::cout <<"\nFor more information, see the full documentation for "
        "PDAL at http://pdal.io/\n" << std::endl;
}
开发者ID:OldMogy,项目名称:PDAL,代码行数:13,代码来源:Kernel.cpp

示例7: TEST

TEST(OptionsTest, nan)
{
    ProgramArgs args;
    double value;

    args.add("value", "Not a number", value);

    Options ops;
    ops.add("value", std::numeric_limits<double>::quiet_NaN());

    StringList cmdline = ops.toCommandLine();
    EXPECT_NO_THROW(args.parse(cmdline));
}
开发者ID:pblottiere,项目名称:PDAL,代码行数:13,代码来源:OptionsTest.cpp

示例8: parseArgs

bool DimBuilder::parseArgs(int argc, char *argv[])
{
    ProgramArgs args;

    args.add("input,i", "Filename of JSON specification of "
        "dimensions", m_input).setPositional();
    args.add("output,o", "Filename of output of C++ header representation of "
        "provided JSON.", m_output).setPositional();
    try
    {
        args.parse(argc, argv);
    }
    catch (arg_error& err)
    {
        std::cerr << err.m_error << "\n";
        return false;
    }
    return true;
}
开发者ID:EricAlex,项目名称:PDAL,代码行数:19,代码来源:DimBuilder.cpp

示例9: doSwitches

void Kernel::doSwitches(int argc, const char *argv[], ProgramArgs& args)
{
    StringList stringArgs;
    OptionsMap& stageOptions = m_manager.stageOptions();

    // Scan the argument vector for extra stage options.  Pull them out and
    // stick them in the list.  Let the ProgramArgs handle everything else.
    // NOTE: This depends on the format being "option=value" rather than
    //   "option value".  This is what we've always expected, so no problem,
    //   but it would be better to be more flexible.
    for (int i = 0; i < argc; ++i)
    {
        std::string stageName, opName, value;

        if (parseOption(argv[i], stageName, opName, value))
        {
            Option op(opName, value);
            stageOptions[stageName].add(op);
        }
        else
            stringArgs.push_back(argv[i]);
    }

    try
    {
        addBasicSwitches(args);

        // parseSimple allows us to scan for the help option without
        // raising exception about missing arguments and so on.
        args.parseSimple(stringArgs);
        addSwitches(args);
        if (!m_showHelp)
        {
            args.reset();
            args.parse(stringArgs);
        }
    }
    catch (arg_error& e)
    {
        throw pdal_error(e.m_error);
    }
}
开发者ID:OldMogy,项目名称:PDAL,代码行数:42,代码来源:Kernel.cpp

示例10: f

void App::outputOptions(std::string const& stageName, std::ostream& strm)
{
    // Force plugin loading.
    StageFactory f(false);

    Stage* s = f.createStage(stageName);
    if (!s)
    {
        std::cerr << "Unable to create stage " << stageName << "\n";
        return;
    }

    ProgramArgs args;
    s->addAllArgs(args);

    if (!m_showJSON)
    {
        strm  << stageName << " -- " << PluginManager<Stage>::link(stageName) <<
            std::endl;
        strm  << headline << std::endl;

        args.dump2(strm , 2, 6, headline.size());
    }
    else
    {
        std::ostringstream ostr;
        args.dump3(ostr);

        NL::json array;
        try
        {
            array = NL::json::parse(ostr.str());
        }
        catch (NL::json::parse_error)
        {}

        NL::json object = { stageName, array };
        strm  << object;
    }
}
开发者ID:PDAL,项目名称:PDAL,代码行数:40,代码来源:pdal.cpp

示例11: addBasicSwitches

void Kernel::addBasicSwitches(ProgramArgs& args)
{
    args.add("help,h", "Print help message", m_showHelp);

    args.add("debug,d", "Enable debug mode", m_isDebug);
    args.add("developer-debug",
        "Enable developer debug (don't trap exceptions)", m_hardCoreDebug);
    args.add("label", "A string to label the process with", m_label);
    args.add("verbose,v", "Set verbose message level", m_verboseLevel);

    args.add("visualize", "Visualize result", m_visualize);
    args.add("stdin,s", "Read pipeline JSON from stdin", m_usestdin);
    args.add("scale",
         "A comma-separated or quoted, space-separated list of scales to "
         "set on the output file: \n--scale 0.1,0.1,0.00001\n--scale \""
         "0.1 0.1 0.00001\"", m_scales);
    args.add("offset",
         "A comma-separated or quoted, space-separated list of offsets to "
         "set on the output file: \n--offset 0,0,0\n--offset "
         "\"1234 5678 91011\"", m_offsets);
}
开发者ID:OldMogy,项目名称:PDAL,代码行数:21,代码来源:Kernel.cpp

示例12: outputHelp

void App::outputHelp(const ProgramArgs& args)
{
    m_out << "Usage:" << std::endl;
    m_out << "  pdal <options>" << std::endl;
    m_out << "  pdal <command> <command options>" << std::endl;

    args.dump(m_out, 2, 80);
    m_out << std::endl;

    m_out << "The following commands are available:" << std::endl;

    // Load all kernels so that we can report the names.
    StageFactory f;
    PluginManager<Kernel>::loadAll();
    outputCommands("  - ");
    m_out << std::endl;
    m_out << "See http://pdal.io/apps/ for more detail" << std::endl;
}
开发者ID:PDAL,项目名称:PDAL,代码行数:18,代码来源:pdal.cpp

示例13: addArgs

void TextReader::addArgs(ProgramArgs& args)
{
    args.add("separator", "Separator character that overrides special "
        "character in header line", m_separator, ' ');
}
开发者ID:pblottiere,项目名称:PDAL,代码行数:5,代码来源:TextReader.cpp

示例14: addSwitches

void FauxPluginKernel::addSwitches(ProgramArgs& args)
{
    args.add("fakearg", "Fake argument", m_fakeArg).setPositional();
}
开发者ID:PDAL,项目名称:PDAL,代码行数:4,代码来源:FauxPluginKernel.cpp

示例15: execute

int App::execute(StringList& cmdArgs, LogPtr& log)
{
    ProgramArgs args;

    addArgs(args);
    try
    {
        args.parseSimple(cmdArgs);
    }
    catch (arg_val_error const& e)
    {
        Utils::printError(e.what());
        return -1;
    }

    log.reset(new Log("PDAL", m_log, m_logtiming));
    if (m_logLevel != LogLevel::None)
        log->setLevel(m_logLevel);
    else if (m_debug)
        log->setLevel(LogLevel::Debug);
    log->get(LogLevel::Debug) << "Debugging..." << std::endl;
    PluginManager<Stage>::setLog(log);
    PluginManager<Kernel>::setLog(log);
#ifndef _WIN32
    if (m_debug)
    {
        signal(SIGSEGV, [](int sig)
        {
            logPtr->get(LogLevel::Debug) << "Segmentation fault (signal 11)\n";
            StringList lines = Utils::backtrace();

            for (const auto& l : lines)
                logPtr->get(LogLevel::Debug) << l << std::endl;
            exit(1);
        });
    }
#endif

    m_command = Utils::tolower(m_command);
    if (!m_command.empty())
    {
        int ret = 0;
        std::string name("kernels." + m_command);

        Kernel *kernel = PluginManager<Kernel>::createObject(name);
        if (kernel)
        {
            if (m_help)
                cmdArgs.push_back("--help");
            // This shouldn't throw.  If it does, it's something awful, so
            // not cleaning up seems inconsequential.
            log->setLeader("pdal " + m_command);
            ret = kernel->run(cmdArgs, log);
            delete kernel;
            // IMPORTANT - The kernel must be destroyed before GDAL
            //  drivers are unregistered or GDAL will attempt to destroy
            //  resources more than once, resulting in a crash.
            gdal::unregisterDrivers();
        }
        else
            log->get(LogLevel::Error) << "Command '" << m_command <<
                "' not recognized" << std::endl << std::endl;
        return ret;
    }

    if (m_showVersion)
        outputVersion();
    else if (m_showDrivers)
        outputDrivers();
    else if (m_showOptions.size())
    {
        if (m_showOptions == "all")
            outputOptions();
        else
            outputOptions(m_showOptions, m_out);
    }
    else
        outputHelp(args);
    return 0;
}
开发者ID:PDAL,项目名称:PDAL,代码行数:80,代码来源:pdal.cpp


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