libzypp  17.38.7
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 
20 #include <zypp-core/base/InputStream>
23 #include <zypp-core/parser/IniParser>
24 
26 namespace zypp
27 {
28  namespace parser
30  {
31 
33  //
34  // CLASS NAME : IniDict
35  //
41  class ZYPP_API IniDict : public IniParser
42  {
43  friend std::ostream & operator<<( std::ostream & str, const IniDict & obj );
44  public:
45  using EntrySet = std::map<std::string, std::string>;
46  using SectionSet = std::map<std::string, EntrySet>;
48  using entry_const_iterator = EntrySet::const_iterator;
49 
63  section_const_iterator sectionsBegin() const;
64  section_const_iterator sectionsEnd() const;
65  Iterable<section_const_iterator> sections() const;
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 
105  IniDict( IniDict && ) = default;
106  IniDict & operator=( IniDict && ) = default;
107 
109  ~IniDict() override;
110 
115  void read( const InputStream &is,
117 
124  void insertEntry( const std::string &section,
125  const std::string &key,
126  const std::string &value );
127 
134  void deleteSection( const std::string &section );
135 
140  bool hasSection( const std::string &section ) const;
141 
150  bool hasEntry( const std::string &section,
151  const std::string &entry ) const;
152  public:
153 
155  void consume( const std::string &section ) override;
157  void consume( const std::string &section,
158  const std::string &key,
159  const std::string &value ) override;
160 
161  public:
163  std::ostream & dumpAsIniOn( std::ostream & str ) const;
164 
165  private:
173  };
175 
177  std::ostream & operator<<( std::ostream & str, const IniDict & obj );
178 
180  inline std::ostream & dumpOn( std::ostream & str, const IniDict & obj )
181  { return obj.dumpAsIniOn( str ); }
182 
184  } // namespace parser
187 } // namespace zypp
189 #endif // ZYPP_PARSER_INIDICT_H
std::map< std::string, std::string > EntrySet
Definition: inidict.h:45
EntrySet _empty_map
empty map used to simulate iteration in non-existent sections
Definition: inidict.h:172
SectionSet _dict
Definition: inidict.h:166
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Definition: progressdata.h:140
String related utilities and Regular expression matching.
std::map< std::string, EntrySet > SectionSet
Definition: inidict.h:46
Helper to create and pass std::istream.
Definition: inputstream.h:56
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition: Arch.h:173
Simple INI-file parser.
Definition: iniparser.h:41
std::ostream & dumpOn(std::ostream &str, const IniDict &obj)
relates: IniDict Dump as single ini-file.
Definition: inidict.h:180
transform_iterator< GetPairFirst< typename MapType::value_type >, typename MapType::const_iterator > Key_const_iterator
The key iterator type.
Definition: Iterator.h:217
Parses a INI file and offers its structure as a dictionary.
Definition: inidict.h:41
std::map< std::string, std::string > read(const Pathname &_path)
Read sysconfig file path_r and return (key,valye) pairs.
Definition: sysconfig.cc:34
EntrySet::const_iterator entry_const_iterator
Definition: inidict.h:48
MapKVIteratorTraits< SectionSet >::Key_const_iterator section_const_iterator
Definition: inidict.h:47
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
std::ostream & dumpAsIniOn(std::ostream &str) const
Dump the collected iniMap as ini-file.
Definition: inidict.cc:158
std::ostream & operator<<(std::ostream &str, const ProductFileData &obj)
relates: ProductFileData Stream output