Main Page | Namespace List | Class List | File List | Namespace Members | Class Members | Related Pages

conf::Config Struct Reference

A structure for defining, storing and querying options. More...

#include <conf.hh>

List of all members.

Public Types

typedef std::map< unsigned
char, int > 
ShortMap
 A type for mapping short option names to option indices.

typedef std::map< std::string,
int > 
LongMap
 A type for mapping long option names to option indices.


Public Member Functions

 Config ()
 Create an empty config.

Configoperator() (unsigned char short_name, std::string long_name, std::string type="", std::string default_value="", std::string help="")
 Add a new option.

void parse (int argc, char *argv[])
 Parse command line arguments.

void read (FILE *file)
 Read a config file.

void check_required () const
 Check if all required options are specified.

std::string help_string () const
 Returns the usage information.

const Optionoperator[] (unsigned char short_name) const
 Get a value of an option.

const Optionoperator[] (std::string long_name) const
 Get a value of an option.


Public Attributes

std::vector< Optionoptions
 Options added to the configuration.

ShortMap short_map
 Mapping short names to options.

LongMap long_map
 Mapping long names to options.

std::vector< std::string > arguments
 Rest of the non-option arguments.

int longest_name_length
 The length of the longest long name.


Detailed Description

A structure for defining, storing and querying options.

Bug:
Reading options from a file is not implemented yet.


Member Function Documentation

Config & conf::Config::operator() unsigned char  short_name,
std::string  long_name,
std::string  type = "",
std::string  default_value = "",
std::string  help = ""
 

Add a new option.

Parameters:
short_name = the short name of the option used after a hyphen
long_name = the long name of the option used after two hyphens
type = a space seperated list of type specifiers:
  • "arg" = argument must follow the option
  • "must" = the argument must be specified by the user
default_value = the default value of the option
help = the help string of the option

void conf::Config::read FILE *  file  ) 
 

Read a config file.

Parameters:
file = file to read from


The documentation for this struct was generated from the following files:
Generated on Sat Feb 26 22:54:39 2005 for GoCam by doxygen 1.3.4