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 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". | |
| virtual | ~ini_configurator () |
| DEFINE_CLASS_NAME ("ini_configurator") | |
| void | refresh () |
| useful mainly on unix/linux, where the file is parsed and held in memory. | |
| basis::astring | name () const |
| observes the name of the file used for ini entries. | |
| void | name (const basis::astring &name) |
| modifies the name of the file used for ini entries. | |
| virtual bool | get (const basis::astring §ion, const basis::astring &entry, basis::astring &found) |
| implements the configurator retrieval function. | |
| virtual void | sections (structures::string_array &list) |
| retrieves the section names into "list". | |
| virtual bool | section_exists (const basis::astring §ion) |
| returns true if the "section" was found in the file. | |
| virtual bool | put (const basis::astring §ion, const basis::astring &entry, const basis::astring &to_store) |
| implements the configurator storage function. | |
| virtual bool | delete_section (const basis::astring §ion) |
| removes the entire "section" specified. | |
| virtual bool | delete_entry (const basis::astring §ion, const basis::astring &entry) |
| removes the entry specified by the "section" and "entry" name. | |
| virtual bool | get_section (const basis::astring §ion, structures::string_table &info) |
| reads the entire "section" into a table called "info". | |
| 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. | |
| bool | add_spaces () const |
| void | add_spaces (bool add_them) |
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.
| 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 50 of file ini_configurator.cpp.
| configuration::ini_configurator::~ini_configurator | ( | ) | [virtual] |
Definition at line 63 of file ini_configurator.cpp.
References basis::WHACK().
| void configuration::ini_configurator::add_spaces | ( | bool | add_them | ) | [inline] |
Definition at line 109 of file ini_configurator.h.
| bool configuration::ini_configurator::add_spaces | ( | ) | const [inline] |
Definition at line 108 of file ini_configurator.h.
| configuration::ini_configurator::DEFINE_CLASS_NAME | ( | "ini_configurator" | ) |
| bool configuration::ini_configurator::delete_entry | ( | const basis::astring & | section, | |
| const basis::astring & | entry | |||
| ) | [virtual] |
removes the entry specified by the "section" and "entry" name.
Definition at line 214 of file ini_configurator.cpp.
References configuration::table_configurator::delete_entry().
Referenced by put(), and application::stdio_redirecter::zap_program().
| bool configuration::ini_configurator::delete_section | ( | const basis::astring & | section | ) | [virtual] |
removes the entire "section" specified.
Definition at line 201 of file ini_configurator.cpp.
References configuration::table_configurator::delete_section().
Referenced by put().
| bool configuration::ini_configurator::get | ( | const basis::astring & | section, | |
| const basis::astring & | entry, | |||
| basis::astring & | found | |||
| ) | [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 245 of file ini_configurator.cpp.
References configuration::table_configurator::get(), and configuration::MAXIMUM_LINE_INI_CONFIG.
| bool configuration::ini_configurator::get_section | ( | const basis::astring & | section, | |
| structures::string_table & | info | |||
| ) | [virtual] |
reads the entire "section" into a table called "info".
on win95, this will fail if the section's data exceeds 32K.
FUNCDEF("get_section");
Definition at line 260 of file ini_configurator.cpp.
References buffer_size, configuration::table_configurator::get_section(), basis::astring::length(), name(), basis::astring::observe(), configuration::variable_tokenizer::parse(), structures::symbol_table< contents >::reset(), basis::astring::shrink(), and configuration::variable_tokenizer::table().
Referenced by section_exists().
| void configuration::ini_configurator::name | ( | const basis::astring & | name | ) |
modifies the name of the file used for ini entries.
Definition at line 82 of file ini_configurator.cpp.
References ALL_USERS_DIRECTORY, configuration::application_configuration::application_directory(), filesystem::filename::basename(), filesystem::filename::had_directory(), OS_DIRECTORY, and configuration::application_configuration::software_product_name().
| astring configuration::ini_configurator::name | ( | ) | const |
observes the name of the file used for ini entries.
Definition at line 71 of file ini_configurator.cpp.
References filesystem::filename::raw().
Referenced by get_section(), put_section(), and versions::version_ini::version_ini().
| bool configuration::ini_configurator::put | ( | const basis::astring & | section, | |
| const basis::astring & | entry, | |||
| const basis::astring & | to_store | |||
| ) | [virtual] |
implements the configurator storage function.
FUNCDEF("put");
Implements configuration::configurator.
Definition at line 227 of file ini_configurator.cpp.
References delete_entry(), delete_section(), basis::astring::length(), and configuration::table_configurator::put().
| bool configuration::ini_configurator::put_section | ( | const basis::astring & | section, | |
| const structures::string_table & | info | |||
| ) | [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 302 of file ini_configurator.cpp.
References basis::astring::length(), name(), configuration::table_configurator::put_section(), configuration::variable_tokenizer::table(), and configuration::variable_tokenizer::text_form().
| void configuration::ini_configurator::refresh | ( | ) |
useful mainly on unix/linux, where the file is parsed and held in memory.
Definition at line 73 of file ini_configurator.cpp.
References configuration::configurator::behavior(), and basis::WHACK().
| bool configuration::ini_configurator::section_exists | ( | const basis::astring & | section | ) | [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 140 of file ini_configurator.cpp.
References get_section(), and configuration::table_configurator::section_exists().
| void configuration::ini_configurator::sections | ( | structures::string_array & | list | ) | [virtual] |
retrieves the section names into "list".
Reimplemented from configuration::configurator.
Definition at line 117 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(), basis::astring::strip_white_spaces(), and basis::astring::zap().
1.6.3