Public Member Functions | |
OFConfigFile (FILE *infile) | |
constructor. | |
virtual | ~OFConfigFile () |
destructor | |
const char * | get_keyword (unsigned int level) |
gets the name of the keyword at the specified level in the cursor path. | |
const char * | get_value () |
gets the value for the current entry (level 0 keyword). | |
OFBool | get_bool_value (OFBool defaultvalue) |
gets the value for the current entry and interprets it as a boolean value. | |
OFBool | section_valid (unsigned int level) const |
checks if the cursor points to a valid entry in the config data tree up to the the specified level. | |
void | set_section (unsigned int level, const char *key) |
sets cursor to the entry with keyword "key" at the given level. | |
void | first_section (unsigned int level) |
sets cursor to the first entry at the given level (without changing the cursor position at higher levels). | |
void | next_section (unsigned int level) |
sets cursor to the next entry at the given level (without changing the cursor position at higher levels). | |
void | save_cursor () |
puts the current cursor position on a cursor stack. | |
void | restore_cursor () |
restores a previously stored cursor position from the cursor stack. | |
void | select_section (const char *key1, const char *key2=NULL) |
sets the cursor to a different section. | |
const char * | get_entry (const char *key0) |
sets the cursor to the given level 0 keyword and returns the string value assigned to this keyword. | |
Private Member Functions | |
char | read_char (FILE *infile) |
reads the next character from the input file, maintains the current line number and filters out comments. | |
char | read_keywordchar (FILE *infile) |
reads the next non-whitespace character from the input file and returns as uppercase character. | |
void | read_entry (FILE *infile) |
reads a complete entry from the config file. | |
void | store_char (char c) |
writes a character to the string buffer maintained in "buffer". | |
OFConfigFile (const OFConfigFile &) | |
private undefined copy constructor | |
OFConfigFile & | operator= (const OFConfigFile &) |
private undefined assignment operator | |
Private Attributes | |
OFStack< OFConfigFileCursor > | stack |
stack of cursor positions that can be saved and restored | |
OFConfigFileCursor | cursor |
current cursor position | |
OFConfigFileNode * | anchor |
anchor to data tree | |
int | isnewline |
flag indicating whether newline during file read | |
int | crfound |
flag indicating whether CR was read during file read | |
char * | buffer |
buffer during file read | |
size_t | bufptr |
index into buffer during file read | |
long | bufsize |
buffer size during file read |
An object of this class reads upon construction a text config file and offers methods allowing to browse the configuration data
Definition at line 301 of file ofconfig.h.
|
constructor.
|
|
sets cursor to the first entry at the given level (without changing the cursor position at higher levels). Cursor must be valid at the level higher than the one specified. If no section is found the cursor becomes invalid at the specified level. The cursor always becomes invalid at all levels lower than specified.
Definition at line 371 of file ofconfig.h. References anchor, cursor, and OFConfigFileCursor::first_section(). |
|
gets the value for the current entry and interprets it as a boolean value. The keywords "yes", "no", "on", "off", "1", "0", "true" and false" are recognised in upper, lower and mixed case. If the value is different from any recognised keyword, the specified default is returned Cursor must point to a valid entry (i.e. be valid at level 0)
|
|
sets the cursor to the given level 0 keyword and returns the string value assigned to this keyword.
|
|
gets the name of the keyword at the specified level in the cursor path. Cursor must be valid at the specified level.
|
|
gets the value for the current entry (level 0 keyword). Cursor must point to a valid entry (i.e. be valid at level 0)
|
|
sets cursor to the next entry at the given level (without changing the cursor position at higher levels). Cursor must be valid at the level specified. If no section is found the cursor becomes invalid at the specified level. The cursor always becomes invalid at all levels lower than specified.
Definition at line 384 of file ofconfig.h. References cursor, and OFConfigFileCursor::next_section(). |
|
reads the next character from the input file, maintains the current line number and filters out comments.
|
|
reads a complete entry from the config file. An entry can either be a section heading or an entry of the form key=value. The entry is inserted into the config data tree managed by this object.
|
|
reads the next non-whitespace character from the input file and returns as uppercase character.
|
|
checks if the cursor points to a valid entry in the config data tree up to the the specified level.
Definition at line 344 of file ofconfig.h. References cursor, and OFConfigFileCursor::section_valid(). |
|
sets the cursor to a different section. This "shortcut" method allows to specify both section levels at the same time. The cursor becomes invalid when the section is not found.
|
|
sets cursor to the entry with keyword "key" at the given level. Cursor must be valid at the level higher than the one specified. If the keyword exists more than once, the first occurance is found. If the keyword does not exist, the cursor becomes invalid at the specified level. The cursor always becomes invalid at all levels lower than specified.
Definition at line 358 of file ofconfig.h. References anchor, cursor, and OFConfigFileCursor::set_section(). |
|
writes a character to the string buffer maintained in "buffer". Automatically resizes buffer if necessary.
|