libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_PARSER_XML_PARSEDEF_H 00013 #define ZYPP_PARSER_XML_PARSEDEF_H 00014 00015 #include <iosfwd> 00016 00017 #include "zypp/base/PtrTypes.h" 00018 #include "zypp/parser/xml/ParseDefTraits.h" 00019 00021 namespace zypp 00022 { 00023 00024 namespace xml 00025 { 00026 00027 class Reader; 00028 class ParseDefConsume; 00029 00031 // 00032 // CLASS NAME : ParseDef 00033 // 00128 class ParseDef 00129 { 00130 typedef ParseDefTraits Traits; 00131 00132 public: 00133 enum Mode 00134 { 00135 OPTIONAL = Traits::BIT_OPTIONAL | Traits::BIT_ONCE, 00136 MANDTAORY = Traits::BIT_MANDTAORY | Traits::BIT_ONCE, 00137 MULTIPLE_OPTIONAL = Traits::BIT_OPTIONAL | Traits::BIT_MULTIPLE, 00138 MULTIPLE_MANDTAORY = Traits::BIT_MANDTAORY | Traits::BIT_MULTIPLE 00139 }; 00140 00141 public: 00142 ParseDef( const std::string & name_r, Mode mode_r ); 00143 ParseDef( const std::string & name_r, Mode mode_r, const shared_ptr<ParseDefConsume> & target_r ); 00144 00145 virtual ~ParseDef(); 00146 00147 public: 00148 const std::string & name() const; 00149 Mode mode() const; 00150 bool isOptional() const; 00151 bool isMandatory() const; 00152 bool singleDef() const; 00153 bool multiDef() const; 00154 unsigned visited() const; 00155 00156 public: 00165 ParseDef & addNode( ParseDef & subnode_r ); 00166 00167 ParseDef & addNode( const std::string & name_r, Mode mode_r ) 00168 { ParseDef tmp( name_r, mode_r ); return addNode( tmp ); } 00169 00170 ParseDef & addNode( const std::string & name_r, Mode mode_r, const shared_ptr<ParseDefConsume> & target_r ) 00171 { ParseDef tmp( name_r, mode_r, target_r ); return addNode( tmp ); } 00172 00176 ParseDef & operator()( ParseDef & subnode_r ) 00177 { return addNode( subnode_r ); } 00178 00179 ParseDef & operator()( const std::string & name_r, Mode mode_r ) 00180 { return addNode( name_r, mode_r ); } 00181 00182 ParseDef & operator()( const std::string & name_r, Mode mode_r, const shared_ptr<ParseDefConsume> & target_r ) 00183 { return addNode( name_r, mode_r, target_r ); } 00184 00188 ParseDef operator[]( const std::string & name_r ); 00189 00190 public: 00192 void setConsumer( const shared_ptr<ParseDefConsume> & target_r ); 00197 void setConsumer( ParseDefConsume * allocatedTarget_r ); 00199 void setConsumer( ParseDefConsume & target_r ); 00201 void cancelConsumer(); 00202 00204 shared_ptr<ParseDefConsume> getConsumer() const; 00205 00216 void take( Reader & reader_r ); 00217 00218 private: 00220 class Impl; 00222 RW_pointer<Impl> _pimpl; 00223 00224 ParseDef( const shared_ptr<Impl> & pimpl_r ); 00225 friend std::ostream & operator<<( std::ostream & str, const ParseDef & obj ); 00226 friend std::ostream & operator<<( std::ostream & str, const ParseDef::Impl & obj ); 00227 00228 public: 00229 static bool _debug; 00230 }; 00232 00234 std::ostream & operator<<( std::ostream & str, ParseDef::Mode obj ); 00235 00237 std::ostream & operator<<( std::ostream & str, const ParseDef & obj ); 00238 00240 } // namespace xml 00243 } // namespace zypp 00245 #endif // ZYPP_PARSER_XML_PARSEDEF_H