libzypp  15.28.6
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:

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;
}
section_const_iterator sectionsBegin () const
 
section_const_iterator sectionsEnd () 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)
 

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;
}
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
 
 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 40 of file IniDict.h.

Member Typedef Documentation

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

Definition at line 44 of file IniDict.h.

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

Definition at line 45 of file IniDict.h.

Definition at line 46 of file IniDict.h.

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

Definition at line 47 of file IniDict.h.

Constructor & Destructor Documentation

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 36 of file IniDict.cc.

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

Creates a mepty dictionary.

Definition at line 42 of file IniDict.cc.

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

Dtor.

Definition at line 57 of file IniDict.cc.

Member Function Documentation

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

Definition at line 94 of file IniDict.cc.

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

Definition at line 99 of file IniDict.cc.

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

Definition at line 71 of file IniDict.cc.

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

Definition at line 82 of file IniDict.cc.

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

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 104 of file IniDict.cc.

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

add an entry

Parameters
section
key
value

Definition at line 111 of file IniDict.cc.

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

True if there is a section with that name.

Parameters
sectionSection Name

Definition at line 116 of file IniDict.cc.

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

True if an entry exists in the section.

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

Definition at line 124 of file IniDict.cc.

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

Called when a section is found.

Reimplemented from zypp::parser::IniParser.

Definition at line 60 of file IniDict.cc.

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 65 of file IniDict.cc.

Friends And Related Function Documentation

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

Definition at line 143 of file IniDict.cc.

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

Stream output

Definition at line 143 of file IniDict.cc.

Member Data Documentation

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

Definition at line 150 of file IniDict.h.

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

empty map used to simulate iteration in non existant sections

Definition at line 156 of file IniDict.h.


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