diff --git a/include/DOM/SAX2DOM/SAX2DOM.hpp b/include/DOM/SAX2DOM/SAX2DOM.hpp index 3295d725..a529d10c 100644 --- a/include/DOM/SAX2DOM/SAX2DOM.hpp +++ b/include/DOM/SAX2DOM/SAX2DOM.hpp @@ -23,17 +23,18 @@ namespace SAX2DOM template, class SAX_parser = Arabica::SAX::XMLReader > -class Parser : protected Arabica::SAX::DefaultHandler +class Parser : protected Arabica::SAX::DefaultHandler { - typedef Arabica::SAX::EntityResolver EntityResolverT; - typedef Arabica::SAX::ErrorHandler ErrorHandlerT; - typedef Arabica::SAX::LexicalHandler LexicalHandlerT; - typedef Arabica::SAX::DeclHandler DeclHandlerT; - typedef Arabica::SAX::InputSource InputSourceT; + typedef Arabica::SAX::Attributes AttributesT; + typedef Arabica::SAX::EntityResolver EntityResolverT; + typedef Arabica::SAX::ErrorHandler ErrorHandlerT; + typedef Arabica::SAX::LexicalHandler LexicalHandlerT; + typedef Arabica::SAX::DeclHandler DeclHandlerT; + typedef Arabica::SAX::InputSource InputSourceT; typedef Arabica::SimpleDOM::EntityImpl EntityT; typedef Arabica::SimpleDOM::NotationImpl NotationT; typedef Arabica::SimpleDOM::ElementImpl ElementT; - typedef typename Arabica::SAX::ErrorHandler::SAXParseExceptionT SAXParseExceptionT; + typedef typename ErrorHandlerT::SAXParseExceptionT SAXParseExceptionT; public: Parser() : @@ -93,8 +94,8 @@ class Parser : protected Arabica::SAX::DefaultHandler if(entityResolver_) parser.setEntityResolver(*entityResolver_); - setParserProperty(parser, pNames.lexicalHandler); - setParserProperty(parser, pNames.declHandler); + parser.setLexicalHandler(*this); + parser.setDeclHandler(*this); setParserFeatures(parser); @@ -156,20 +157,6 @@ class Parser : protected Arabica::SAX::DefaultHandler Arabica::SAX::AttributeTypes attributeTypes_; protected: - template - void setParserProperty(SAX_parser& parser, const stringT& propertyName) - { - try { -#ifndef __BORLANDC__ - // this line causes a crash with BCB 6 => may be a compiler bug - parser.setProperty(propertyName, static_cast(*this)); -#else - parser.setProperty(propertyName, *(interfaceT*)this); -#endif - } // try - catch(Arabica::SAX::SAXException&) { } - } // setParserProperty - void setParserFeatures(SAX_parser& parser) const { for(typename Features::const_iterator f = features_.begin(), e = features_.end(); f != e; ++f) @@ -187,7 +174,7 @@ class Parser : protected Arabica::SAX::DefaultHandler } // endDocument virtual void startElement(const stringT& namespaceURI, const stringT& localName, - const stringT& qName, const Arabica::SAX::Attributes& atts) + const stringT& qName, const AttributesT& atts) { if(currentNode_ == 0) return; diff --git a/include/SAX/filter/NamespaceTracker.hpp b/include/SAX/filter/NamespaceTracker.hpp index 9ca53b31..99d2e2d8 100644 --- a/include/SAX/filter/NamespaceTracker.hpp +++ b/include/SAX/filter/NamespaceTracker.hpp @@ -12,24 +12,25 @@ namespace Arabica namespace SAX { -template > -class NamespaceTracker : public XMLFilterImpl +template +class NamespaceTracker : public XMLFilterImpl { + typedef XMLFilterImpl XMLFilterT; + typedef typename XMLFilterT::string_adaptor string_adaptor; typedef NamespaceSupport NamespaceSupportT; typedef typename NamespaceSupportT::stringListT stringListT; - typedef XMLFilterImpl XMLFilterT; public: - typedef XMLReaderInterface XMLReaderT; + typedef XMLReaderInterface XMLReaderT; typedef Attributes AttributesT; NamespaceTracker() : - XMLFilterImpl() + XMLFilterT() { } // NamespaceTracker NamespaceTracker(XMLReaderT& parent) : - XMLFilterImpl(parent) + XMLFilterT(parent) { } // NamespaceTracker diff --git a/include/SAX/filter/PYXWriter.hpp b/include/SAX/filter/PYXWriter.hpp index 8b6ff5a8..63fa49da 100644 --- a/include/SAX/filter/PYXWriter.hpp +++ b/include/SAX/filter/PYXWriter.hpp @@ -11,18 +11,17 @@ namespace Arabica namespace SAX { -template -class PYXWriter : public XMLFilterImpl +template +class PYXWriter : public XMLFilterImpl { public: - typedef string_type stringT; - typedef PYXWriter PYXWriterT; + typedef XMLReaderInterface XMLReaderT; + typedef XMLFilterImpl XMLFilterT; + typedef typename XMLFilterT::AttributesT AttributesT; + typedef typename XMLFilterT::string_adaptor string_adaptor; typedef typename string_type::value_type charT; typedef typename string_type::traits_type traitsT; typedef std::basic_ostream ostreamT; - typedef XMLReaderInterface XMLReaderT; - typedef XMLFilterImpl XMLFilterT; - typedef typename XMLFilterImpl::AttributesT AttributesT; typedef Arabica::Unicode UnicodeT; private: using XMLFilterT::getParent; @@ -42,23 +41,23 @@ class PYXWriter : public XMLFilterImpl public: // ContentHandler - virtual void startElement(const stringT& namespaceURI, const stringT& localName, - const stringT& qName, const AttributesT& atts); - virtual void endElement(const stringT& namespaceURI, const stringT& localName, - const stringT& qName); - virtual void characters(const stringT& ch); - virtual void processingInstruction(const stringT& target, const stringT& data); + virtual void startElement(const string_type& namespaceURI, const string_type& localName, + const string_type& qName, const AttributesT& atts); + virtual void endElement(const string_type& namespaceURI, const string_type& localName, + const string_type& qName); + virtual void characters(const string_type& ch); + virtual void processingInstruction(const string_type& target, const string_type& data); private: - void escape(const stringT& ch); + void escape(const string_type& ch); ostreamT* stream_; }; // class PYXWriter -template> -void PYXWriter::startElement( - const stringT& namespaceURI, const stringT& localName, - const stringT& qName, const AttributesT& atts) +template +void PYXWriter::startElement( + const string_type& namespaceURI, const string_type& localName, + const string_type& qName, const AttributesT& atts) { *stream_ << UnicodeT::LEFT_PARENTHESIS << localName << std::endl; for(int i = 0; i < atts.getLength(); ++i) @@ -72,18 +71,18 @@ void PYXWriter::startElement( XMLFilterT::startElement(namespaceURI, localName, qName, atts); } // startElement -template> -void PYXWriter::endElement( - const stringT& namespaceURI, const stringT& localName, - const stringT& qName) +template +void PYXWriter::endElement( + const string_type& namespaceURI, const string_type& localName, + const string_type& qName) { *stream_ << UnicodeT::RIGHT_PARENTHESIS << localName << std::endl; XMLFilterT::endElement(namespaceURI, localName, qName); } // endElement -template> -void PYXWriter::characters(const stringT& ch) +template +void PYXWriter::characters(const string_type& ch) { *stream_ << UnicodeT::HYPHEN_MINUS; escape(ch); @@ -92,8 +91,8 @@ void PYXWriter::characters(const stringT& ch) XMLFilterT::characters(ch); } // characters -template> -void PYXWriter::processingInstruction(const stringT& target, const stringT& data) +template +void PYXWriter::processingInstruction(const string_type& target, const string_type& data) { *stream_ << UnicodeT::QUESTION_MARK << target << UnicodeT::SPACE << data @@ -102,10 +101,10 @@ void PYXWriter::processingInstruction(const stringT XMLFilterT::processingInstruction(target, data); } // processingInstruction -template> -void PYXWriter::escape(const stringT& ch) +template +void PYXWriter::escape(const string_type& ch) { - for(typename stringT::const_iterator s = ch.begin(), se = ch.end(); s != se; ++s) + for(typename string_type::const_iterator s = ch.begin(), se = ch.end(); s != se; ++s) if(*s == UnicodeT::LINE_FEED) *stream_ << UnicodeT::BACK_SLASH << UnicodeT::LOWERCASE_N; else diff --git a/include/SAX/filter/TextCoalescer.hpp b/include/SAX/filter/TextCoalescer.hpp index 0ad31f8b..e368697b 100644 --- a/include/SAX/filter/TextCoalescer.hpp +++ b/include/SAX/filter/TextCoalescer.hpp @@ -16,13 +16,14 @@ namespace SAX an issue, and sometimes it makes things a little awkward. This filter buffers up multiple calls to characters(...) and reports text in a single lump. */ -template > -class TextCoalescer : public XMLFilterImpl +template +class TextCoalescer : public XMLFilterImpl { - typedef XMLFilterImpl XMLFilterT; + typedef XMLFilterImpl XMLFilterT; + typedef typename XMLFilterT::string_adaptor string_adaptor; public: - typedef XMLReaderInterfaceXMLReaderT; + typedef XMLReaderInterface XMLReaderT; typedef Attributes AttributesT; TextCoalescer() : diff --git a/include/SAX/filter/TextOnly.hpp b/include/SAX/filter/TextOnly.hpp index 9861230a..43925fa9 100644 --- a/include/SAX/filter/TextOnly.hpp +++ b/include/SAX/filter/TextOnly.hpp @@ -13,7 +13,7 @@ namespace SAX /** Strips out everything except startDocument, endDocument and text */ -template > +template class TextOnly : public XMLFilterImpl { typedef XMLFilterImpl XMLFilterT; diff --git a/include/SAX/filter/WhitespaceStripperFilter.hpp b/include/SAX/filter/WhitespaceStripperFilter.hpp index fe3d343a..7b493dcc 100644 --- a/include/SAX/filter/WhitespaceStripperFilter.hpp +++ b/include/SAX/filter/WhitespaceStripperFilter.hpp @@ -10,30 +10,30 @@ namespace Arabica namespace SAX { -template > -class WhitespaceStripper : public SAX::XMLFilterImpl +template +class WhitespaceStripper : public SAX::XMLFilterImpl { public: - typedef string_type stringT; - typedef SAX::XMLFilterImpl baseT; - typedef SAX::XMLReader XMLReaderT; + typedef SAX::XMLReader XMLReaderT; + typedef SAX::XMLFilterImpl XMLFilterT; + typedef typename XMLFilterT::string_adaptor string_adaptor; WhitespaceStripper() : - baseT() + XMLFilterT() { } // WhitespaceStripper WhitespaceStripper(XMLReaderT& parent) : - baseT(parent) + XMLFilterT(parent) { } // WhitespaceStripper - virtual void characters(const stringT& ch) + virtual void characters(const string_type& ch) { - baseT::characters(Arabica::string::normalize_whitespace(ch)); + XMLFilterT::characters(Arabica::string::normalize_whitespace(ch)); } // characters - virtual void ignorableWhitespace(const stringT& ch) + virtual void ignorableWhitespace(const string_type& ch) { } // ignorableWhitespace }; // class WhitespaceStripper diff --git a/include/SAX/filter/XMLBaseTracker.hpp b/include/SAX/filter/XMLBaseTracker.hpp index 620a129f..84153315 100644 --- a/include/SAX/filter/XMLBaseTracker.hpp +++ b/include/SAX/filter/XMLBaseTracker.hpp @@ -11,26 +11,27 @@ namespace Arabica namespace SAX { -template > -class XMLBaseTracker : public XMLFilterImpl +template +class XMLBaseTracker : public XMLFilterImpl { + typedef XMLFilterImpl XMLFilterT; + typedef typename XMLFilterT::string_adaptor string_adaptor; typedef XMLBaseSupport XMLBaseSupportT; - typedef XMLFilterImpl XMLFilterT; public: - typedef XMLReaderInterface XMLReaderT; + typedef XMLReaderInterface XMLReaderT; typedef Locator LocatorT; typedef Attributes AttributesT; XMLBaseTracker() : - XMLFilterImpl(), + XMLFilterT(), locator_(0), base_set_(false) { } // XMLBaseTracker XMLBaseTracker(XMLReaderT& parent) : - XMLFilterImpl(parent), + XMLFilterT(parent), locator_(0), base_set_(false) { diff --git a/include/XSLT/impl/handler/xslt_include_handler.hpp b/include/XSLT/impl/handler/xslt_include_handler.hpp index 89c05078..cf5f74f5 100644 --- a/include/XSLT/impl/handler/xslt_include_handler.hpp +++ b/include/XSLT/impl/handler/xslt_include_handler.hpp @@ -77,7 +77,7 @@ public: } } // startElement - virtual void startPrefixMapping(const stringT& prefix, const stringT& uri) + virtual void startPrefixMapping(const std::string& prefix, const std::string& uri) { context_->parentHandler().startPrefixMapping(prefix, uri); } // startPrefixMapping diff --git a/include/XSLT/impl/xslt_sink.hpp b/include/XSLT/impl/xslt_sink.hpp index 09cc2169..298d9761 100755 --- a/include/XSLT/impl/xslt_sink.hpp +++ b/include/XSLT/impl/xslt_sink.hpp @@ -305,7 +305,7 @@ private: int pending_attribute_; std::string name_; std::string namespaceURI_; - SAX::AttributesImpl atts_; + SAX::AttributesImpl > atts_; std::stringstream buffer_; bool text_mode_; NamespaceStack namespaceStack_; diff --git a/tests/DOM/test_SAX2DOM.hpp b/tests/DOM/test_SAX2DOM.hpp index fdbbcdeb..1ad6903e 100644 --- a/tests/DOM/test_SAX2DOM.hpp +++ b/tests/DOM/test_SAX2DOM.hpp @@ -28,8 +28,8 @@ class SAX2DOMTest : public TestCase std::stringstream ss; ss << SA::asStdString(str); - Arabica::SAX::InputSource is(ss); - Arabica::SAX::CatchErrorHandler eh; + Arabica::SAX::InputSource is(ss); + Arabica::SAX::CatchErrorHandler eh; Arabica::SAX2DOM::Parser parser; parser.setErrorHandler(eh); parser.parse(is); diff --git a/tests/DOM/test_TreeWalker.hpp b/tests/DOM/test_TreeWalker.hpp index c2d9fba0..ff94da75 100644 --- a/tests/DOM/test_TreeWalker.hpp +++ b/tests/DOM/test_TreeWalker.hpp @@ -28,8 +28,8 @@ class TreeWalkerTest : public TestCase std::stringstream ss; ss << SA::asStdString(str); - Arabica::SAX::InputSource is(ss); - Arabica::SAX::CatchErrorHandler eh; + Arabica::SAX::InputSource is(ss); + Arabica::SAX::CatchErrorHandler eh; Arabica::SAX2DOM::Parser parser; parser.setErrorHandler(eh); parser.parse(is);