feisty meow concerns codebase  2.140
configuration::configurator Class Referenceabstract

Provides a base class for configuration repositories. More...

#include <configurator.h>

Inheritance diagram for configuration::configurator:
Collaboration diagram for configuration::configurator:

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 &section, const basis::astring &entry, basis::astring &found)=0
 Retrieves an item from the configuration store. More...
 
virtual bool put (const basis::astring &section, const basis::astring &entry, const basis::astring &to_store)=0
 Places an item into the configuration store. More...
 
bool store (const basis::astring &section, const basis::astring &entry, const basis::astring &to_store)
 a synonym for put. More...
 
basis::astring load (const basis::astring &section, 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 &section, const basis::astring &entry, int value)
 stores an integer value from the configuration store. More...
 
int load (const basis::astring &section, 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 &section)
 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...
 

Detailed Description

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.

Member Enumeration Documentation

◆ treatment_of_defaults

Enumerator
AUTO_STORE 
RETURN_ONLY 

Definition at line 36 of file configurator.h.

Constructor & Destructor Documentation

◆ configurator()

configuration::configurator::configurator ( treatment_of_defaults  behavior = RETURN_ONLY)
inline

Definition at line 42 of file configurator.h.

◆ ~configurator()

configuration::configurator::~configurator ( )
virtual

Definition at line 26 of file configurator.cpp.

Member Function Documentation

◆ behavior() [1/2]

treatment_of_defaults configuration::configurator::behavior ( ) const
inline

observes the behavior chosen for the load() function.

Definition at line 46 of file configurator.h.

Referenced by configuration::string_configlet::load().

◆ behavior() [2/2]

void configuration::configurator::behavior ( treatment_of_defaults  new_behavior)
inline

modifies the behavior of the load() function.

Definition at line 48 of file configurator.h.

References AUTO_STORE, and RETURN_ONLY.

◆ delete_entry()

virtual bool configuration::configurator::delete_entry ( const basis::astring formalsection,
const basis::astring formalentry 
)
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().

◆ delete_section()

virtual bool configuration::configurator::delete_section ( const basis::astring formalsection)
inlinevirtual

whacks the entire "section" specified.

Definition at line 97 of file configurator.h.

Referenced by configuration::section_manager::zap_section().

◆ get()

virtual bool configuration::configurator::get ( const basis::astring section,
const basis::astring entry,
basis::astring found 
)
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().

◆ get_section()

virtual bool configuration::configurator::get_section ( const basis::astring formalsection,
structures::string_table formalfound 
)
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().

◆ load() [1/2]

astring configuration::configurator::load ( const basis::astring section,
const basis::astring entry,
const basis::astring default_value 
)

◆ load() [2/2]

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().

◆ put()

virtual bool configuration::configurator::put ( const basis::astring section,
const basis::astring entry,
const basis::astring to_store 
)
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().

◆ put_section()

virtual bool configuration::configurator::put_section ( const basis::astring formalsection,
const structures::string_table formalto_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().

◆ section_exists()

bool configuration::configurator::section_exists ( const basis::astring 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.

◆ section_set()

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().

◆ sections()

void configuration::configurator::sections ( structures::string_array list)
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().

◆ store() [1/2]

◆ store() [2/2]

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.


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