libzypp: zypp::parser::IniParser Class Reference

libzypp 17.38.9

zypp::parser::IniParser Class Reference

Simple INI-file parser. More...

`#include <zypp-core/parser/iniparser.h>`

Inheritance diagram for zypp::parser::IniParser:

## Public Member Functions
| IniParser ()
| Default ctor.
| IniParser (IniParser &&)
| Being NonCopyable is a legacy but allow at least moving.
IniParser & | operator= (IniParser &&)
virtual | ~IniParser ()
| Dtor.
void | parse (const InputStream &imput_r, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
| Parse the stream.
virtual void | beginParse ()
| Called when start parsing.
virtual void | consume (const std::string &section)
| Called when a section is found.
virtual void | consume (const std::string &section, const std::string &key, const std::string &value)
| Called when a key value is found.
virtual void | endParse ()
| Called when the parse is done.
virtual void | garbageLine (const std::string &section, const std::string &line)
| Called whenever a garbage line is found.
const std::string & | inputname () const
| Name of the current InputStream.

## Private Attributes
std::string | _inputname
std::string | _current_section
int | _line_nr

## Detailed Description

Simple INI-file parser.

Lines staring with ``; or `#` are treated as comment. Section names are enclosed by []. Key and value are separated by `=`.

Lines without `=` or with a key containing any of "<tt>,|\\/</tt>" or section lines without closing ``] are considered garbage.

Definition at line 41 of file iniparser.h.

## Constructor & Destructor Documentation

## ◆ IniParser() [1/2]

zypp::parser::IniParser::IniParser | ( |  | ) |

Default ctor.

Definition at line 48 of file iniparser.cc.

## ◆ IniParser() [2/2]

zypp::parser::IniParser::IniParser | ( | IniParser && | rhs | ) |

Being NonCopyable is a legacy but allow at least moving.

It's a design flaw that data storing classes like IniDict inherit from IniParser rather than just using it to fill their data store. But we can allow moving the parsed data around.

Definition at line 52 of file iniparser.cc.

## ◆ ~IniParser()

zypp::parser::IniParser::~IniParser | ( |  | ) |
| virtual

Dtor.

Definition at line 63 of file iniparser.cc.

## Member Function Documentation

## ◆ operator=()

IniParser & zypp::parser::IniParser::operator= | ( | IniParser && |  | ) |

## ◆ parse()

void zypp::parser::IniParser::parse | ( | const InputStream & | imput_r,
|  | const ProgressData::ReceiverFnc & | progress = ProgressData::ReceiverFnc() )

Parse the stream.

Exceptions

  ParseException | on errors. Invoke consume for each tag. consume might throw other exceptions as well.

Definition at line 90 of file iniparser.cc.

## ◆ beginParse()

void zypp::parser::IniParser::beginParse | ( |  | ) |
| virtual

Called when start parsing.

Definition at line 66 of file iniparser.cc.

## ◆ consume() [1/2]

void zypp::parser::IniParser::consume | ( | const std::string & | section | ) |
| virtual

Called when a section is found.

Reimplemented in IniDict, and zypp::parser::IniDict.

Definition at line 72 of file iniparser.cc.

## ◆ consume() [2/2]

void zypp::parser::IniParser::consume | ( | const std::string & | section,
|  | const std::string & | key,
|  | const std::string & | value )
| virtual

Called when a key value is found.

Reimplemented in IniDict, and zypp::parser::IniDict.

Definition at line 69 of file iniparser.cc.

## ◆ endParse()

void zypp::parser::IniParser::endParse | ( |  | ) |
| virtual

Called when the parse is done.

Definition at line 75 of file iniparser.cc.

## ◆ garbageLine()

void zypp::parser::IniParser::garbageLine | ( | const std::string & | section,
|  | const std::string & | line )
| virtual

Called whenever a garbage line is found.

Exceptions

  ParseException | if not overloaded.

Derived parsers may overload this to examine the line and call this method to actually throw the exception.

Used by some parsers to accept multi-line entires.

Definition at line 78 of file iniparser.cc.

## ◆ inputname()

const std::string & zypp::parser::IniParser::inputname | ( |  | ) | const
| inline

Name of the current InputStream.

Definition at line 88 of file iniparser.h.

## Member Data Documentation

## ◆ _inputname

std::string zypp::parser::IniParser::_inputname
| private

Definition at line 94 of file iniparser.h.

## ◆ _current_section

std::string zypp::parser::IniParser::_current_section
| private

Definition at line 95 of file iniparser.h.

## ◆ _line_nr

int zypp::parser::IniParser::_line_nr
| private

Definition at line 96 of file iniparser.h.

The documentation for this class was generated from the following files:

- zypp-core/parser/iniparser.h
- zypp-core/parser/iniparser.cc