libzypp: zypp/parser/xml/ParseDef.h Source File

libzypp 17.38.14

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-core/base/PtrTypes.h>
18#include <zypp/parser/xml/ParseDefTraits.h>
19
21namespace zypp
22{
24 namespace xml
25 {
26
27 class Reader;
28 struct ParseDefConsume;
29
31 //
32 // CLASS NAME : ParseDef
33 //
128 class ParseDef
129 {
130 using Traits = ParseDefTraits;
131
132 public:
133 enum Mode
134 {
135 OPTIONAL = Traits::BIT_OPTIONAL | Traits::BIT_ONCE,
136 MANDTAORY = Traits::BIT_MANDTAORY | Traits::BIT_ONCE,
137 MULTIPLE_OPTIONAL = Traits::BIT_OPTIONAL | Traits::BIT_MULTIPLE,
138 MULTIPLE_MANDTAORY = Traits::BIT_MANDTAORY | Traits::BIT_MULTIPLE
139 };
140
141 public:
142 ParseDef( std::string name_r, Mode mode_r );
143 ParseDef( std::string name_r, Mode mode_r, 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;
222 RW_pointer<Impl> _pimpl;
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 };
231
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
ParseDefTraits.h
PtrTypes.h
Impl
shared_ptr
zypp::xml::ParseDef::Impl
ParseDef implementation.
Definition ParseDef.cc:96
zypp::xml::ParseDef
Define a xml node structure to parse.
Definition ParseDef.h:129
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::ParseDef::setConsumer
void setConsumer(const shared_ptr< ParseDefConsume > &target_r)
Set data consumer.
Definition ParseDef.cc:428
zypp::xml::ParseDef::name
const std::string & name() const
Definition ParseDef.cc:394
zypp::xml::ParseDef::~ParseDef
virtual ~ParseDef()
Definition ParseDef.cc:391
zypp::xml::ParseDef::ParseDef
ParseDef(std::string name_r, Mode mode_r)
Definition ParseDef.cc:374
zypp::xml::ParseDef::Mode
Mode
Definition ParseDef.h:134
zypp::xml::ParseDef::OPTIONAL
@ OPTIONAL
Definition ParseDef.h:135
zypp::xml::ParseDef::MULTIPLE_OPTIONAL
@ MULTIPLE_OPTIONAL
Definition ParseDef.h:137
zypp::xml::ParseDef::MANDTAORY
@ MANDTAORY
Definition ParseDef.h:136
zypp::xml::ParseDef::MULTIPLE_MANDTAORY
@ MULTIPLE_MANDTAORY
Definition ParseDef.h:138
zypp::xml::ParseDef::cancelConsumer
void cancelConsumer()
Unset data consumer.
Definition ParseDef.cc:437
zypp::xml::ParseDef::singleDef
bool singleDef() const
Definition ParseDef.cc:406
zypp::xml::ParseDef::Traits
ParseDefTraits Traits
Definition ParseDef.h:130
zypp::xml::ParseDef::_pimpl
RW_pointer< Impl > _pimpl
Pointer to implementation (shared!).
Definition ParseDef.h:222
zypp::xml::ParseDef::addNode
ParseDef & addNode(ParseDef &subnode_r)
Add subnode definition.
Definition ParseDef.cc:415
zypp::xml::ParseDef::getConsumer
shared_ptr< ParseDefConsume > getConsumer() const
Get data consumer.
Definition ParseDef.cc:440
zypp::xml::ParseDef::operator<<
friend std::ostream & operator<<(std::ostream &str, const ParseDef &obj)
relates: ParseDef Stream output.
Definition ParseDef.cc:471
zypp::xml::ParseDef::isOptional
bool isOptional() const
Definition ParseDef.cc:400
zypp::xml::ParseDef::addNode
ParseDef & addNode(const std::string &name_r, Mode mode_r)
Definition ParseDef.h:167
zypp::xml::ParseDef::operator[]
ParseDef operator[](const std::string &name_r)
Get subnode by name.
Definition ParseDef.cc:418
zypp::xml::ParseDef::multiDef
bool multiDef() const
Definition ParseDef.cc:409
zypp::xml::ParseDef::take
void take(Reader &reader_r)
Parse the node.
Definition ParseDef.cc:444
zypp::xml::ParseDef::operator()
ParseDef & operator()(ParseDef &subnode_r)
Add subnode definition.
Definition ParseDef.h:176
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::ParseDef::operator()
ParseDef & operator()(const std::string &name_r, Mode mode_r)
Definition ParseDef.h:179
zypp::xml::ParseDef::visited
unsigned visited() const
Definition ParseDef.cc:412
zypp::xml::ParseDef::_debug
static bool _debug
Definition ParseDef.h:229
zypp::xml::ParseDef::isMandatory
bool isMandatory() const
Definition ParseDef.cc:403
zypp::xml::ParseDef::mode
Mode mode() const
Definition ParseDef.cc:397
zypp::xml::Reader
xmlTextReader based interface to iterate xml streams.
Definition Reader.h:96
str
String related utilities and Regular expression matching.
zypp::xml
Definition libxmlfwd.cc:22
zypp::xml::operator<<
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
relates: ReadState Stream output.
Definition libxmlfwd.cc:29
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
zypp::xml::ParseDefConsume
Base class for ParseDef consumer.
Definition ParseDefConsume.h:40
zypp::xml::ParseDefTraits
Definition ParseDefTraits.h:30
zypp::xml::ParseDefTraits::BIT_MULTIPLE
@ BIT_MULTIPLE
Definition ParseDefTraits.h:45
zypp::xml::ParseDefTraits::BIT_ONCE
@ BIT_ONCE
Definition ParseDefTraits.h:44
zypp::xml::ParseDefTraits::BIT_MANDTAORY
@ BIT_MANDTAORY
Definition ParseDefTraits.h:39
zypp::xml::ParseDefTraits::BIT_OPTIONAL
@ BIT_OPTIONAL
Definition ParseDefTraits.h:38