libzypp 17.31.23
zypp::parser::IniParser Class Reference

Simple INI-file parser. More...

#include <parser/iniparser.h>

Inheritance diagram for zypp::parser::IniParser:

Public Member Functions

 IniParser ()
 Default ctor.
 
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()

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

Default ctor.

Definition at line 48 of file iniparser.cc.

◆ ~IniParser()

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

Dtor.

Definition at line 57 of file iniparser.cc.

Member Function Documentation

◆ parse()

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

Parse the stream.

Exceptions
ParseExceptionon errors. Invoke consume for each tag. consume might throw other exceptions as well.

Definition at line 84 of file iniparser.cc.

◆ beginParse()

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

Called when start parsing.

Definition at line 60 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 zypp::parser::IniDict.

Definition at line 66 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 zypp::parser::IniDict.

Definition at line 63 of file iniparser.cc.

◆ endParse()

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

Called when the parse is done.

Definition at line 69 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
ParseExceptionif 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 72 of file iniparser.cc.

◆ inputname()

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

Name of the current InputStream.

Definition at line 78 of file iniparser.h.

Member Data Documentation

◆ _inputname

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

Definition at line 84 of file iniparser.h.

◆ _current_section

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

Definition at line 85 of file iniparser.h.

◆ _line_nr

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

Definition at line 86 of file iniparser.h.


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