libzypp  13.10.6
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  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
static bool _debug
Definition: ParseDef.h:229
RW_pointer< Impl > _pimpl
Pointer to implementation (shared!)
Definition: ParseDef.h:220
ParseDef(const std::string &name_r, Mode mode_r)
Definition: ParseDef.cc:369
Define a xml node structure to parse.
Definition: ParseDef.h:128
ParseDef & operator()(ParseDef &subnode_r)
Add subnode definition.
Definition: ParseDef.h:176
ParseDef & operator()(const std::string &name_r, Mode mode_r)
Definition: ParseDef.h:179
shared_ptr< ParseDefConsume > getConsumer() const
Get data consumer.
Definition: ParseDef.cc:435
const std::string & name() const
Definition: ParseDef.cc:389
bool singleDef() const
Definition: ParseDef.cc:401
bool isOptional() const
Definition: ParseDef.cc:395
ParseDefTraits Traits
Definition: ParseDef.h:130
ParseDef implementation.
Definition: ParseDef.cc:94
void take(Reader &reader_r)
Parse the node.
Definition: ParseDef.cc:439
Mode mode() const
Definition: ParseDef.cc:392
ParseDef & operator()(const std::string &name_r, Mode mode_r, const shared_ptr< ParseDefConsume > &target_r)
Definition: ParseDef.h:182
bool multiDef() const
Definition: ParseDef.cc:404
Base class for ParseDef consumer.
ParseDef & addNode(const std::string &name_r, Mode mode_r)
Definition: ParseDef.h:167
unsigned visited() const
Definition: ParseDef.cc:407
virtual ~ParseDef()
Definition: ParseDef.cc:386
ParseDef & addNode(ParseDef &subnode_r)
Add subnode definition.
Definition: ParseDef.cc:410
bool isMandatory() const
Definition: ParseDef.cc:398
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
Definition: libxmlfwd.cc:29
void cancelConsumer()
Unset data consumer.
Definition: ParseDef.cc:432
friend std::ostream & operator<<(std::ostream &str, const ParseDef &obj)
Definition: ParseDef.cc:466
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:265
ParseDef operator[](const std::string &name_r)
Get subnode by name.
Definition: ParseDef.cc:413
void setConsumer(const shared_ptr< ParseDefConsume > &target_r)
Set data consumer.
Definition: ParseDef.cc:423
ParseDef & addNode(const std::string &name_r, Mode mode_r, const shared_ptr< ParseDefConsume > &target_r)
Definition: ParseDef.h:170
xmlTextReader based interface to iterate xml streams.
Definition: Reader.h:95