From 625c7141e1a35b32817b6f87c7f13ecc27133f07 Mon Sep 17 00:00:00 2001 From: jez_higgins <> Date: Thu, 8 Jun 2006 09:51:18 +0000 Subject: [PATCH] vc6 compatibility fixes --- DOM/SAX2DOM/SAX2DOM.h | 11 ++- DOM/Simple/AttrNSImpl.h | 2 +- DOM/Simple/ElementNSImpl.h | 2 +- DOM/Simple/Helpers.h | 2 +- SAX/SAX.dsp | 4 +- SAX/SAX.vcproj | 4 +- SAX/helpers/NamespaceSupport.h | 2 +- SAX/helpers/ParserAdaptor.h | 2 +- SAX/helpers/XMLBaseSupport.h | 2 +- SAX/wrappers/saxexpat.h | 2 +- SAX/wrappers/saxlibxml2.h | 2 +- SAX/wrappers/saxxerces.h | 2 +- Utils/StringAdaptor.h | 6 +- Utils/convertstream.h | 2 +- XPath/impl/xpath_function.hpp | 8 +- test/SAX2DOM/SAX2DOM_test.dsp | 138 ++++++++--------------------- test/silly_string/silly_string.cpp | 2 - test/silly_string/silly_string.hpp | 6 +- 18 files changed, 74 insertions(+), 125 deletions(-) diff --git a/DOM/SAX2DOM/SAX2DOM.h b/DOM/SAX2DOM/SAX2DOM.h index b17baf2b..43cf643d 100644 --- a/DOM/SAX2DOM/SAX2DOM.h +++ b/DOM/SAX2DOM/SAX2DOM.h @@ -25,6 +25,9 @@ class Parser : protected SAX::basic_DefaultHandler2 { typedef SAX::basic_EntityResolver EntityResolverT; typedef SAX::basic_ErrorHandler ErrorHandlerT; + typedef SAX::basic_LexicalHandler LexicalHandlerT; + typedef SAX::basic_DeclHandler DeclHandlerT; + typedef SAX::basic_InputSource InputSourceT; typedef SimpleDOM::EntityImpl EntityT; typedef SimpleDOM::NotationImpl NotationT; typedef SimpleDOM::ElementImpl ElementT; @@ -65,11 +68,11 @@ class Parser : protected SAX::basic_DefaultHandler2 bool parse(const stringT& systemId) { - SAX::basic_InputSource is(systemId); + InputSourceT is(systemId); return parse(is); } // loadDOM - bool parse(SAX::basic_InputSource& source) + bool parse(InputSourceT& source) { SAX::PropertyNames pNames; @@ -85,8 +88,8 @@ class Parser : protected SAX::basic_DefaultHandler2 if(entityResolver_) parser.setEntityResolver(*entityResolver_); - setParserProperty >(parser, pNames.lexicalHandler); - setParserProperty >(parser, pNames.declHandler); + setParserProperty(parser, pNames.lexicalHandler); + setParserProperty(parser, pNames.declHandler); setParserFeatures(parser); diff --git a/DOM/Simple/AttrNSImpl.h b/DOM/Simple/AttrNSImpl.h index 43006323..fe11b755 100644 --- a/DOM/Simple/AttrNSImpl.h +++ b/DOM/Simple/AttrNSImpl.h @@ -26,7 +26,7 @@ class AttrNSImpl : public AttrImpl stringT const* prefix_for_checking = (&ownerDoc->empty_string()); size_type index = string_adaptorT::find(qualifiedName, string_adaptorT::construct_from_utf8(":")); - if(index == string_adaptorT::npos) + if(index == string_adaptorT::npos()) { //qualifiedName contains no ':' localName_ = AttrT::ownerDoc_->stringPool(qualifiedName); if(*localName_ == string_adaptorT::construct_from_utf8("xmlns")) diff --git a/DOM/Simple/ElementNSImpl.h b/DOM/Simple/ElementNSImpl.h index e9f68f8e..290de2ee 100644 --- a/DOM/Simple/ElementNSImpl.h +++ b/DOM/Simple/ElementNSImpl.h @@ -24,7 +24,7 @@ class ElementNSImpl : public ElementImpl bool hasPrefix = false; size_type index = string_adaptorT::find(qualifiedName, string_adaptorT::construct_from_utf8(":")); - if(index == string_adaptorT::npos) + if(index == string_adaptorT::npos()) { //qualifiedName contains no ':' localName_ = ElementImplT::ownerDoc_->stringPool(qualifiedName); } diff --git a/DOM/Simple/Helpers.h b/DOM/Simple/Helpers.h index bf4ff6fd..da5aa76a 100644 --- a/DOM/Simple/Helpers.h +++ b/DOM/Simple/Helpers.h @@ -22,7 +22,7 @@ std::pair checkPrefixAndNamespace(bool hasPrefix, if(!hasPrefix) return std::make_pair(hasNamespaceURI, namespaceURI); - if(string_adaptorT::find(prefix, string_adaptorT::construct_from_utf8(":")) != string_adaptorT::npos) + if(string_adaptorT::find(prefix, string_adaptorT::construct_from_utf8(":")) != string_adaptorT::npos()) throw DOM::DOMException(DOM::DOMException::NAMESPACE_ERR); if(prefix == xml) diff --git a/SAX/SAX.dsp b/SAX/SAX.dsp index d3375443..c6a13ae2 100644 --- a/SAX/SAX.dsp +++ b/SAX/SAX.dsp @@ -488,8 +488,8 @@ BuildCmds= \ InputPath=.\ParserConfig.S BuildCmds= \ - cl /TC /D USE_EXPAT /EP ParserConfig.S > ParserConfig.h \ - cl /TC /D USE_EXPAT /EP saxlib.S > saxlib.cpp \ + cl /TC /D USE_XERCES /EP ParserConfig.S > ParserConfig.h \ + cl /TC /D USE_XERCES /EP saxlib.S > saxlib.cpp \ "ParserConfig.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" diff --git a/SAX/SAX.vcproj b/SAX/SAX.vcproj index db9ef25e..b4eda2dd 100644 --- a/SAX/SAX.vcproj +++ b/SAX/SAX.vcproj @@ -754,8 +754,8 @@ Name="Debug|Win32"> diff --git a/SAX/helpers/NamespaceSupport.h b/SAX/helpers/NamespaceSupport.h index 19e6168d..0f46d450 100644 --- a/SAX/helpers/NamespaceSupport.h +++ b/SAX/helpers/NamespaceSupport.h @@ -222,7 +222,7 @@ class basic_NamespaceSupport Parts name; typename string_adaptorT::size_type index = string_adaptorT::find(qName, nsc_.colon); - if(index == string_adaptorT::npos) + if(index == string_adaptorT::npos()) { // no prefix name.URI = getURI(stringT()); diff --git a/SAX/helpers/ParserAdaptor.h b/SAX/helpers/ParserAdaptor.h index b3a86e6a..0c1d0a63 100644 --- a/SAX/helpers/ParserAdaptor.h +++ b/SAX/helpers/ParserAdaptor.h @@ -321,7 +321,7 @@ public: { stringT prefix; int n = attQName.find(NamespaceSupportT::COLON); - if(n != stringT::npos) + if(n != stringT::npos()) prefix = stringT(attQName.begin() + n + 1, attQName.end()); if(!nsSupport_.declarePrefix(prefix, value)) reportError("Illegal Namespace prefix " + makeString(prefix)); diff --git a/SAX/helpers/XMLBaseSupport.h b/SAX/helpers/XMLBaseSupport.h index 4c9aeac5..f233dbca 100644 --- a/SAX/helpers/XMLBaseSupport.h +++ b/SAX/helpers/XMLBaseSupport.h @@ -90,7 +90,7 @@ private: static const stringT SCHEME_MARKER = string_adaptorT::construct_from_utf8("://"); static const valueT FORWARD_SLASH = string_adaptorT::convert_from_utf8(Arabica::Unicode::SLASH); - if(location.find(SCHEME_MARKER) != stringT::npos) + if(location.find(SCHEME_MARKER) != stringT::npos()) return location; std::ostringstream ss; diff --git a/SAX/wrappers/saxexpat.h b/SAX/wrappers/saxexpat.h index fad36dd1..79725abb 100644 --- a/SAX/wrappers/saxexpat.h +++ b/SAX/wrappers/saxexpat.h @@ -649,7 +649,7 @@ void expat_wrapper::startElement(const char* qName, const char* { stringT prefix; typename SA::size_type n = SA::find(attQName, nsc_.colon); - if(n != SA::npos) + if(n != SA::npos()) prefix = SA::construct(SA::begin(attQName) + n + 1, SA::end(attQName)); if(!nsSupport_.declarePrefix(prefix, value)) reportError(std::string("Illegal Namespace prefix ") + SA::asStdString(prefix)); diff --git a/SAX/wrappers/saxlibxml2.h b/SAX/wrappers/saxlibxml2.h index c5992a1e..65894b39 100644 --- a/SAX/wrappers/saxlibxml2.h +++ b/SAX/wrappers/saxlibxml2.h @@ -535,7 +535,7 @@ void libxml2_wrapper::SAXstartElement(const xmlChar* qName, con { stringT prefix; typename string_adaptorT::size_type n = string_adaptorT::find(attQName, nsc_.colon); - if(n != string_adaptorT::npos) + if(n != string_adaptorT::npos()) prefix = string_adaptorT::construct(string_adaptorT::begin(attQName) + n + 1, string_adaptorT::end(attQName)); if(!nsSupport_.declarePrefix(prefix, value)) reportError(std::string("Illegal Namespace prefix ") + string_adaptorT::asStdString(prefix)); diff --git a/SAX/wrappers/saxxerces.h b/SAX/wrappers/saxxerces.h index b6c3d7ae..602df76a 100644 --- a/SAX/wrappers/saxxerces.h +++ b/SAX/wrappers/saxxerces.h @@ -317,7 +317,7 @@ class xerces_wrapper : public SAX::basic_ProgressiveParser if(!locator_) return string_type(); - return SA::makeStringT(locator_->getPublicId()); + return xerces_string_adaptor::makeStringT(locator_->getPublicId()); } // getPublicId string_type getSystemId() const diff --git a/Utils/StringAdaptor.h b/Utils/StringAdaptor.h index 27efe790..5d3187e0 100644 --- a/Utils/StringAdaptor.h +++ b/Utils/StringAdaptor.h @@ -26,7 +26,10 @@ public: typedef typename string_type::value_type value_type; typedef typename string_type::size_type size_type; - static const typename string_type::size_type npos = static_cast(-1); + static size_type npos() + { + return static_cast(-1); + } //todo: is this safe? template @@ -93,6 +96,7 @@ public: }; // class default_string_adaptor_base + // specialize for std::string and std::wstring template<> class default_string_adaptor : diff --git a/Utils/convertstream.h b/Utils/convertstream.h index c0a5b548..cc452daf 100644 --- a/Utils/convertstream.h +++ b/Utils/convertstream.h @@ -126,7 +126,7 @@ public: std::use_facet >(this->getloc()); #else const std::codecvt& cvt = - std::use_facet(stringbuf_.getloc(), (std::codecvt*)0, true); + std::use_facet(convertstreambuf_initT::buf()->getloc(), (std::codecvt*)0, true); #endif if(cvt.always_noconv()) diff --git a/XPath/impl/xpath_function.hpp b/XPath/impl/xpath_function.hpp index 05746cba..d9f53517 100644 --- a/XPath/impl/xpath_function.hpp +++ b/XPath/impl/xpath_function.hpp @@ -294,7 +294,7 @@ public: const ExecutionContext& executionContext) const { return new BoolValue(string_adaptor::find(baseT::argAsString(0, context, executionContext), - baseT::argAsString(1, context, executionContext)) != string_adaptor::npos); + baseT::argAsString(1, context, executionContext)) != string_adaptor::npos()); } // evaluate }; // class ContainsFn @@ -312,7 +312,7 @@ public: string_type value = baseT::argAsString(0, context, executionContext); size_t splitAt = string_adaptor::find(value, baseT::argAsString(1, context, executionContext)); - if(splitAt == string_adaptor::npos) + if(splitAt == string_adaptor::npos()) return new StringValue(""); return new StringValue(string_adaptor::substr(value, 0, splitAt)); @@ -334,7 +334,7 @@ public: string_type split = baseT::argAsString(1, context, executionContext); size_t splitAt = string_adaptor::find(value, split); - if((splitAt == string_adaptor::npos) || ((splitAt + string_adaptor::length(split)) >= string_adaptor::length(value))) + if((splitAt == string_adaptor::npos()) || ((splitAt + string_adaptor::length(split)) >= string_adaptor::length(value))) return new StringValue(""); return new StringValue(string_adaptor::substr(value, splitAt + string_adaptor::length(split))); @@ -438,7 +438,7 @@ public: for(typename string_adaptor::mutable_iterator i = string_adaptor::begin(str), ie = string_adaptor::end(str); i != ie; ++i) { size_t r = string_adaptor::find(from, *i); - if(r == string_adaptor::npos) + if(r == string_adaptor::npos()) ++p; else if(r < string_adaptor::length(to)) *p++ = *(string_adaptor::begin(to) + r); diff --git a/test/SAX2DOM/SAX2DOM_test.dsp b/test/SAX2DOM/SAX2DOM_test.dsp index 03cbb0d9..eb9767cb 100644 --- a/test/SAX2DOM/SAX2DOM_test.dsp +++ b/test/SAX2DOM/SAX2DOM_test.dsp @@ -93,59 +93,7 @@ SOURCE=.\main.cpp # End Source File # Begin Source File -SOURCE=.\test_Attribute.cpp -# End Source File -# Begin Source File - -SOURCE=.\test_Document.cpp -# End Source File -# Begin Source File - -SOURCE=.\test_DocumentFragment.cpp -# End Source File -# Begin Source File - -SOURCE=.\test_DocumentType.cpp -# End Source File -# Begin Source File - -SOURCE=.\test_DOMImplementation.cpp -# End Source File -# Begin Source File - -SOURCE=.\test_Element.cpp -# End Source File -# Begin Source File - -SOURCE=.\test_ProcessingInstruction.cpp -# End Source File -# Begin Source File - -SOURCE=.\test_SAX.cpp -# End Source File -# Begin Source File - -SOURCE=.\test_Siblings.cpp -# End Source File -# Begin Source File - -SOURCE=..\CppUnit\framework\TestCase.cpp -# End Source File -# Begin Source File - -SOURCE=..\CppUnit\framework\TestFailure.cpp -# End Source File -# Begin Source File - -SOURCE=..\CppUnit\framework\TestResult.cpp -# End Source File -# Begin Source File - -SOURCE=..\CppUnit\framework\TestSuite.cpp -# End Source File -# Begin Source File - -SOURCE=..\CppUnit\textui\TextTestResult.cpp +SOURCE=..\silly_string\silly_string.cpp # End Source File # End Group # Begin Group "Header Files" @@ -153,6 +101,26 @@ SOURCE=..\CppUnit\textui\TextTestResult.cpp # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File +SOURCE=..\silly_string\silly_string.hpp +# End Source File +# Begin Source File + +SOURCE=.\test_SAX.h +# End Source File +# End Group +# Begin Group "Libs" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\lib\Arabica.lib +# End Source File +# End Group +# Begin Group "CppUnit" + +# PROP Default_Filter "" +# Begin Source File + SOURCE=..\CppUnit\framework\CppUnitException.h # End Source File # Begin Source File @@ -169,71 +137,43 @@ SOURCE=..\CppUnit\framework\Test.h # End Source File # Begin Source File -SOURCE=.\test_Attribute.h -# End Source File -# Begin Source File - -SOURCE=.\test_Document.h -# End Source File -# Begin Source File - -SOURCE=.\test_DocumentFragment.h -# End Source File -# Begin Source File - -SOURCE=.\test_DocumentType.h -# End Source File -# Begin Source File - -SOURCE=.\test_DOMImplementation.h -# End Source File -# Begin Source File - -SOURCE=.\test_Element.h -# End Source File -# Begin Source File - -SOURCE=.\test_Notation.h -# End Source File -# Begin Source File - -SOURCE=.\test_ProcessingInstruction.h -# End Source File -# Begin Source File - -SOURCE=.\test_SAX.h -# End Source File -# Begin Source File - -SOURCE=.\test_Siblings.h -# End Source File -# Begin Source File - SOURCE=.\CppUnit\framework\TestCaller.h # End Source File # Begin Source File +SOURCE=..\CppUnit\framework\TestCase.cpp +# End Source File +# Begin Source File + SOURCE=.\CppUnit\framework\TestCase.h # End Source File # Begin Source File +SOURCE=..\CppUnit\framework\TestFailure.cpp +# End Source File +# Begin Source File + SOURCE=.\CppUnit\framework\TestFailure.h # End Source File # Begin Source File +SOURCE=..\CppUnit\framework\TestResult.cpp +# End Source File +# Begin Source File + SOURCE=.\CppUnit\framework\TestResult.h # End Source File # Begin Source File -SOURCE=.\CppUnit\framework\TestSuite.h +SOURCE=..\CppUnit\framework\TestSuite.cpp # End Source File -# End Group -# Begin Group "Libs" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\lib\Arabica.lib +SOURCE=.\CppUnit\framework\TestSuite.h +# End Source File +# Begin Source File + +SOURCE=..\CppUnit\textui\TextTestResult.cpp # End Source File # End Group # End Target diff --git a/test/silly_string/silly_string.cpp b/test/silly_string/silly_string.cpp index 2097a8ef..928b997c 100644 --- a/test/silly_string/silly_string.cpp +++ b/test/silly_string/silly_string.cpp @@ -30,8 +30,6 @@ silly_string& silly_string::operator=(const silly_string& rhs) //////////////////////////////////////// //////////////////////////////////////// -const silly_string_adaptor::size_type silly_string_adaptor::npos = std::string::npos; - char silly_string_adaptor::convert_from_utf8(char c) { return c; diff --git a/test/silly_string/silly_string.hpp b/test/silly_string/silly_string.hpp index e74c6e11..dd8320bf 100644 --- a/test/silly_string/silly_string.hpp +++ b/test/silly_string/silly_string.hpp @@ -33,7 +33,11 @@ public: typedef std::string::iterator mutable_iterator; typedef char value_type; typedef std::string::size_type size_type; - static const size_type npos; + static size_type npos() + { + return std::string::npos; + } + template static silly_string construct(InputIterator from, InputIterator to)