arabica/include/DOM/DualMode/DualMode.hpp

48 lines
1.4 KiB
C++
Raw Normal View History

#ifndef ARABICA_DOM_DUALMODE_DUALMODE_HPP
#define ARABICA_DOM_DUALMODE_DUALMODE_HPP
#include <DOM/SAX2DOM/SAX2DOM.h>
#include <boost/function.hpp>
2007-09-05 13:47:13 +02:00
namespace Arabica
{
namespace DualMode
{
template<class stringT,
class string_adaptorT = Arabica::default_string_adaptor<stringT>,
2007-09-05 11:49:18 +02:00
class SAX_parser = Arabica::SAX::XMLReader<stringT, string_adaptorT> >
2007-09-05 13:47:13 +02:00
class Parser : public Arabica::SAX2DOM::Parser<stringT, string_adaptorT, SAX_parser>
{
2007-09-05 13:47:13 +02:00
typedef Arabica::SAX2DOM::Parser<stringT, string_adaptorT, SAX_parser> BaseT;
public:
2007-09-10 10:19:44 +02:00
typedef boost::function2<void, Arabica::DOM::Node<stringT, string_adaptorT> &, Arabica::DOM::Node<stringT, string_adaptorT> &> ElementHandlerT;
void setElementEndHandler(ElementHandlerT func)
2006-01-05 17:30:31 +01:00
{
elementEndFunc_ = func;
} // setElementEndHandler
protected:
virtual void endElement(const stringT& namespaceURI, const stringT& localName,
const stringT& qName)
{
2006-01-05 17:30:31 +01:00
if(BaseT::currentNode() == 0)
return;
2007-09-10 10:19:44 +02:00
Arabica::DOM::Node<stringT, string_adaptorT> child(BaseT::currentNode());
BaseT::endElement(namespaceURI, localName, qName);
2006-01-05 17:30:31 +01:00
if(!!elementEndFunc_)
elementEndFunc_(BaseT::currentNode(), child);
} // endElement
private:
2006-01-05 17:30:31 +01:00
ElementHandlerT elementEndFunc_;
}; // class Parser
} // namespace DualMode
2007-09-05 13:47:13 +02:00
} // namespace Arabica
2006-01-05 17:30:31 +01:00
#endif