Shapeworks Studio
2.1
Shape analysis software suite
|
Classes | |
class | Callback |
class | Option |
class | OptionGroup |
class | OptionParser |
class | str_wrap |
class | Value |
Class for automatic conversion from string -> anytype. More... | |
class | Values |
Typedefs | |
typedef std::map< std::string, std::string > | strMap |
typedef std::map< std::string, std::list< std::string > > | lstMap |
typedef std::map< std::string, Option const * > | optMap |
Variables | |
const char *const | SUPPRESS_HELP = "SUPPRESS" "HELP" |
const char *const | SUPPRESS_USAGE = "SUPPRESS" "USAGE" |
Copyright (C) 2010 Johannes Weißl jargo License: your favourite BSD-style license n@mo lb.or g
git clone http://github.com/weisslj/cpp-optparse.git
This is yet another option parser for C++. It is modelled after the excellent Python optparse API. Although incomplete, anyone familiar to optparse should feel at home: http://docs.python.org/library/optparse.html
Design decisions:
Why not use getopt/getopt_long?
Why not use Boost.Program_options?
Why not use tclap/Opag/Options/CmdLine/Anyoption/Argument_helper/...?
Future work:
Python only features:
Example:
using optparse::OptionParser;
OptionParser parser = OptionParser() .description("just an example");
parser.add_option("-f", "--file") .dest("filename") .help("write report to FILE") .metavar("FILE"); parser.add_option("-q", "--quiet") .action("store_false") .dest("verbose") .set_default("1") .help("don't print status messages to stdout");
optparse::Values options = parser.parse_args(argc, argv); vector<string> args = parser.args();
if (options.get("verbose")) cout << options["filename"] << endl;