ParseDef.h

Go to the documentation of this file.
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 
00144       virtual ~ParseDef();
00145 
00146     public:
00147       const std::string & name() const;
00148       Mode mode() const;
00149       bool isOptional() const;
00150       bool isMandatory() const;
00151       bool singleDef() const;
00152       bool multiDef() const;
00153       unsigned visited() const;
00154 
00155     public:
00164       ParseDef & addNode( ParseDef & subnode_r );
00165 
00166       ParseDef & addNode( const std::string & name_r, Mode mode_r )
00167       { ParseDef tmp( name_r, mode_r ); return addNode( tmp ); }
00168 
00172       ParseDef & operator()( ParseDef & subnode_r )
00173       { return addNode( subnode_r ); }
00174 
00175       ParseDef & operator()( const std::string & name_r, Mode mode_r )
00176       { return addNode( name_r, mode_r ); }
00177 
00181       ParseDef operator[]( const std::string & name_r );
00182 
00183     public:
00185       void setConsumer( const shared_ptr<ParseDefConsume> & target_r );
00190       void setConsumer( ParseDefConsume * allocatedTarget_r );
00192       void setConsumer( ParseDefConsume & target_r );
00194       void cancelConsumer();
00195 
00197       shared_ptr<ParseDefConsume> getConsumer() const;
00198 
00209       void take( Reader & reader_r );
00210 
00211     private:
00213       class Impl;
00215       RW_pointer<Impl> _pimpl;
00216 
00217       ParseDef( const shared_ptr<Impl> & pimpl_r );
00218       friend std::ostream & operator<<( std::ostream & str, const ParseDef & obj );
00219       friend std::ostream & operator<<( std::ostream & str, const ParseDef::Impl & obj );
00220 
00221     public:
00222       static bool _debug;
00223     };
00225 
00227     std::ostream & operator<<( std::ostream & str, ParseDef::Mode obj );
00228 
00230     std::ostream & operator<<( std::ostream & str, const ParseDef & obj );
00231 
00233   } // namespace xml
00236 } // namespace zypp
00238 #endif // ZYPP_PARSER_XML_PARSEDEF_H

Generated on Tue Sep 25 19:23:03 2007 for libzypp by  doxygen 1.5.3