feisty meow concerns codebase  2.140
configuration::ini_configurator Class Reference

Supports a configurator-based interface on text initialization files. More...

#include <ini_configurator.h>

Inheritance diagram for configuration::ini_configurator:
Collaboration diagram for configuration::ini_configurator:

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 &section, 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 &section)
 returns true if the "section" was found in the file. More...
 
virtual bool put (const basis::astring &section, const basis::astring &entry, const basis::astring &to_store)
 implements the configurator storage function. More...
 
virtual bool delete_section (const basis::astring &section)
 removes the entire "section" specified. More...
 
virtual bool delete_entry (const basis::astring &section, const basis::astring &entry)
 removes the entry specified by the "section" and "entry" name. More...
 
virtual bool get_section (const basis::astring &section, structures::string_table &info)
 reads the entire "section" into a table called "info". More...
 
virtual bool put_section (const basis::astring &section, 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 &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...
 
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...
 

Detailed Description

Supports a configurator-based interface on text initialization files.

Definition at line 32 of file ini_configurator.h.

Member Enumeration Documentation

◆ file_location_default

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.

Constructor & Destructor Documentation

◆ ini_configurator()

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.

◆ ~ini_configurator()

configuration::ini_configurator::~ini_configurator ( )
virtual

Definition at line 67 of file ini_configurator.cpp.

References basis::WHACK().

Member Function Documentation

◆ add_spaces() [1/2]

bool configuration::ini_configurator::add_spaces ( ) const
inline

Definition at line 108 of file ini_configurator.h.

◆ add_spaces() [2/2]

void configuration::ini_configurator::add_spaces ( bool  add_them)
inline

Definition at line 109 of file ini_configurator.h.

◆ DEFINE_CLASS_NAME()

configuration::ini_configurator::DEFINE_CLASS_NAME ( "ini_configurator"  )

◆ delete_entry()

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 218 of file ini_configurator.cpp.

Referenced by application::stdio_redirecter::zap_program().

◆ delete_section()

bool configuration::ini_configurator::delete_section ( const basis::astring section)
virtual

removes the entire "section" specified.

Definition at line 205 of file ini_configurator.cpp.

◆ get()

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 249 of file ini_configurator.cpp.

References configuration::MAXIMUM_LINE_INI_CONFIG.

◆ get_section()

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.

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

◆ name() [1/2]

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

◆ name() [2/2]

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

◆ put()

bool configuration::ini_configurator::put ( const basis::astring section,
const basis::astring entry,
const basis::astring to_store 
)
virtual

implements the configurator storage function.

Implements configuration::configurator.

Definition at line 231 of file ini_configurator.cpp.

References FUNCDEF, and basis::astring::length().

◆ put_section()

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 306 of file ini_configurator.cpp.

◆ refresh()

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

◆ section_exists()

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 144 of file ini_configurator.cpp.

◆ sections()


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