DeSR Dependency Parser

IXE::OptionStream Class Reference

Given the traditional argc and argv for command-line arguments, extract options from them following the stream model. More...

#include <OptionStream.h>

Collaboration diagram for IXE::OptionStream:

Collaboration graph

List of all members.

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

OptionStreamoperator>> (OptionStream &, Option &)
 Parse and extract an option from an option stream (argv values).


Detailed Description

Given the traditional argc and argv for command-line arguments, extract options from them following the stream model.

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.


Friends And Related Function Documentation

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 '-').

Parameters:
os The OptionStream to extract options from
o The option to deposit into.
Returns:
The passed-in OptionStream.

Definition at line 120 of file OptionStream.cpp.


The documentation for this class was generated from the following file:
 
Copyright © 2005-2007 G. Attardi. Generated on 13 Aug 2009 by doxygen 1.5.7.1.