The Lean Mean C++ Option Parser
testodr2.cc
Go to the documentation of this file.
1 /* Written 2012 by Matthias S. Benkmann
2  *
3  * The author hereby waives all copyright and related rights to the contents
4  * of this example file (testodr2.cc) to the extent possible under the law.
5  */
6 
13 #include "optionparser.h"
14 
15 #include <cstdio>
16 
17 using option::Descriptor;
18 using option::Arg;
19 enum OptionIndex {CREATE};
20 enum OptionType {DISABLE, ENABLE, OTHER};
21 
22 extern const Descriptor usage[] = {
23  { CREATE, OTHER,
24  "c", "create",
25  Arg::None,
26  "--create\t\t\tTells the program to create something."
27  }
28  };
29 
30 extern bool foo(int argc, const char* argv[])
31 {
32  printUsage(std::fwrite, stdout, usage);
33  option::Stats stats(usage, argc, argv);
34  option::Option buffer [stats.buffer_max];
35  option::Option options[stats.options_max];
36  option::Parser parse(usage, argc, argv, options, buffer);
37  return parse.error();
38 }
39 
Determines the minimum lengths of the buffer and options arrays used for Parser.
Definition: optionparser.h:950
This is the only file required to use The Lean Mean C++ Option Parser. Just #include it and you&#39;re se...
static ArgStatus None(const Option &, bool)
For options that don&#39;t take an argument: Returns ARG_NONE.
Definition: optionparser.h:926
A parsed option from the command line together with its argument if it has one.
Definition: optionparser.h:442
Functions for checking the validity of option arguments.
Definition: optionparser.h:923
Checks argument vectors for validity and parses them into data structures that are easier to work wit...
Describes an option, its help text (usage) and how it should be parsed.
Definition: optionparser.h:315
void printUsage(OStream &prn, const Descriptor usage[], int width=80, int last_column_min_percent=50, int last_column_own_line_max_percent=75)
Outputs a nicely formatted usage string with support for multi-column formatting and line-wrapping...