libzypp  17.14.0
zypp::parser::IniParser Class Reference

Simple INI-file parser. More...

#include <IniParser.h>

Inheritance diagram for zypp::parser::IniParser:

Public Member Functions

 IniParser ()
 Default ctor. More...
 
virtual ~IniParser ()
 Dtor. More...
 
void parse (const InputStream &imput_r, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
 Parse the stream. More...
 
virtual void beginParse ()
 Called when start parsing. More...
 
virtual void consume (const std::string &section)
 Called when a section is found. More...
 
virtual void consume (const std::string &section, const std::string &key, const std::string &value)
 Called when a key value is found. More...
 
virtual void endParse ()
 Called when the parse is done. More...
 
virtual void garbageLine (const std::string &section, const std::string &line)
 Called whenever a garbage line is found. More...
 
const std::string & inputname () const
 Name of the current InputStream. More...
 

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 46 of file IniParser.cc.

◆ ~IniParser()

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

Dtor.

Definition at line 55 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 82 of file IniParser.cc.

◆ beginParse()

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

Called when start parsing.

Definition at line 58 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 64 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 61 of file IniParser.cc.

◆ endParse()

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

Called when the parse is done.

Definition at line 67 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 70 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: