FBB::ConfigFile(3bobcat)

Configuration File Processing
(libbobcat-dev_5.04.01-x.tar.gz)

2005-2020

NAME

FBB::ConfigFile - A class processing standard unix-like configuration files

SYNOPSIS

#include <bobcat/configfile>
Linking option: -lbobcat

DESCRIPTION

ConfigFile objects read standard unix-style configuration files. Lines are stored with initial white-space (blanks and tabs) removed. If a line ends in \, then the next line (initial white-space removed) is appended to the current line.

If the rmComment flag is set to true blanks lines and information on lines from the first # are removed. If the comment character (#) is prefixed by a backslash (i.e., \#) it is not considered comment, but replaced by a single # character. Likewise, if the rmComment flag was set two consecutive backslash characters are replaced by a single backslash character, In the retrieved configuration information it appears as a single # character. If the configuration file should contain \# write \\#, this results in replacing \# by #, leaving \#.

All non-empty lines of the configuration file (when comment is ignored comment is not considered to be line-content) are stored in the ConfigFile object. When line indices should be stored the (0-based) line indices of lines are available as well.

At construction time comment handling (keep comment / remove comment), case-sensitive searching (sensitive / insensitive) and index storage (store / don't store) can be specified.

It can't be modified using the open member, but overloaded assignment is supported and comment and letter case handling can be modified by set-members.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

-

ENUMERATIONS

The following enumerations are defined by the class ConfigFile:

TYPES

The following types are defined by the class ConfigFile:

CONSTRUCTORS

OVERLOADED OPERATORS

Copy and move constructors (and assignment operators) are available.

MEMBER FUNCTIONS

EXAMPLE

Assume the configuration file is called config.rc and contains the following lines:



# this is ignored

noline: this one too

line: this is found

this is not a line containing line: at the beginning of the line

line: this one is

    line: what about this one? \ 
        it's extending over multiple lines

and there may, of course, be more lines in this file
    

The following program may be compiled and run as a.out config.rc:


#include <iostream>
#include <iterator>
#include <algorithm>
#include <string>
#include <bobcat/configfile>

using namespace std;
using namespace FBB;
    
int main(int argc, char **argv)
{
    ConfigFile cf(argv[1]);     

    cout << *cf.find("this one") << '\n'; // find text within a line

                                         // find all lines matching 
    auto [begin, end] = cv.beginEndRE("^line:"); // `^line:'

    copy(begin, end, ostream_iterator<string>(cout, "\n"));
}
    

Producing the output:


noline: this one too
line: this is found
line: this one is
line: what about this one? it's extending over multiple lines
    

FILES

bobcat/configfile - defines the class interface

SEE ALSO

argconfig(3bobcat), bobcat(7), exception(3bobcat), pattern(3bobcat)

BUGS

None Reported.

DISTRIBUTION FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).