libzypp: IniDict Class Reference

libzypp 17.38.7

IniDict Class Reference

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

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

Inheritance diagram for IniDict:

## Public Types
using | EntrySet = std::map<std::string, std::string>
using | SectionSet = std::map<std::string, EntrySet>
using | section_const_iterator = MapKVIteratorTraits<SectionSet>::Key_const_iterator
using | entry_const_iterator = EntrySet::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:103 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.
| 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 | 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.

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

## 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; } 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-existent sections
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.
| IniDict ()
| Creates an empty dictionary.
| IniDict (IniDict &&)=default
| Move CTor.
IniDict & | operator= (IniDict &&)=default
| ~IniDict () override
| Dtor.
void | read (const InputStream &is, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
| Fill a dictionary from a InputStream containing a ini structured file.
void | insertEntry (const std::string &section, const std::string &key, const std::string &value)
| add an entry
void | deleteSection (const std::string &section)
| add an entry
bool | hasSection (const std::string &section) const
| True if there is a section with that name.
bool | hasEntry (const std::string &section, const std::string &entry) const
| True if an entry exists in the section.
void | consume (const std::string &section) override
| Called when a section is found.
void | consume (const std::string &section, const std::string &key, const std::string &value) override
| Called when a key value is found.
std::ostream & | dumpAsIniOn (std::ostream &str) const
| Dump the collected iniMap as ini-file.

## 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

using zypp::parser::IniDict::EntrySet = std::map<std::string, std::string>

Definition at line 45 of file inidict.h.

## ◆ SectionSet

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

Definition at line 46 of file inidict.h.

## ◆ section_const_iterator

using zypp::parser::IniDict::section_const_iterator = MapKVIteratorTraits<SectionSet>::Key_const_iterator

Definition at line 47 of file inidict.h.

## ◆ entry_const_iterator

using zypp::parser::IniDict::entry_const_iterator = EntrySet::const_iterator

Definition at line 48 of file inidict.h.

## Constructor & Destructor Documentation

## ◆ IniDict() [1/3]

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 40 of file inidict.cc.

## ◆ IniDict() [2/3]

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

Creates an empty dictionary.

Definition at line 46 of file inidict.cc.

## ◆ IniDict() [3/3]

zypp::parser::IniDict::IniDict | ( | IniDict && |  | ) |
| default

Move CTor.

Inheriting IniParser is a legacy design flaw making IniDict NonCopyable. But we can allow moving the parsed data around.

## ◆ ~IniDict()

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

Dtor.

Definition at line 61 of file inidict.cc.

## Member Function Documentation

## ◆ sectionsBegin()

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

Definition at line 108 of file inidict.cc.

## ◆ sectionsEnd()

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

Definition at line 113 of file inidict.cc.

## ◆ sections()

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

Definition at line 118 of file inidict.cc.

## ◆ entriesBegin()

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

Definition at line 75 of file inidict.cc.

## ◆ entriesEnd()

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

Definition at line 86 of file inidict.cc.

## ◆ entries()

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

Definition at line 97 of file inidict.cc.

## ◆ operator=()

IniDict & zypp::parser::IniDict::operator= | ( | IniDict && |  | ) |
| default

## ◆ 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 50 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 123 of file inidict.cc.

## ◆ deleteSection()

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

add an entry

Parameters

  section |
  key |
  value |

Definition at line 131 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 136 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 144 of file inidict.cc.

## ◆ consume() [1/2]

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

Called when a section is found.

Reimplemented from zypp::parser::IniParser.

Definition at line 64 of file inidict.cc.

## ◆ consume() [2/2]

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

Called when a key value is found.

Reimplemented from zypp::parser::IniParser.

Definition at line 69 of file inidict.cc.

## ◆ dumpAsIniOn()

std::ostream & zypp::parser::IniDict::dumpAsIniOn | ( | std::ostream & | str | ) | const

Dump the collected iniMap as ini-file.

Definition at line 158 of file inidict.cc.

## Friends And Related Symbol Documentation

## ◆ operator<<

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

relates: IniDict Stream output

Definition at line 171 of file inidict.cc.

## Member Data Documentation

## ◆ _dict

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

Definition at line 166 of file inidict.h.

## ◆ _empty_map

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

empty map used to simulate iteration in non-existent sections

Definition at line 172 of file inidict.h.

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

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