libzypp  11.13.5
ParseDef.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_PARSER_XML_PARSEDEF_H
13 #define ZYPP_PARSER_XML_PARSEDEF_H
14 
15 #include <iosfwd>
16 
17 #include "zypp/base/PtrTypes.h"
19 
21 namespace zypp
22 {
23 
24  namespace xml
25  {
26 
27  class Reader;
28  class ParseDefConsume;
29 
31  //
32  // CLASS NAME : ParseDef
33  //
128  class ParseDef
129  {
131 
132  public:
133  enum Mode
134  {
139  };
140 
141  public:
142  ParseDef( const std::string & name_r, Mode mode_r );
143  ParseDef( const std::string & name_r, Mode mode_r, const shared_ptr<ParseDefConsume> & target_r );
144 
145  virtual ~ParseDef();
146 
147  public:
148  const std::string & name() const;
149  Mode mode() const;
150  bool isOptional() const;
151  bool isMandatory() const;
152  bool singleDef() const;
153  bool multiDef() const;
154  unsigned visited() const;
155 
156  public:
165  ParseDef & addNode( ParseDef & subnode_r );
166 
167  ParseDef & addNode( const std::string & name_r, Mode mode_r )
168  { ParseDef tmp( name_r, mode_r ); return addNode( tmp ); }
169 
170  ParseDef & addNode( const std::string & name_r, Mode mode_r, const shared_ptr<ParseDefConsume> & target_r )
171  { ParseDef tmp( name_r, mode_r, target_r ); return addNode( tmp ); }
172 
176  ParseDef & operator()( ParseDef & subnode_r )
177  { return addNode( subnode_r ); }
178 
179  ParseDef & operator()( const std::string & name_r, Mode mode_r )
180  { return addNode( name_r, mode_r ); }
181 
182  ParseDef & operator()( const std::string & name_r, Mode mode_r, const shared_ptr<ParseDefConsume> & target_r )
183  { return addNode( name_r, mode_r, target_r ); }
184 
188  ParseDef operator[]( const std::string & name_r );
189 
190  public:
192  void setConsumer( const shared_ptr<ParseDefConsume> & target_r );
197  void setConsumer( ParseDefConsume * allocatedTarget_r );
199  void setConsumer( ParseDefConsume & target_r );
201  void cancelConsumer();
202 
204  shared_ptr<ParseDefConsume> getConsumer() const;
205 
216  void take( Reader & reader_r );
217 
218  private:
220  class Impl;
223 
224  ParseDef( const shared_ptr<Impl> & pimpl_r );
225  friend std::ostream & operator<<( std::ostream & str, const ParseDef & obj );
226  friend std::ostream & operator<<( std::ostream & str, const ParseDef::Impl & obj );
227 
228  public:
229  static bool _debug;
230  };
232 
234  std::ostream & operator<<( std::ostream & str, ParseDef::Mode obj );
235 
237  std::ostream & operator<<( std::ostream & str, const ParseDef & obj );
238 
240  } // namespace xml
243 } // namespace zypp
245 #endif // ZYPP_PARSER_XML_PARSEDEF_H