IniDict.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_PARSER_INIDICT_H
00013 #define ZYPP_PARSER_INIDICT_H
00014 
00015 #include <iosfwd>
00016 #include <map>
00017 #include <string>
00018 
00019 #include "zypp/base/PtrTypes.h"
00020 #include "zypp/base/InputStream.h"
00021 #include "zypp/base/Iterator.h"
00022 #include "zypp/parser/IniParser.h"
00023 
00025 namespace zypp
00026 { 
00027 
00028   namespace parser
00029   { 
00030 
00032     //
00033     //  CLASS NAME : IniDict
00034     //
00040     class IniDict : public IniParser
00041     {
00042       friend std::ostream & operator<<( std::ostream & str, const IniDict & obj );
00043     public:
00044       typedef std::map<std::string, std::string> EntrySet;
00045       typedef std::map<std::string, EntrySet> SectionSet;
00046       typedef MapKVIteratorTraits<SectionSet>::Key_const_iterator section_const_iterator;
00047       typedef EntrySet::const_iterator entry_const_iterator;
00048       
00062       section_const_iterator sectionsBegin() const;
00063       section_const_iterator sectionsEnd() const;
00065       
00080       entry_const_iterator entriesBegin(const std::string &section) const;
00081       entry_const_iterator entriesEnd(const std::string &section) const;
00083       
00088       IniDict( const InputStream &is,
00089                const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
00090 
00094       IniDict();
00095       
00097       ~IniDict();
00098 
00103       void read( const InputStream &is,
00104                  const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
00105 
00112       void insertEntry( const std::string &section,
00113                         const std::string &key,
00114                         const std::string &value );
00115       
00122       void deleteSection( const std::string &section );
00123 
00128       bool hasSection( const std::string &section ) const;
00129 
00138       bool hasEntry( const std::string &section,
00139                      const std::string &entry ) const;
00140     public:
00141 
00143       virtual void consume( const std::string &section );
00145       virtual void consume( const std::string &section,
00146                             const std::string &key,
00147                             const std::string &value );
00148 
00149     private:
00150       SectionSet _dict;
00156       EntrySet _empty_map;
00157     };
00159 
00161     std::ostream & operator<<( std::ostream & str, const IniDict & obj );
00162 
00164   } // namespace parser
00167 } // namespace zypp
00169 #endif // ZYPP_PARSER_INIDICT_H

doxygen