libzypp: zypp::parser::IniDict Class Reference

libzypp 17.25.10

Public Types | Friends | Related Functions | List of all members
zypp::parser::IniDict Class Reference

Parses a INI file and offers its structure as a dictionary. More...

`#include <IniDict.h>`

Inheritance diagram for zypp::parser::IniDict:
[legend]

## Public Types
typedef std::map< std::string, std::string > | EntrySet
typedef std::map< std::string, EntrySet > | SectionSet
typedef MapKVIteratorTraits< SectionSet >::Key_const_iterator | section_const_iterator
typedef EntrySet::const_iterator | entry_const_iterator

## Public Member Functions
Section Iterators
Iterate trough ini file sections for ( IniDict::section_const_iterator it = dict.sectionsBegin(); it != dict.sectionsEnd(); ++it ) { MIL << (*it) << endl; } MIL #define MIL Definition: Logger.h:91 zypp::parser::IniDict::section_const_iterator MapKVIteratorTraits< SectionSet >::Key_const_iterator section_const_iterator Definition: IniDict.h:47
section_const_iterator | sectionsBegin () const
section_const_iterator | sectionsEnd () const
Iterable< section_const_iterator > | sections () const
Public Member Functions inherited from zypp::parser::IniParser
| 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 | 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...

## Friends
std::ostream & | operator<< (std::ostream &str, const IniDict &obj)

## Related Functions
(Note that these are not member functions.)
std::ostream & | operator<< (std::ostream &str, const IniDict &obj)
| Stream output. More...

## Entries Iterators
Iterate trough ini file entries in a section for ( IniDict::entry_const_iterator it = dict.entriesBegin("updates"); it != dict.entriesEnd("updates"); ++it ) { MIL << (*it).first << endl; } zypp::parser::IniDict::entry_const_iterator EntrySet::const_iterator entry_const_iterator Definition: IniDict.h:48
SectionSet | _dict
EntrySet | _empty_map
| empty map used to simulate iteration in non existant sections More...
entry_const_iterator | entriesBegin (const std::string &section) const
entry_const_iterator | entriesEnd (const std::string &section) const
Iterable< entry_const_iterator > | entries (const std::string &section) const
| IniDict (const InputStream &is, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
| Creates a dictionary from a InputStream containing a ini structured file. More...
| IniDict ()
| Creates a mepty dictionary. More...
| ~IniDict ()
| Dtor. More...
void | read (const InputStream &is, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
| Fill a dictionary from a InputStream containing a ini structured file. More...
void | insertEntry (const std::string &section, const std::string &key, const std::string &value)
| add an entry More...
void | deleteSection (const std::string &section)
| add an entry More...
bool | hasSection (const std::string &section) const
| True if there is a section with that name. More...
bool | hasEntry (const std::string &section, const std::string &entry) const
| True if an entry exists in the section. 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...

## Detailed Description

Parses a INI file and offers its structure as a dictionary.

Definition at line 41 of file IniDict.h.

## Member Typedef Documentation

## ◆ EntrySet

typedef std::map<std::string, std::string> zypp::parser::IniDict::EntrySet

Definition at line 45 of file IniDict.h.

## ◆ SectionSet

typedef std::map<std::string, EntrySet> zypp::parser::IniDict::SectionSet

Definition at line 46 of file IniDict.h.

## ◆ section_const_iterator

typedef MapKVIteratorTraits<SectionSet>::Key_const_iterator zypp::parser::IniDict::section_const_iterator

Definition at line 47 of file IniDict.h.

## ◆ entry_const_iterator

typedef EntrySet::const_iterator zypp::parser::IniDict::entry_const_iterator

Definition at line 48 of file IniDict.h.

## Constructor & Destructor Documentation

## ◆ IniDict() [1/2]

zypp::parser::IniDict::IniDict | ( | const InputStream & | is,
|  | const ProgressData::ReceiverFnc & | progress = `ProgressData::ReceiverFnc()`
| ) |  |

Creates a dictionary from a InputStream containing a ini structured file.

Definition at line 37 of file IniDict.cc.

## ◆ IniDict() [2/2]

zypp::parser::IniDict::IniDict | ( |  | ) |

Creates a mepty dictionary.

Definition at line 43 of file IniDict.cc.

## ◆ ~IniDict()

zypp::parser::IniDict::~IniDict | ( |  | ) |

Dtor.

Definition at line 58 of file IniDict.cc.

## Member Function Documentation

## ◆ sectionsBegin()

IniDict::section_const_iterator zypp::parser::IniDict::sectionsBegin | ( |  | ) | const

Definition at line 105 of file IniDict.cc.

## ◆ sectionsEnd()

IniDict::section_const_iterator zypp::parser::IniDict::sectionsEnd | ( |  | ) | const

Definition at line 110 of file IniDict.cc.

## ◆ sections()

Iterable< IniDict::section_const_iterator > zypp::parser::IniDict::sections | ( |  | ) | const

Definition at line 115 of file IniDict.cc.

## ◆ entriesBegin()

IniDict::entry_const_iterator zypp::parser::IniDict::entriesBegin | ( | const std::string & | section | ) | const

Definition at line 72 of file IniDict.cc.

## ◆ entriesEnd()

IniDict::entry_const_iterator zypp::parser::IniDict::entriesEnd | ( | const std::string & | section | ) | const

Definition at line 83 of file IniDict.cc.

## ◆ entries()

Iterable< IniDict::entry_const_iterator > zypp::parser::IniDict::entries | ( | const std::string & | section | ) | const

Definition at line 94 of file IniDict.cc.

## ◆ read()

void zypp::parser::IniDict::read | ( | const InputStream & | is,
|  | const ProgressData::ReceiverFnc & | progress = `ProgressData::ReceiverFnc()`
| ) |  |

Fill a dictionary from a InputStream containing a ini structured file.

Definition at line 47 of file IniDict.cc.

## ◆ insertEntry()

void zypp::parser::IniDict::insertEntry | ( | const std::string & | section,
|  | const std::string & | key,
|  | const std::string & | value
| ) |  |

add an entry

Parameters

  section |
  key |
  value |

Definition at line 120 of file IniDict.cc.

## ◆ deleteSection()

void zypp::parser::IniDict::deleteSection | ( | const std::string & | section | ) |

add an entry

Parameters

  section |
  key |
  value |

Definition at line 128 of file IniDict.cc.

## ◆ hasSection()

bool zypp::parser::IniDict::hasSection | ( | const std::string & | section | ) | const

True if there is a section with that name.

Parameters

  section | Section Name

Definition at line 133 of file IniDict.cc.

## ◆ hasEntry()

bool zypp::parser::IniDict::hasEntry | ( | const std::string & | section,
|  | const std::string & | entry
| ) |  | const

True if an entry exists in the section.

Parameters

  section | Section name
  entry | entry name

Note
  If the given section does not exist, this will of course return false.

Definition at line 141 of file IniDict.cc.

## ◆ consume() [1/2]

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

Called when a section is found.

Reimplemented from zypp::parser::IniParser.

Definition at line 61 of file IniDict.cc.

## ◆ consume() [2/2]

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

Called when a key value is found.

Reimplemented from zypp::parser::IniParser.

Definition at line 66 of file IniDict.cc.

## Friends And Related Function Documentation

## ◆ operator<< [1/2]

std::ostream& operator<< | ( | std::ostream & | str,
|  | const IniDict & | obj
| ) |  |
| friend

Definition at line 160 of file IniDict.cc.

## ◆ operator<<() [2/2]

std::ostream & operator<< | ( | std::ostream & | str,
|  | const IniDict & | obj
| ) |  |
| related

Stream output.

Definition at line 160 of file IniDict.cc.

## Member Data Documentation

## ◆ _dict

SectionSet zypp::parser::IniDict::_dict
| private

Definition at line 153 of file IniDict.h.

## ◆ _empty_map

EntrySet zypp::parser::IniDict::_empty_map
| private

empty map used to simulate iteration in non existant sections

Definition at line 159 of file IniDict.h.

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

- zypp/parser/IniDict.h
- zypp/parser/IniDict.cc