libzypp  17.25.0
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  struct 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
zypp::xml::ParseDef::_pimpl
RW_pointer< Impl > _pimpl
Pointer to implementation (shared!)
Definition: ParseDef.h:220
zypp::xml::ParseDef::addNode
ParseDef & addNode(const std::string &name_r, Mode mode_r, const shared_ptr< ParseDefConsume > &target_r)
Definition: ParseDef.h:170
zypp::xml::Reader
xmlTextReader based interface to iterate xml streams.
Definition: Reader.h:95
zypp::xml::ParseDef::isMandatory
bool isMandatory() const
Definition: ParseDef.cc:397
zypp::xml::ParseDef::multiDef
bool multiDef() const
Definition: ParseDef.cc:403
zypp::xml::ParseDefTraits::BIT_OPTIONAL
Definition: ParseDefTraits.h:38
zypp::xml::ParseDef::ParseDef
ParseDef(const std::string &name_r, Mode mode_r)
Definition: ParseDef.cc:368
zypp::xml::ParseDef::operator()
ParseDef & operator()(ParseDef &subnode_r)
Add subnode definition.
Definition: ParseDef.h:176
zypp::xml::ParseDef::Impl
ParseDef implementation.
Definition: ParseDef.cc:94
zypp::xml::operator<<
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
Definition: libxmlfwd.cc:28
PtrTypes.h
zypp::xml::ParseDef::Traits
ParseDefTraits Traits
Definition: ParseDef.h:130
zypp::xml::ParseDef::MANDTAORY
Definition: ParseDef.h:136
zypp::xml::ParseDef::operator()
ParseDef & operator()(const std::string &name_r, Mode mode_r)
Definition: ParseDef.h:179
zypp::xml::ParseDefTraits::BIT_ONCE
Definition: ParseDefTraits.h:44
zypp::RW_pointer< Impl >
zypp::xml::ParseDef::take
void take(Reader &reader_r)
Parse the node.
Definition: ParseDef.cc:438
zypp::xml::ParseDef::Mode
Mode
Definition: ParseDef.h:133
zypp::xml::ParseDef::operator()
ParseDef & operator()(const std::string &name_r, Mode mode_r, const shared_ptr< ParseDefConsume > &target_r)
Definition: ParseDef.h:182
zypp::xml::ParseDefConsume
Base class for ParseDef consumer.
Definition: ParseDefConsume.h:38
zypp::xml::ParseDefTraits::BIT_MANDTAORY
Definition: ParseDefTraits.h:39
zypp::xml::ParseDef
Define a xml node structure to parse.
Definition: ParseDef.h:128
zypp::xml::ParseDef::addNode
ParseDef & addNode(const std::string &name_r, Mode mode_r)
Definition: ParseDef.h:167
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::xml::ParseDef::getConsumer
shared_ptr< ParseDefConsume > getConsumer() const
Get data consumer.
Definition: ParseDef.cc:434
zypp::xml::ParseDef::isOptional
bool isOptional() const
Definition: ParseDef.cc:394
zypp::xml::ParseDef::addNode
ParseDef & addNode(ParseDef &subnode_r)
Add subnode definition.
Definition: ParseDef.cc:409
zypp::xml::ParseDefTraits::BIT_MULTIPLE
Definition: ParseDefTraits.h:45
zypp::xml::ParseDef::operator<<
friend std::ostream & operator<<(std::ostream &str, const ParseDef &obj)
Definition: ParseDef.cc:463
zypp::xml::ParseDef::OPTIONAL
Definition: ParseDef.h:135
zypp::xml::ParseDef::cancelConsumer
void cancelConsumer()
Unset data consumer.
Definition: ParseDef.cc:431
zypp::xml::ParseDef::~ParseDef
virtual ~ParseDef()
Definition: ParseDef.cc:385
zypp::xml::ParseDef::MULTIPLE_MANDTAORY
Definition: ParseDef.h:138
xml
zypp::xml::ParseDef::operator[]
ParseDef operator[](const std::string &name_r)
Get subnode by name.
Definition: ParseDef.cc:412
zypp::xml::ParseDef::mode
Mode mode() const
Definition: ParseDef.cc:391
zypp::xml::ParseDef::visited
unsigned visited() const
Definition: ParseDef.cc:406
zypp::xml::ParseDef::MULTIPLE_OPTIONAL
Definition: ParseDef.h:137
zypp::xml::ParseDef::name
const std::string & name() const
Definition: ParseDef.cc:388
zypp::xml::ParseDefTraits
Definition: ParseDefTraits.h:29
zypp::xml::ParseDef::setConsumer
void setConsumer(const shared_ptr< ParseDefConsume > &target_r)
Set data consumer.
Definition: ParseDef.cc:422
str
String related utilities and Regular expression matching.
ParseDefTraits.h
zypp::xml::ParseDef::singleDef
bool singleDef() const
Definition: ParseDef.cc:400
zypp::xml::ParseDef::_debug
static bool _debug
Definition: ParseDef.h:229