DeSR Dependency Parser |
#include <OptionStream.h>
Classes | |
class | Option |
Public Member Functions | |
OptionStream (int argc, char *argv[], Options::spec const [], std::ostream &=std::cerr) | |
int | shift () const |
operator bool () const | |
Friends | |
OptionStream & | operator>> (OptionStream &, Option &) |
Parse and extract an option from an option stream (argv values). |
RATIONALE
Why not use the standard getopt() or GNU's getopt_long()? Because neither are thread-safe and I needed a thread-safe version.
Definition at line 92 of file OptionStream.h.
OptionStream& operator>> | ( | OptionStream & | os, | |
OptionStream::Option & | o | |||
) | [friend] |
Parse and extract an option from an option stream (argv values).
Options begin with either a '-' for short options or a "--" for long options. Either a '-' or "--" by itself explicitly ends the options; however, the difference is that '-' is returned as the first non-option whereas "--" is skipped entirely.
When there are no more options, the OptionStream converts to bool as false. The OptionStream's shift() member is the number of options parsed which the caller can use to adjust argc and argv.
Short options can take an argument either as the remaining characters of the same argv or in the next argv unless the next argv looks like an option by beginning with a '-').
Long option names can be abbreviated so long as the abbreviation is unambiguous. Long options can take an argument either directly after a '=' in the same argv or in the next argv (but without an '=') unless the next argv looks like an option by beginning with a '-').
os | The OptionStream to extract options from | |
o | The option to deposit into. |
Definition at line 120 of file OptionStream.cpp.