libzypp 17.31.23
inidict.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_PARSER_INIDICT_H
13#define ZYPP_PARSER_INIDICT_H
14
15#include <iosfwd>
16#include <map>
17#include <string>
18
19#include <zypp-core/base/PtrTypes.h>
20#include <zypp-core/base/InputStream>
21#include <zypp-core/base/Iterator.h>
22#include <zypp-core/base/Iterable.h>
23#include <zypp-core/parser/IniParser>
24
26namespace zypp
27{
29 namespace parser
30 {
31
33 //
34 // CLASS NAME : IniDict
35 //
41 class IniDict : public IniParser
42 {
43 friend std::ostream & operator<<( std::ostream & str, const IniDict & obj );
44 public:
45 typedef std::map<std::string, std::string> EntrySet;
46 typedef std::map<std::string, EntrySet> SectionSet;
48 typedef EntrySet::const_iterator entry_const_iterator;
49
67
82 entry_const_iterator entriesBegin(const std::string &section) const;
83 entry_const_iterator entriesEnd(const std::string &section) const;
84 Iterable<entry_const_iterator> entries(const std::string &section) const;
86
91 IniDict( const InputStream &is,
93
97 IniDict();
98
100 ~IniDict();
101
106 void read( const InputStream &is,
108
115 void insertEntry( const std::string &section,
116 const std::string &key,
117 const std::string &value );
118
125 void deleteSection( const std::string &section );
126
131 bool hasSection( const std::string &section ) const;
132
141 bool hasEntry( const std::string &section,
142 const std::string &entry ) const;
143 public:
144
146 virtual void consume( const std::string &section );
148 virtual void consume( const std::string &section,
149 const std::string &key,
150 const std::string &value );
151
152 private:
160 };
162
164 std::ostream & operator<<( std::ostream & str, const IniDict & obj );
165
167 } // namespace parser
170} // namespace zypp
172#endif // ZYPP_PARSER_INIDICT_H
Helper to create and pass std::istream.
Definition: inputstream.h:57
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Definition: progressdata.h:140
Parses a INI file and offers its structure as a dictionary.
Definition: inidict.h:42
section_const_iterator sectionsEnd() const
Definition: inidict.cc:113
friend std::ostream & operator<<(std::ostream &str, const IniDict &obj)
Definition: inidict.cc:163
void read(const InputStream &is, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
Fill a dictionary from a InputStream containing a ini structured file.
Definition: inidict.cc:50
bool hasSection(const std::string &section) const
True if there is a section with that name.
Definition: inidict.cc:136
void deleteSection(const std::string &section)
add an entry
Definition: inidict.cc:131
EntrySet::const_iterator entry_const_iterator
Definition: inidict.h:48
MapKVIteratorTraits< SectionSet >::Key_const_iterator section_const_iterator
Definition: inidict.h:47
Iterable< section_const_iterator > sections() const
Definition: inidict.cc:118
entry_const_iterator entriesBegin(const std::string &section) const
Definition: inidict.cc:75
Iterable< entry_const_iterator > entries(const std::string &section) const
Definition: inidict.cc:97
void insertEntry(const std::string &section, const std::string &key, const std::string &value)
add an entry
Definition: inidict.cc:123
section_const_iterator sectionsBegin() const
Definition: inidict.cc:108
bool hasEntry(const std::string &section, const std::string &entry) const
True if an entry exists in the section.
Definition: inidict.cc:144
IniDict()
Creates a mepty dictionary.
Definition: inidict.cc:46
virtual void consume(const std::string &section)
Called when a section is found.
Definition: inidict.cc:64
SectionSet _dict
Definition: inidict.h:153
EntrySet _empty_map
empty map used to simulate iteration in non-existent sections
Definition: inidict.h:159
std::map< std::string, std::string > EntrySet
Definition: inidict.h:45
entry_const_iterator entriesEnd(const std::string &section) const
Definition: inidict.cc:86
std::map< std::string, EntrySet > SectionSet
Definition: inidict.h:46
Simple INI-file parser.
Definition: iniparser.h:42
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const ProductFileData &obj)
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
transform_iterator< GetPairFirst< typename MapType::value_type >, typename MapType::const_iterator > Key_const_iterator
The key iterator type.
Definition: Iterator.h:218