Main   Classes   Namespace members   Examples   Recipes   Rationale   Related pages

boost::program_options::config_file Class Reference

Standalone parser for config files in ini-line format:. More...

#include <config_file.hpp>

List of all members.

Public Member Functions

 config_file (std::istream &is, bool validate=true)
 Creates a config file parser for the specified stream.

 config_file (const std::string &filename, bool validate=true)
 Creates a config file parser for the specified file.

void add_option (const char *name)
 Adds another allowed option.

 operator bool () const
 Returns true if there's another option to extract, i.e.

config_file & operator++ ()
 Moves to the next option assignment in this file.

const std::string & name () const
 Returns the option name for the current assignment.

const std::string & value () const
 Return the value for the current assignment.


Detailed Description

Standalone parser for config files in ini-line format:.

Config file can not contain arguments.

The actuall variable name is constructed by combining current section name and variable name, with dot between. If section_name already contains dot at the end, new dot is not inserted. For example:

         [gui.accessibility]
         visual_bell=yes
         
will result in option "gui.accessibility.visual_bell" with value "yes" been returned.


Constructor & Destructor Documentation

boost::program_options::config_file::config_file std::istream &    is,
bool    validate = true
 

Creates a config file parser for the specified stream.

If 'validate' is set to false, allows all options.

boost::program_options::config_file::config_file const std::string &    filename,
bool    validate = true
 

Creates a config file parser for the specified file.


Member Function Documentation

void boost::program_options::config_file::add_option const char *    name
 

Adds another allowed option.

If the 'name' ends with '*', then all options with the same prefix are allowed. For example, if 'name' is 'foo*', then 'foo1' and 'foo_bar' are allowed.

boost::program_options::config_file::operator bool   const
 

Returns true if there's another option to extract, i.e.

if name() and value() are valid. Is false immediately after construction -- call operator++ to obtain the first value.

config_file & boost::program_options::config_file::operator++  
 

Moves to the next option assignment in this file.

When called for the first time, moves to the first assignment.

Exceptions:
invalid_syntax Can be called after exception is thrown, and will return next variable.

const std::string & boost::program_options::config_file::name   const
 

Returns the option name for the current assignment.

const std::string & boost::program_options::config_file::value   const
 

Return the value for the current assignment.


The documentation for this class was generated from the following files:
Generated on 23 May 2003 with
doxygen