libzypp  17.23.5
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/base/PtrTypes.h>
20 #include <zypp/base/InputStream.h>
21 #include <zypp/base/Iterator.h>
22 #include <zypp/parser/IniParser.h>
23 
25 namespace zypp
26 {
27  namespace parser
29  {
30 
32  //
33  // CLASS NAME : IniDict
34  //
40  class IniDict : public IniParser
41  {
42  friend std::ostream & operator<<( std::ostream & str, const IniDict & obj );
43  public:
44  typedef std::map<std::string, std::string> EntrySet;
45  typedef std::map<std::string, EntrySet> SectionSet;
47  typedef EntrySet::const_iterator entry_const_iterator;
48 
65 
80  entry_const_iterator entriesBegin(const std::string &section) const;
81  entry_const_iterator entriesEnd(const std::string &section) const;
83 
88  IniDict( const InputStream &is,
90 
94  IniDict();
95 
97  ~IniDict();
98 
103  void read( const InputStream &is,
105 
112  void insertEntry( const std::string &section,
113  const std::string &key,
114  const std::string &value );
115 
122  void deleteSection( const std::string &section );
123 
128  bool hasSection( const std::string &section ) const;
129 
138  bool hasEntry( const std::string &section,
139  const std::string &entry ) const;
140  public:
141 
143  virtual void consume( const std::string &section );
145  virtual void consume( const std::string &section,
146  const std::string &key,
147  const std::string &value );
148 
149  private:
157  };
159 
161  std::ostream & operator<<( std::ostream & str, const IniDict & obj );
162 
164  } // namespace parser
167 } // namespace zypp
169 #endif // ZYPP_PARSER_INIDICT_H
zypp::parser::IniDict::sectionsBegin
section_const_iterator sectionsBegin() const
Definition: IniDict.cc:95
zypp::parser::IniDict::EntrySet
std::map< std::string, std::string > EntrySet
Definition: IniDict.h:44
zypp::parser::IniDict::_empty_map
EntrySet _empty_map
empty map used to simulate iteration in non existant sections
Definition: IniDict.h:156
zypp::parser::IniDict::~IniDict
~IniDict()
Dtor.
Definition: IniDict.cc:58
zypp::parser::IniDict::IniDict
IniDict()
Creates a mepty dictionary.
Definition: IniDict.cc:43
PtrTypes.h
zypp::parser::IniDict::read
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:47
zypp::parser::IniDict::SectionSet
std::map< std::string, EntrySet > SectionSet
Definition: IniDict.h:45
zypp::parser::IniDict
Parses a INI file and offers its structure as a dictionary.
Definition: IniDict.h:40
zypp::parser::IniDict::insertEntry
void insertEntry(const std::string &section, const std::string &key, const std::string &value)
add an entry
Definition: IniDict.cc:105
zypp::MapKVIteratorTraits::Key_const_iterator
transform_iterator< GetPairFirst< typename MapType::value_type >, typename MapType::const_iterator > Key_const_iterator
The key iterator type.
Definition: Iterator.h:218
zypp::parser::IniDict::entriesEnd
entry_const_iterator entriesEnd(const std::string &section) const
Definition: IniDict.cc:83
zypp::parser::IniDict::entry_const_iterator
EntrySet::const_iterator entry_const_iterator
Definition: IniDict.h:47
zypp::parser::IniDict::deleteSection
void deleteSection(const std::string &section)
add an entry
Definition: IniDict.cc:112
zypp::parser::IniDict::hasEntry
bool hasEntry(const std::string &section, const std::string &entry) const
True if an entry exists in the section.
Definition: IniDict.cc:125
zypp::InputStream
Helper to create and pass std::istream.
Definition: InputStream.h:56
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::parser::IniParser
Simple INI-file parser.
Definition: IniParser.h:41
Iterator.h
zypp::ProgressData::ReceiverFnc
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Definition: ProgressData.h:139
zypp::parser::IniDict::sectionsEnd
section_const_iterator sectionsEnd() const
Definition: IniDict.cc:100
zypp::parser::operator<<
std::ostream & operator<<(std::ostream &str, const IniDict &obj)
Definition: IniDict.cc:143
zypp::parser::IniDict::operator<<
friend std::ostream & operator<<(std::ostream &str, const IniDict &obj)
Definition: IniDict.cc:143
zypp::parser::IniDict::_dict
SectionSet _dict
Definition: IniDict.h:150
zypp::parser::IniDict::consume
virtual void consume(const std::string &section)
Called when a section is found.
Definition: IniDict.cc:61
zypp::parser::IniDict::section_const_iterator
MapKVIteratorTraits< SectionSet >::Key_const_iterator section_const_iterator
Definition: IniDict.h:46
InputStream.h
IniParser.h
zypp::parser::IniDict::hasSection
bool hasSection(const std::string &section) const
True if there is a section with that name.
Definition: IniDict.cc:117
str
String related utilities and Regular expression matching.
zypp::parser::IniDict::entriesBegin
entry_const_iterator entriesBegin(const std::string &section) const
Definition: IniDict.cc:72