The Lean Mean C++ Option Parser
testodr1.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 (testodr1.cc) to the extent possible under the law.
5  */
6 
23 #include "optionparser.h"
24 #include "optionparser.h" //intentionally included twice
25 
26 #include <cstdio>
27 
28 using option::Option;
29 using option::Descriptor;
30 
31 extern const Descriptor usage[];
32 
33 extern bool bar(int argc, const char* argv[])
34 {
35  printUsage(std::fwrite, stdout, usage);
36  option::Stats stats(usage, argc, argv);
37  option::Option buffer [stats.buffer_max];
38  option::Option options[stats.options_max];
39  option::Parser parse(usage, argc, argv, options, buffer);
40  return parse.error();
41 }
42 
43 int main()
44 {
45  Descriptor d = usage[0];
46  std::printf("%s",d.shortopt);
47 }
48 
49 
50 
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...
const char *const shortopt
Each char in this string will be accepted as a short option character.
Definition: optionparser.h:358
A parsed option from the command line together with its argument if it has one.
Definition: optionparser.h:442
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...