2005-12-01 17:13:42 +01:00
|
|
|
#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
|
|
|
|
{
|
2005-12-01 17:13:42 +01:00
|
|
|
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>
|
2005-12-01 17:13:42 +01:00
|
|
|
{
|
2007-09-05 13:47:13 +02:00
|
|
|
typedef Arabica::SAX2DOM::Parser<stringT, string_adaptorT, SAX_parser> BaseT;
|
2005-12-01 17:13:42 +01:00
|
|
|
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;
|
2005-12-01 17:13:42 +01:00
|
|
|
|
|
|
|
void setElementEndHandler(ElementHandlerT func)
|
2006-01-05 17:30:31 +01:00
|
|
|
{
|
|
|
|
elementEndFunc_ = func;
|
|
|
|
} // setElementEndHandler
|
2005-12-01 17:13:42 +01:00
|
|
|
|
|
|
|
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)
|
2005-12-01 17:13:42 +01:00
|
|
|
return;
|
|
|
|
|
2007-09-10 10:19:44 +02:00
|
|
|
Arabica::DOM::Node<stringT, string_adaptorT> child(BaseT::currentNode());
|
2005-12-01 17:13:42 +01:00
|
|
|
|
|
|
|
BaseT::endElement(namespaceURI, localName, qName);
|
|
|
|
|
2006-01-05 17:30:31 +01:00
|
|
|
if(!!elementEndFunc_)
|
|
|
|
elementEndFunc_(BaseT::currentNode(), child);
|
2005-12-01 17:13:42 +01:00
|
|
|
} // endElement
|
|
|
|
|
|
|
|
private:
|
2006-01-05 17:30:31 +01:00
|
|
|
ElementHandlerT elementEndFunc_;
|
2005-12-01 17:13:42 +01:00
|
|
|
}; // class Parser
|
|
|
|
|
|
|
|
} // namespace DualMode
|
2007-09-05 13:47:13 +02:00
|
|
|
} // namespace Arabica
|
2005-12-01 17:13:42 +01:00
|
|
|
|
2006-01-05 17:30:31 +01:00
|
|
|
#endif
|