25 using namespace basis;
34 _toc_title(new
astring(toc_title)),
35 _section_prefix(new
astring(header_prefix))
42 WHACK(_section_prefix);
52 if (!
get_toc(toc))
return false;
53 for (
int i = 0; i < toc.
symbols(); i++) sections += toc.
name(i);
59 if (!section_name)
return false;
60 return _config.
load(*_toc_title, section_name,
"").
t();
64 {
return *_section_prefix + section; }
69 if (!section_name)
return false;
75 if (!_config.
put(*_toc_title, section_name, section_value))
87 if (!section_name)
return false;
90 if (!replacement.
symbols())
return true;
96 if (!section_name)
return false;
105 if (!section_name)
return false;
void reset(int number=0, const contents *initial_contents=NULL_POINTER)
Resizes this array and sets the contents from an array of contents.
Provides a dynamically resizable ASCII character string.
bool t() const
t() is a shortcut for the string being "true", as in non-empty.
Provides a base class for configuration repositories.
virtual bool put(const basis::astring §ion, const basis::astring &entry, const basis::astring &to_store)=0
Places an item into the configuration store.
virtual bool get_section(const basis::astring &formal(section), structures::string_table &formal(found))
retrieves an entire "section", if supported by the derived object.
virtual bool delete_section(const basis::astring &formal(section))
whacks the entire "section" specified.
virtual bool delete_entry(const basis::astring &formal(section), const basis::astring &formal(entry))
eliminates the entry specified by the "section" and "entry" name.
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.
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.
basis::astring make_section_heading(const basis::astring §ion)
provides the appropriate heading string for the "section" name.
bool get_section_names(structures::string_array §ions)
loads the "sections" array with all section names.
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".
bool get_toc(structures::string_table &toc)
reads the table of contents into "toc".
bool zap_section(const basis::astring §ion_name)
removes the data for "section_name" from both the config and TOC.
bool section_exists(const basis::astring §ion_name)
returns true if the section called "section_name" exists in the config.
bool replace_section(const basis::astring §ion, const structures::string_table &replacement)
replaces the contents of "section" with the "replacement" table.
bool find_section(const basis::astring §ion_name, structures::string_table &found)
loads the data from "section_name" into the table "found".
An array of strings with some additional helpful methods.
Provides a symbol_table that holds strings as the content.
const basis::astring & name(int index) const
returns the name held at the "index".
int symbols() const
returns the number of symbols listed in the table.
The guards collection helps in testing preconditions and reporting errors.
void WHACK(contents *&ptr)
deletion with clearing of the pointer.
A dynamic container class that holds any kind of object via pointers.