xdrpp
RFC4506 XDR compiler and message library
Classes | Namespaces | Typedefs | Functions
iniparse.h File Reference

Parser for .ini style files. More...

#include <cstdint>
#include <functional>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <vector>
Include dependency graph for iniparse.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  xdr::IniLine
 Contents of a specific property. More...
 
struct  xdr::IniGroup
 Set of callbacks to run when parsing properties within a particular group. More...
 

Namespaces

 xdr
 Most of the xdrpp library is encapsulated in the xdr namespace.
 

Typedefs

using xdr::IniActions = std::unordered_map< string, IniGroup >
 Holds the actions to execute on various properties in the ini file.
 

Functions

void xdr::ini_runparse (IniActions &a, IniLine &st, std::istream &s)
 Run the ini parser. More...
 
bool xdr::ini_parse (IniActions &a, string file)
 Run the parser on a file. More...
 

Detailed Description

Parser for .ini style files.

Accepts the following escape sequences in property values: '\r' '\n' '\s' (for space) and '\\'. An example of how to use the parser is this:

string foo, bar;
bool baz;
a["group1"].add("foo", &foo, "baz", &baz);
a["group2"].add("bar", &bar);
if (!ini_parse(a, "config.ini"))
exit (1);

This will parse an ini file like this:

[group1]
foo = some string
baz = true
[group2]
bar = \s a string starting with three spaces

Definition in file iniparse.h.