feisty meow concerns codebase
2.140
|
Tracks a collection of related configurations in a configurator. More...
#include <section_manager.h>
Public Member Functions | |
section_manager (configurator &config, const basis::astring &toc_title, const basis::astring &header_prefix) | |
creates a section_manager that uses the "config" for storage. More... | |
~section_manager () | |
DEFINE_CLASS_NAME ("section_manager") | |
bool | section_exists (const basis::astring §ion_name) |
returns true if the section called "section_name" exists in the config. More... | |
bool | get_section_names (structures::string_array §ions) |
loads the "sections" array with all section names. More... | |
bool | add_section (const basis::astring §ion_name, const structures::string_table &to_add) |
stores a new section for "section_name" using the table "to_add". More... | |
bool | replace_section (const basis::astring §ion, const structures::string_table &replacement) |
replaces the contents of "section" with the "replacement" table. More... | |
bool | zap_section (const basis::astring §ion_name) |
removes the data for "section_name" from both the config and TOC. More... | |
bool | find_section (const basis::astring §ion_name, structures::string_table &found) |
loads the data from "section_name" into the table "found". More... | |
configurator & | config () |
allows access to the configurator we operate on. More... | |
bool | get_toc (structures::string_table &toc) |
reads the table of contents into "toc". More... | |
basis::astring | make_section_heading (const basis::astring §ion) |
provides the appropriate heading string for the "section" name. More... | |
Public Member Functions inherited from basis::nameable | |
virtual const char * | class_name () const =0 |
Returns the bare name of this class as a constant character pointer. More... | |
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.
configuration::section_manager::section_manager | ( | configurator & | config, |
const basis::astring & | toc_title, | ||
const basis::astring & | 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:
Definition at line 31 of file section_manager.cpp.
configuration::section_manager::~section_manager | ( | ) |
Definition at line 39 of file section_manager.cpp.
References basis::WHACK().
bool configuration::section_manager::add_section | ( | const basis::astring & | section_name, |
const structures::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 66 of file section_manager.cpp.
References make_section_heading(), configuration::configurator::put(), configuration::configurator::put_section(), section_exists(), and structures::symbol_table< contents >::symbols().
Referenced by processes::configured_applications::add_section(), and replace_section().
|
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 85 of file section_manager.h.
Referenced by processes::configured_applications::find_program().
configuration::section_manager::DEFINE_CLASS_NAME | ( | "section_manager" | ) |
bool configuration::section_manager::find_section | ( | const basis::astring & | section_name, |
structures::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 102 of file section_manager.cpp.
References configuration::configurator::get_section(), make_section_heading(), and section_exists().
Referenced by processes::configured_applications::find_section().
bool configuration::section_manager::get_section_names | ( | structures::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 48 of file section_manager.cpp.
References get_toc(), structures::symbol_table< contents >::name(), basis::array< contents >::reset(), and structures::symbol_table< contents >::symbols().
bool configuration::section_manager::get_toc | ( | structures::string_table & | toc | ) |
reads the table of contents into "toc".
Definition at line 45 of file section_manager.cpp.
References configuration::configurator::get_section().
Referenced by get_section_names().
astring configuration::section_manager::make_section_heading | ( | const basis::astring & | section | ) |
provides the appropriate heading string for the "section" name.
this can be used to find entries using the config().
Definition at line 63 of file section_manager.cpp.
Referenced by add_section(), processes::configured_applications::find_program(), find_section(), and zap_section().
bool configuration::section_manager::replace_section | ( | const basis::astring & | section, |
const structures::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 84 of file section_manager.cpp.
References add_section(), section_exists(), structures::symbol_table< contents >::symbols(), and zap_section().
Referenced by processes::configured_applications::replace_section().
bool configuration::section_manager::section_exists | ( | const basis::astring & | section_name | ) |
returns true if the section called "section_name" exists in the config.
Definition at line 57 of file section_manager.cpp.
References configuration::configurator::load(), and basis::astring::t().
Referenced by processes::configured_applications::add_program(), add_section(), find_section(), processes::configured_applications::product_exists(), and replace_section().
bool configuration::section_manager::zap_section | ( | const basis::astring & | 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 94 of file section_manager.cpp.
References configuration::configurator::delete_entry(), configuration::configurator::delete_section(), and make_section_heading().
Referenced by replace_section().