Combine multiple configuration sources. More...

#include <senf/Utils/Console/Config.hh>

Public Member Functions

template<class Source >
Source & add (boost::intrusive_ptr< Source > source)
 Add configuration source. More...
 
void parse ()
 Parse config bundle. More...
 
void parse (DirectoryNode &restrict)
 Parse config bundle under restrict. More...
 
bool complete () const
 true, if all nodes have been parsed More...
 
bool parsed (GenericNode &node) const
 true. if node has been parsed More...
 
void reset ()
 Reset node parse info state. More...
 
DirectoryNoderoot () const
 
void chroot (DirectoryNode &node)
 

Structors and default members

 ConfigBundle ()
 root node is set to console::root() More...
 
 ConfigBundle (DirectoryNode &root)
 Set custom root node. More...
 

Detailed Description

Combine multiple configuration sources.

A ConfigBundle combines several sources and parses them together, in the order they were added. Parse restrictions are applied uniformly to all sources.

// Add three configuration sources: A system configuration file, a user configuration file
// and command line options
conf.add( senf::console::FileConfig("/etc/some.conf") );
conf.add( senf::console::FileConfig("local.conf") );
conf.add( senf::console::OptionsConfig(senf::Daemon::instance().argc(),
conf.parse();
    This bundle may also be passed to other code which may use restricted parsing to parse
    partial information from all configuration sources.

Definition at line 52 of file Config.hh.

Constructor & Destructor Documentation

◆ ConfigBundle() [1/2]

senf::console::ConfigBundle::ConfigBundle ( )

root node is set to console::root()

◆ ConfigBundle() [2/2]

senf::console::ConfigBundle::ConfigBundle ( DirectoryNode root)

Set custom root node.

Member Function Documentation

◆ add()

template<class Source >
Source& senf::console::ConfigBundle::add ( boost::intrusive_ptr< Source >  source)

Add configuration source.

◆ chroot()

void senf::console::ConfigBundle::chroot ( DirectoryNode node)

◆ complete()

bool senf::console::ConfigBundle::complete ( ) const

true, if all nodes have been parsed

◆ parse() [1/2]

void senf::console::ConfigBundle::parse ( )

Parse config bundle.

All nodes already parsed are skipped

Definition at line 106 of file Config.cc.

◆ parse() [2/2]

void senf::console::ConfigBundle::parse ( DirectoryNode restrict)

Parse config bundle under restrict.

Only nodes which are children of restrict are parsed.

Definition at line 112 of file Config.cc.

◆ parsed()

bool senf::console::ConfigBundle::parsed ( GenericNode node) const

true. if node has been parsed

◆ reset()

void senf::console::ConfigBundle::reset ( )

Reset node parse info state.

After a call to reset(), all information about already parsed nodes is cleared. Calling parse() will parse the complete config bundle again.

◆ root()

DirectoryNode& senf::console::ConfigBundle::root ( ) const

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