feisty meow concerns codebase
2.140
|
Provides a base class for configuration repositories. More...
#include <configurator.h>
Public Types | |
enum | treatment_of_defaults { AUTO_STORE , RETURN_ONLY } |
Public Member Functions | |
configurator (treatment_of_defaults behavior=RETURN_ONLY) | |
virtual | ~configurator () |
treatment_of_defaults | behavior () const |
observes the behavior chosen for the load() function. More... | |
void | behavior (treatment_of_defaults new_behavior) |
modifies the behavior of the load() function. More... | |
virtual bool | get (const basis::astring §ion, const basis::astring &entry, basis::astring &found)=0 |
Retrieves an item from the configuration store. More... | |
virtual bool | put (const basis::astring §ion, const basis::astring &entry, const basis::astring &to_store)=0 |
Places an item into the configuration store. More... | |
bool | store (const basis::astring §ion, const basis::astring &entry, const basis::astring &to_store) |
a synonym for put. More... | |
basis::astring | load (const basis::astring §ion, const basis::astring &entry, const basis::astring &default_value) |
a synonym for get that implements the auto-store behavior. More... | |
bool | store (const basis::astring §ion, const basis::astring &entry, int value) |
stores an integer value from the configuration store. More... | |
int | load (const basis::astring §ion, const basis::astring &entry, int def_value) |
loads an integer value from the configuration store. More... | |
virtual void | sections (structures::string_array &list) |
retrieves the section names into "list". More... | |
void | section_set (structures::string_set &list) |
similar to above, but stores section names into a set. More... | |
virtual bool | delete_entry (const basis::astring &formal(section), const basis::astring &formal(entry)) |
eliminates the entry specified by the "section" and "entry" name. More... | |
virtual bool | delete_section (const basis::astring &formal(section)) |
whacks the entire "section" specified. More... | |
virtual bool | section_exists (const basis::astring §ion) |
returns true if the "section" is found in the configurator. More... | |
virtual bool | get_section (const basis::astring &formal(section), structures::string_table &formal(found)) |
retrieves an entire "section", if supported by the derived object. More... | |
virtual bool | put_section (const basis::astring &formal(section), const structures::string_table &formal(to_store)) |
stores an entire "section" from the table in "to_store", if supported. More... | |
Provides a base class for configuration repositories.
All items that can be stored are modelled as having an entry name and a value. Groups of entries are stored in sections, in which the data usually have some relation to each other or share a common purpose.
Definition at line 33 of file configurator.h.
Enumerator | |
---|---|
AUTO_STORE | |
RETURN_ONLY |
Definition at line 36 of file configurator.h.
|
inline |
Definition at line 42 of file configurator.h.
|
virtual |
Definition at line 26 of file configurator.cpp.
|
inline |
observes the behavior chosen for the load() function.
Definition at line 46 of file configurator.h.
Referenced by configuration::string_configlet::load().
|
inline |
modifies the behavior of the load() function.
Definition at line 48 of file configurator.h.
References AUTO_STORE, and RETURN_ONLY.
|
inlinevirtual |
eliminates the entry specified by the "section" and "entry" name.
Definition at line 93 of file configurator.h.
Referenced by configuration::section_manager::zap_section().
|
inlinevirtual |
whacks the entire "section" specified.
Definition at line 97 of file configurator.h.
Referenced by configuration::section_manager::zap_section().
|
pure virtual |
Retrieves an item from the configuration store.
This retrieves a string into "found" that is listed in the "section" specified under the "entry" name. if the string is not found, false is returned.
Implemented in configuration::table_configurator, configuration::ini_configurator, and configuration::registry_configurator.
Referenced by configuration::string_configlet::load(), and configuration::int_configlet::load().
|
inlinevirtual |
retrieves an entire "section", if supported by the derived object.
the symbol table "found" gets the entries from the "section". see symbol_table.h for more details about string_tables. true is returned if the section existed and its contents were put in "found".
Definition at line 106 of file configurator.h.
Referenced by configuration::section_manager::find_section(), configuration::section_manager::get_toc(), and configuration::config_watcher::rescan().
astring configuration::configurator::load | ( | const basis::astring & | section, |
const basis::astring & | entry, | ||
const basis::astring & | default_value | ||
) |
a synonym for get that implements the auto-store behavior.
if the behavior is set to auto-store, then the default value will be written when no value existed prior to the load() invocation.
Definition at line 28 of file configurator.cpp.
Referenced by versions::version_ini::executable(), processes::configured_applications::find_program(), versions::version_ini::get_record(), configuration::ini_roller::ini_roller(), configuration::int_configlet::load(), versions::version_ini::ole_auto_registering(), configuration::application_configuration::read_item(), versions::version_ini::read_version_from_ini(), configuration::section_manager::section_exists(), versions::version_ini::write_code(), and versions::version_ini::write_rc().
int configuration::configurator::load | ( | const basis::astring & | section, |
const basis::astring & | entry, | ||
int | def_value | ||
) |
loads an integer value from the configuration store.
Definition at line 63 of file configurator.cpp.
References basis::astring::convert().
|
pure virtual |
Places an item into the configuration store.
places an entry into the "section" under the "entry" name using the string "to_store". if the storage was successful, true is returned. reasons for failure depend on the derived class implementations.
Implemented in configuration::table_configurator, configuration::ini_configurator, and configuration::registry_configurator.
Referenced by configuration::section_manager::add_section(), configuration::string_configlet::load(), and configuration::string_configlet::store().
|
inlinevirtual |
stores an entire "section" from the table in "to_store", if supported.
if any entries already exist in the "section", then they are eliminated before the new entries are stored. true is returned if the write was successful.
Definition at line 112 of file configurator.h.
Referenced by configuration::section_manager::add_section().
|
virtual |
returns true if the "section" is found in the configurator.
the default implementation is quite slow; if there is a swifter means for a particular type of configurator, then this should be overridden.
Reimplemented in configuration::table_configurator, configuration::ini_configurator, and configuration::registry_configurator.
Definition at line 74 of file configurator.cpp.
void configuration::configurator::section_set | ( | structures::string_set & | list | ) |
similar to above, but stores section names into a set.
this never needs to be overridden; it's simply a set instead of an array. the real sections method is above for string_array.
Definition at line 56 of file configurator.cpp.
Referenced by configuration::config_watcher::changed_sections(), configuration::config_watcher::deleted_sections(), configuration::config_watcher::new_sections(), and configuration::config_watcher::rescan().
|
virtual |
retrieves the section names into "list".
Reimplemented in configuration::table_configurator, and configuration::ini_configurator.
Definition at line 50 of file configurator.cpp.
References string_array().
bool configuration::configurator::store | ( | const basis::astring & | section, |
const basis::astring & | entry, | ||
const basis::astring & | to_store | ||
) |
a synonym for put.
Definition at line 40 of file configurator.cpp.
Referenced by configuration::application_configuration::get_logging_directory(), configuration::ini_roller::ini_roller(), configuration::ini_roller::next_id(), versions::version_ini::set_record(), versions::version_ini::set_version(), configuration::int_configlet::store(), and configuration::ini_roller::~ini_roller().
bool configuration::configurator::store | ( | const basis::astring & | section, |
const basis::astring & | entry, | ||
int | value | ||
) |
stores an integer value from the configuration store.
Definition at line 44 of file configurator.cpp.
References basis::astring::SPRINTF.