本文整理汇总了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);
}
示例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.");
}
}
示例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);
}
示例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);
}
示例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();
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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;
}
示例13: addArgs
void TextReader::addArgs(ProgramArgs& args)
{
args.add("separator", "Separator character that overrides special "
"character in header line", m_separator, ' ');
}
示例14: addSwitches
void FauxPluginKernel::addSwitches(ProgramArgs& args)
{
args.add("fakearg", "Fake argument", m_fakeArg).setPositional();
}
示例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;
}