jigdo API
ConfigFile::Find Class Reference
Class to enumerate all lines in the config file which match a given section & label name. More...
#include <configfile.hh>
Public Member Functions | |
Find (ConfigFile *c, const string §Name, const string &labelName, const iterator i, size_t *offset=0) | |
Find (ConfigFile *c, const string §Name, const string &labelName, size_t *offset=0) | |
size_t | next () |
If the line pointed to by section() is not named sectName, advance both section() and label() to the next section of that name. | |
iterator | section () const |
Current section line. NB takes a copy, can't change the Find object. | |
iterator | label () const |
Current line with label. | |
bool | finished () const |
Returns true if finished enumerating. |
Detailed Description
Class to enumerate all lines in the config file which match a given section & label name.NB: Only references are maintained to the section/label name, but it is assumed that these strings remain unchanged as long as the Find object is used. WARNING WARNING this means that you *must*not* pass string constants to the Find ctor, only strings - the lifetime of the temporary strings created from string constants is usually too short!!! Usage:
for (ConfigFile::Find f(c, sectionStr, labelStr); !f.finished(); f.next()) { f.section() points to "[section]" line, or end() if 0th section f.label() points to "label=..." line, or end() if f.finished() }
size_t off; for (ConfigFile::Find f(c, sectionStr, labelStr, &off); !f.finished(); off = f.next()) { f.section() points to "[section]" line, or end() if 0th section f.label() points to "label=..." line, or end() if f.finished() off is offset of part after "label=", or 0 }
Constructor & Destructor Documentation
ConfigFile::Find::Find | ( | ConfigFile * | c, | |
const string & | sectName, | |||
const string & | labelName, | |||
const iterator | i, | |||
size_t * | offset = 0 | |||
) |
- Parameters:
-
c The ConfigFile to search in sectName Section name labelName Label name i where to start searching. If i points to a [section] line, the search will start there, if it doesn't, the search will start beginning with the next section after i. If you search for the implicit section with an empty name (for labels before the first [section] line in the file), you _must_ supply sectName=="" and i==begin() (or omit i to use the second form). offset If non-null, is overwritten with 0 (unsuccessful) or the offset in the line to the character after '=', i.e. the offset to the entry's value.
References ConfigFile::end(), next(), and o.
ConfigFile::Find::Find | ( | ConfigFile * | c, | |
const string & | sectName, | |||
const string & | labelName, | |||
size_t * | offset = 0 | |||
) |
References ConfigFile::end(), next(), and o.
Member Function Documentation
size_t ConfigFile::Find::next | ( | ) |
If the line pointed to by section() is not named sectName, advance both section() and label() to the next section of that name.
Next, advance label() to the next label called labelName. Repeat the process with further sections if no label of that name in this section.
References ConfigFile::end(), ConfigFile::iterator::nextLabel(), ConfigFile::iterator::nextSection(), and o.
Referenced by Find().
iterator ConfigFile::Find::section | ( | ) | const [inline] |
Current section line. NB takes a copy, can't change the Find object.
iterator ConfigFile::Find::label | ( | ) | const [inline] |
Current line with label.
bool ConfigFile::Find::finished | ( | ) | const [inline] |
The documentation for this class was generated from the following files:
- util/configfile.hh
- util/configfile.cc
Generated on Tue Sep 23 14:27:42 2008 for jigdo by
