r5239@piscolita: duncan | 2007-05-02 19:07:55 +0200
[platform/upstream/libzypp.git] / zypp / parser / IniParser.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/parser/IniParser.h
10  *
11 */
12 #ifndef ZYPP_PARSER_INIPARSER_H
13 #define ZYPP_PARSER_INIPARSER_H
14
15 #include <iosfwd>
16 #include <string>
17 #include <list>
18
19 #include "zypp/base/PtrTypes.h"
20 #include "zypp/base/NonCopyable.h"
21 #include "zypp/base/InputStream.h"
22
23 #include "zypp/parser/tagfile/ParseException.h"
24
25 ///////////////////////////////////////////////////////////////////
26 namespace zypp
27 { /////////////////////////////////////////////////////////////////
28 ///////////////////////////////////////////////////////////////////
29 namespace parser
30 { /////////////////////////////////////////////////////////////////
31
32 using tagfile::ParseException;
33
34 ///////////////////////////////////////////////////////////////////
35 //
36 //      CLASS NAME : IniParser
37 //
38 /** Basic SUSEtags parser.
39  * Will replace parser/tagfile/ and  parser/taggedfile/ stuff.
40 */
41 class IniParser : private base::NonCopyable
42 {
43 public:
44   /** Default ctor */
45   IniParser();
46   /** Dtor */
47   virtual ~IniParser();
48   /** Parse the stream.
49    * \throw ParseExcetion on errors. Invoke \ref consume
50    * for each tag. \ref consume might throw other exceptions
51    * as well.
52   */
53   void parse( const InputStream & imput_r );
54
55 public:
56   /** Called when start parsing. */
57   virtual void beginParse();
58   /** Called when a section is found. */
59   virtual void consume( const std::string &section );
60   /** Called when a key value is found. */
61   virtual void consume( const std::string &section, const std::string &key, const std::string &value );
62   /** Called when the parse is done. */
63   virtual void endParse();
64 public:
65   /** Name of the current InputStream. */
66   const std::string & inputname() const
67   {
68     return _inputname;
69   }
70
71 private:
72   std::string _inputname;
73   std::string _current_section;
74   int _line_nr;
75   //ProgressData _ticks;
76 };
77
78 /////////////////////////////////////////////////////////////////
79 } // namespace parser
80 ///////////////////////////////////////////////////////////////////
81 /////////////////////////////////////////////////////////////////
82 } // namespace zypp
83 ///////////////////////////////////////////////////////////////////
84 #endif // ZYPP_PARSER_INIPARSER_H