section_manager Class Reference

Tracks a collection of related configurations in a configurator. More...

#include <section_manager.h>

Collaboration diagram for section_manager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 section_manager (configurator &config, const istring &toc_title, const istring &header_prefix)
 creates a section_manager that uses the "config" for storage.
 ~section_manager ()
bool section_exists (const istring &section_name)
 returns true if the section called "section_name" exists in the config.
bool get_section_names (string_array &sections)
 loads the "sections" array with all section names.
bool add_section (const istring &section_name, const string_table &to_add)
 stores a new section for "section_name" using the table "to_add".
bool replace_section (const istring &section, const string_table &replacement)
 replaces the contents of "section" with the "replacement" table.
bool zap_section (const istring &section_name)
 removes the data for "section_name" from both the config and TOC.
bool find_section (const istring &section_name, string_table &found)
 loads the data from "section_name" into the table "found".
configuratorconfig ()
 allows access to the configurator we operate on.
bool get_toc (string_table &toc)
 reads the table of contents into "toc".
istring make_section_heading (const istring &section)
 provides the appropriate heading string for the "section" name.

Detailed Description

Tracks a collection of related configurations in a configurator.

If there is a set of items that need to be stored in a configurator, where each item has its own configuration section, then this object can help out. It manages a collection of uniquely named sections in a configurator object and provides a table of contents (TOC) feature for the names of the sections. Each item lives in its own distinct section but the whole set can be operated on as one entity.

Definition at line 34 of file section_manager.h.


Constructor & Destructor Documentation

section_manager::section_manager ( configurator config,
const istring toc_title,
const istring header_prefix 
)

creates a section_manager that uses the "config" for storage.

the "toc_title" is the name of the section to be used for storing the table of contents for the managed configuration items. the "header_prefix" will be prepended to the names of each section to facilitate locating them. for example, if the "toc_title" is "client channels" and the "header_prefix" is "CliChan__", then the resulting configuration might look similar to the following:

      [client channels]
      joe
      ted
      [CliChan__joe]
      port=58
      [CliChan__ted]
      address=13.8.92.4
      auth=primary

Definition at line 26 of file section_manager.cpp.

section_manager::~section_manager (  ) 

Definition at line 34 of file section_manager.cpp.

References WHACK().


Member Function Documentation

bool section_manager::section_exists ( const istring section_name  ) 

returns true if the section called "section_name" exists in the config.

Definition at line 52 of file section_manager.cpp.

References configurator::load(), and istring::t().

Referenced by application_config::add_program(), add_section(), find_section(), application_config::product_exists(), and replace_section().

bool section_manager::get_section_names ( string_array sections  ) 

loads the "sections" array with all section names.

this comes from our table of contents. true is returned if there were any names to load.

Definition at line 43 of file section_manager.cpp.

References get_toc(), symbol_table< contents >::name(), array< contents >::reset(), and symbol_table< contents >::symbols().

bool section_manager::add_section ( const istring section_name,
const string_table to_add 
)

stores a new section for "section_name" using the table "to_add".

this will fail if the section already exists.

Definition at line 61 of file section_manager.cpp.

References make_section_heading(), configurator::put(), configurator::put_section(), section_exists(), and symbol_table< contents >::symbols().

Referenced by application_config::add_section(), and replace_section().

bool section_manager::replace_section ( const istring section,
const string_table replacement 
)

replaces the contents of "section" with the "replacement" table.

this will fail if the section does not already exist.

Definition at line 79 of file section_manager.cpp.

References add_section(), section_exists(), symbol_table< contents >::symbols(), and zap_section().

Referenced by application_config::replace_section().

bool section_manager::zap_section ( const istring section_name  ) 

removes the data for "section_name" from both the config and TOC.

this will fail if the section is not present.

Definition at line 89 of file section_manager.cpp.

References configurator::delete_entry(), configurator::delete_section(), and make_section_heading().

Referenced by replace_section().

bool section_manager::find_section ( const istring section_name,
string_table found 
)

loads the data from "section_name" into the table "found".

this fails if the section doesn't exist or if the section's contents couldn't be detokenized into a table of name/value pairs.

Definition at line 97 of file section_manager.cpp.

References configurator::get_section(), make_section_heading(), and section_exists().

Referenced by application_config::find_section().

configurator& section_manager::config (  )  [inline]

allows access to the configurator we operate on.

getting single items from the config will be signficantly faster using it directly; the make_section_heading() method can be used to locate the proper section.

Definition at line 83 of file section_manager.h.

Referenced by application_config::find_program().

bool section_manager::get_toc ( string_table toc  ) 

reads the table of contents into "toc".

Definition at line 40 of file section_manager.cpp.

References configurator::get_section().

Referenced by get_section_names().

istring section_manager::make_section_heading ( const istring section  ) 

provides the appropriate heading string for the "section" name.

this can be used to find entries using the config().

Definition at line 58 of file section_manager.cpp.

Referenced by add_section(), application_config::find_program(), find_section(), and zap_section().


The documentation for this class was generated from the following files:
Generated on Fri Nov 28 04:30:58 2008 for HOOPLE Libraries by  doxygen 1.5.1