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:
Inheritance graph
[legend]
Collaboration diagram for configuration::ini_configurator:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

Supports a configurator-based interface on text initialization files.

Definition at line 32 of file ini_configurator.h.


Member Enumeration Documentation

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

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


Member Function Documentation

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  ) 
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]

The documentation for this class was generated from the following files:
Generated on Sat Jan 28 04:25:28 2012 for hoople2 project by  doxygen 1.6.3