libsdr  0.1.0
A simple SDR library
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
sdr::Options Class Reference

Convenience functions for command line arguments. More...

#include <options.hh>

Classes

struct  Definition
 Argument definition. More...
 
class  Value
 The argument value. More...
 

Public Types

enum  ArgType { FLAG, INTEGER, FLOAT, ANY }
 Possible argument types. More...
 

Public Member Functions

 Options ()
 Empty constructor. More...
 
bool has (const char *name)
 Returns true if the specified option was found (long name). More...
 
const Valueget (const char *name)
 Returns the argument of the specified option (long name). More...
 

Static Public Member Functions

static bool parse (const Definition defs[], int argc, char *argv[], Options &options)
 Parse the given arguments (argc, argv) using the definitions defs and stores the results into options. More...
 
static void print_help (std::ostream &stream, const Definition defs[])
 Serializes a help text derived from given the definitions into stream. More...
 

Protected Attributes

std::map< std::string, Value_options
 The table of option names and argument values. More...
 

Detailed Description

Convenience functions for command line arguments.

Member Enumeration Documentation

Possible argument types.

Enumerator
FLAG 

No argument (flag).

INTEGER 

Integer argument.

FLOAT 

Floating point argument.

ANY 

Any argument (string).

Constructor & Destructor Documentation

Options::Options ( )

Empty constructor.

Member Function Documentation

const Options::Value & Options::get ( const char *  name)

Returns the argument of the specified option (long name).

bool Options::has ( const char *  name)

Returns true if the specified option was found (long name).

bool Options::parse ( const Definition  defs[],
int  argc,
char *  argv[],
Options options 
)
static

Parse the given arguments (argc, argv) using the definitions defs and stores the results into options.

Returns false on error.

void Options::print_help ( std::ostream &  stream,
const Definition  defs[] 
)
static

Serializes a help text derived from given the definitions into stream.

Member Data Documentation

std::map<std::string, Value> sdr::Options::_options
protected

The table of option names and argument values.


The documentation for this class was generated from the following files: