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]

List of all members.

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

Friends

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
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.
 IniDict ()
 Creates a mepty dictionary.
 ~IniDict ()
 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.
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.


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.

References read().

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

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

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

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

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.

References zypp::parser::IniParser::parse().

Referenced by zypp::VendorAttr::addVendorDirectory(), zypp::VendorAttr::addVendorFile(), and IniDict().

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.

References consume().

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

add an entry

Parameters:
section 
key 
value 

Definition at line 111 of file IniDict.cc.

References _dict.

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

References _dict.

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

References _dict.

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.

References _dict.

Referenced by insertEntry().

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.

References _dict.


Friends And Related Function Documentation

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

Stream output

Definition at line 143 of file IniDict.cc.


Member Data Documentation

empty map used to simulate iteration in non existant sections

Definition at line 156 of file IniDict.h.

Referenced by entriesBegin(), and entriesEnd().


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

doxygen