wpl::opt::list Struct Reference

List of options. More...

#include <wipal/tool/options.hh>

Inherits std::map< name, value >.

List of all members.

Public Types

typedef std::map< name, valuesuper_type

Public Member Functions

 list ()
 list (const internals::pair &defaults)
template<class D >
 list (const internals::defaults_list< D > &defaults)
valueoperator[] (const name &n)
const valueoperator[] (const name &n) const
void add (const list &l)
void add (const name &n, const value &v)
listadd (const name &n, const list &l)
void populate (list &other) const
std::ostream & print (std::ostream &o, unsigned depth=0) const

Detailed Description

List of options.

A list of options is a dynamic map that associates values of arbitrary types to std::string keys. Once a list of options is constructed and filled with various options, one access a specific item with operator[]():

   opt::list  l;

   l.add("int",   int (42));
   l.add("float", float (42));

   int   i = l["int"].get<int>();               // Both methods
   float f = opt::get<float>(l["float"]);       // are valid.

Instead of using add() it is possible to initialize a list as follows:

   opt::list l ((opt::name ("int") -= 42,
                       opt::name ("sublist") -= opt::list
                                                ((
                                                  opt::name ("bool") -= true
                                                ))
                     ));

You can access sub-list items as follows:

   bool b = l["sublist"]["bool"].get<bool>();

Looking for an option that does not exist or trying a conversion to an invalid type with raise an exception.


Member Function Documentation

list & wpl::opt::list::add ( const name n,
const list l 
) [inline]

Add another option list l as a new option with name n.

If an option with name n already exists and is already an option list, the options from l are *added* to this list, i.e. the previous options are not deleted in the sub-list.


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

Generated by  doxygen 1.6.2