feisty meow concerns codebase
2.140
|
Supports a configurator-based interface on text initialization files. More...
#include <ini_configurator.h>
Public Types | |
enum | file_location_default { APPLICATION_DIRECTORY , OS_DIRECTORY , ALL_USERS_DIRECTORY } |
chooses where the ini file is located if no path to it is provided. More... | |
Public Types inherited from configuration::configurator | |
enum | treatment_of_defaults { AUTO_STORE , RETURN_ONLY } |
Public Member Functions | |
ini_configurator (const basis::astring &ini_filename, treatment_of_defaults behavior=RETURN_ONLY, file_location_default where=ALL_USERS_DIRECTORY) | |
creates an ini_configurator that stores entries into "ini_filename". More... | |
virtual | ~ini_configurator () |
DEFINE_CLASS_NAME ("ini_configurator") | |
void | refresh () |
useful mainly on unix/linux, where the file is parsed and held in memory. More... | |
basis::astring | name () const |
observes the name of the file used for ini entries. More... | |
void | name (const basis::astring &name) |
modifies the name of the file used for ini entries. More... | |
virtual bool | get (const basis::astring §ion, const basis::astring &entry, basis::astring &found) |
implements the configurator retrieval function. More... | |
virtual void | sections (structures::string_array &list) |
retrieves the section names into "list". More... | |
virtual bool | section_exists (const basis::astring §ion) |
returns true if the "section" was found in the file. More... | |
virtual bool | put (const basis::astring §ion, const basis::astring &entry, const basis::astring &to_store) |
implements the configurator storage function. More... | |
virtual bool | delete_section (const basis::astring §ion) |
removes the entire "section" specified. More... | |
virtual bool | delete_entry (const basis::astring §ion, const basis::astring &entry) |
removes the entry specified by the "section" and "entry" name. More... | |
virtual bool | get_section (const basis::astring §ion, structures::string_table &info) |
reads the entire "section" into a table called "info". More... | |
virtual bool | put_section (const basis::astring §ion, const structures::string_table &info) |
writes a table called "info" into the "section" in the INI file. More... | |
bool | add_spaces () const |
void | add_spaces (bool add_them) |
Public Member Functions inherited from configuration::configurator | |
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... | |
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... | |
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 | 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... | |
Supports a configurator-based interface on text initialization files.
Definition at line 32 of file ini_configurator.h.
chooses where the ini file is located if no path to it is provided.
the ini file being manipulated will be stored in either the same directory as the program being executed (APPLICATION_DIRECTORY) or in the directory where the operating system resides (OS_DIRECTORY). however, the OS_DIRECTORY choice only really makes sense on windows. if the flag is instead ALL_USERS_DIRECTORY, then the directory pointed at by the $ALLUSERSPROFILE variable will be used on windows; otherwise, the default is the same as for APPLICATION_DIRECTORY.
Enumerator | |
---|---|
APPLICATION_DIRECTORY | config files live with application. |
OS_DIRECTORY | config files live in operating system directory. |
ALL_USERS_DIRECTORY | config files live in the "all users" account. |
Definition at line 43 of file ini_configurator.h.
configuration::ini_configurator::ini_configurator | ( | const basis::astring & | ini_filename, |
treatment_of_defaults | behavior = RETURN_ONLY , |
||
file_location_default | where = ALL_USERS_DIRECTORY |
||
) |
creates an ini_configurator that stores entries into "ini_filename".
the ini config will have the "behavior" specified for how to handle missing items. "where" dictates the file's location if no path is specified as part of the "ini_filename".
Definition at line 52 of file ini_configurator.cpp.
References FUNCDEF.
|
virtual |
Definition at line 67 of file ini_configurator.cpp.
References basis::WHACK().
|
inline |
Definition at line 108 of file ini_configurator.h.
|
inline |
Definition at line 109 of file ini_configurator.h.
configuration::ini_configurator::DEFINE_CLASS_NAME | ( | "ini_configurator" | ) |
|
virtual |
removes the entry specified by the "section" and "entry" name.
Definition at line 218 of file ini_configurator.cpp.
Referenced by application::stdio_redirecter::zap_program().
|
virtual |
removes the entire "section" specified.
Definition at line 205 of file ini_configurator.cpp.
|
virtual |
implements the configurator retrieval function.
this returns true if the entry was present and stores it in "found".
Implements configuration::configurator.
Definition at line 249 of file ini_configurator.cpp.
References configuration::MAXIMUM_LINE_INI_CONFIG.
|
virtual |
reads the entire "section" into a table called "info".
on win95, this will fail if the section's data exceeds 32K.
Definition at line 264 of file ini_configurator.cpp.
References buffer_size, FUNCDEF, basis::astring::length(), basis::astring::observe(), configuration::variable_tokenizer::parse(), structures::symbol_table< contents >::reset(), basis::astring::shrink(), and configuration::variable_tokenizer::table().
astring configuration::ini_configurator::name | ( | ) | const |
observes the name of the file used for ini entries.
Definition at line 75 of file ini_configurator.cpp.
Referenced by versions::version_ini::version_ini().
void configuration::ini_configurator::name | ( | const basis::astring & | name | ) |
modifies the name of the file used for ini entries.
Definition at line 86 of file ini_configurator.cpp.
References basis::environment::get().
|
virtual |
implements the configurator storage function.
Implements configuration::configurator.
Definition at line 231 of file ini_configurator.cpp.
References FUNCDEF, and basis::astring::length().
|
virtual |
writes a table called "info" into the "section" in the INI file.
any existing data for that section is wiped out. on win95, this will fail if the section's data exceeds 32K.
Definition at line 306 of file ini_configurator.cpp.
void configuration::ini_configurator::refresh | ( | ) |
useful mainly on unix/linux, where the file is parsed and held in memory.
Definition at line 77 of file ini_configurator.cpp.
References basis::WHACK().
|
virtual |
returns true if the "section" was found in the file.
NOTE: for an INI file, this is quite a heavy-weight call.
Reimplemented from configuration::configurator.
Definition at line 144 of file ini_configurator.cpp.
|
virtual |
retrieves the section names into "list".
Reimplemented from configuration::configurator.
Definition at line 121 of file ini_configurator.cpp.
References basis::astring::end(), basis::astring::find(), filesystem::byte_filer::good(), configuration::MAXIMUM_LINE_INI_CONFIG, basis::negative(), filesystem::byte_filer::read(), string_array(), basis::astring::strip_white_spaces(), and basis::astring::zap().