1 /*-----------------------------------------------------------------------------
  2 Name:      XmlQoSBase.h
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 Comment:   Handling one QoS (quality of service), knows how to parse it 
  6            with SAX
  7 -----------------------------------------------------------------------------*/
  8 
  9 #ifndef _UTIL_XMLQOSBASE_H
 10 #define _UTIL_XMLQOSBASE_H
 11 
 12 #include <util/xmlBlasterDef.h>
 13 #include <util/parser/XmlHandlerBase.h>
 14 #include <util/ReferenceCounterBase.h>
 15 #include <util/ReferenceHolder.h>
 16 #include <string>
 17 
 18 namespace org { namespace xmlBlaster { namespace util {
 19     /**
 20      * In good old C days this would have been named a 'flag' (with bit wise 
 21      * setting)<br />
 22      * But this allows to specify QoS (quality of service) in XML syntax.<p />
 23      * With XML there are no problems to extend the services of the xmlBlaster
 24      * in unlimited ways.<br />
 25      * The xml std::string is parsed with a SAX parser, since no persistent DOM 
 26      * tree is needed and SAX is much faster. <p />
 27      * You may use this as a base class for your specialized QoS.<br />
 28      * The &lt;qos> tag is parsed here, and you provide the parsing of the 
 29      * inner tags.
 30      */
 31     class Dll_Export XmlQoSBase : public parser::XmlHandlerBase, public ReferenceCounterBase
 32     {
 33 
 34     private:
 35 
 36        std::string me()
 37        {
 38           return "XmlQoSBase";
 39        }
 40        
 41     protected:
 42 
 43        bool inQos_; // parsing inside <qos> ? </qos>
 44        
 45     public:
 46 
 47        /**
 48         * Constructs an un initialized QoS (quality of service) object.
 49         * You need to call the init() method to parse the XML std::string.
 50         */
 51        XmlQoSBase(org::xmlBlaster::util::Global& global);
 52 
 53     protected:
 54 
 55        /**
 56         * To avoid SAX parsing (which costs many CPU cycles)
 57         * check the QoS std::string here if it contains anything useful.
 58         * @param qos The literal ASCII xml std::string
 59         */
 60        bool isEmpty(const std::string &qos);
 61 
 62        /**
 63         * Start element callback, does handling of tag &lt;qos>. <p />
 64         * You may include this into your derived startElement() method like 
 65         * this:<br />
 66         * <pre>
 67         *  if (util::XmlQoSBase::startElementBase(name, attrs)) return;
 68         * </pre>
 69         * @return true if the tag is parsed here, the derived class doesn't 
 70         *         need to look at this tag anymore
 71         *         false this tag is not handled by this Base class
 72         */
 73        bool startElementBase(const std::string &name, const parser::AttributeMap& /*attrs*/);
 74 
 75     public:
 76        /**
 77         * Start element.<p />
 78         * Default implementation, knows how to parse &lt;qos> but knows 
 79         * nothing about the tags inside of qos
 80         */
 81        void startElement(const std::string &name, const parser::AttributeMap &attrs);
 82        
 83     protected:
 84        /**
 85         * End element callback, does handling of tag &lt;qos>. <p />
 86         * You may include this into your derived endElement() method like 
 87         * this:<br />
 88         * <pre>
 89         *  if (SaxHandlerBase::endElementBase(name) == true)
 90         *     return;
 91         * </pre>
 92         * @return true if the tag is parsed here, the derived class doesn't 
 93         *         need to look at this tag anymore
 94         *         false this tag is not handled by this Base class
 95         */
 96        bool endElementBase(const std::string &name);
 97 
 98     public:
 99        /** End element.
100         * <p />
101         * Default implementation, knows how to parse &lt;qos> but knows 
102         * nothing about the tags inside of qos
103         */
104        void endElement(const std::string &name);
105     };
106 }}} // namespace
107 
108 
109 #endif


syntax highlighted by Code2HTML, v. 0.9.1