From ad5c42953cfdc55ebf46c0291b2bf17f525e16a1 Mon Sep 17 00:00:00 2001
From: jez_higgins <>
Date: Tue, 9 Sep 2003 13:09:48 +0000
Subject: [PATCH] more wchar_t exclusion hackery
---
Makefile | 8 +++++--
SAX/ArabicaConfig.S | 10 +++++++++
SAX/SAX.vcproj | 10 +++++++++
SAX/filter/Writer.h | 4 ++--
SAX/helpers/InputSourceResolver.cpp | 2 +-
SAX/helpers/StringAdaptor.h | 35 ++++++++++++++++++++---------
SAX/parsers/saxgarden.h | 12 +++++-----
SAX/wrappers/saxxerces.h | 4 ++--
Utils/base64codecvt.cpp | 1 +
Utils/convert_adaptor.h | 11 +++++----
Utils/convertstream.h | 13 ++++++-----
Utils/impl/iso88591_utf8.h | 2 --
Utils/iso88591utf8codecvt.cpp | 20 -----------------
Utils/rot13codecvt.cpp | 1 +
Utils/socket_stream.h | 2 +-
Utils/utf16beucs2codecvt.cpp | 1 +
Utils/utf16leucs2codecvt.cpp | 1 +
Utils/utf16utf8codecvt.cpp | 1 +
Utils/utf8iso88591codecvt.cpp | 1 +
Utils/utf8ucs2codecvt.cpp | 1 +
examples/SAX/writer.cpp | 4 ++--
examples/SAX2DOM/Makefile | 4 ++--
22 files changed, 87 insertions(+), 61 deletions(-)
diff --git a/Makefile b/Makefile
index 7375496b..8dab9240 100644
--- a/Makefile
+++ b/Makefile
@@ -4,8 +4,12 @@
# High level rules
-all :
+all : SAX, examples
+
+SAX: dummy
cd SAX; ${MAKE}
+
+examples: dummy
cd examples; ${MAKE}
# Cleaning up
@@ -25,7 +29,7 @@ tar: clean
zip: clean
cd ..; zip -rv9 arabica/arabica.zip arabica -x arabica/arabica.tar.gz -x \*/CVS/\*
-
+dummy:
#/////////////////////////////////////////////////////////////////////////
#//////////////////////////////////////////////
diff --git a/SAX/ArabicaConfig.S b/SAX/ArabicaConfig.S
index cba22972..52d9dacb 100644
--- a/SAX/ArabicaConfig.S
+++ b/SAX/ArabicaConfig.S
@@ -19,6 +19,16 @@ define ARABICA_CONFIG_H
define pasty(ARABICA, _NO_WCHAR_T) 1
#endif
+#ifdef _MSC_VER
+#if (_MSC_VER < 1300)
+define ARABICA_VS6_WORKAROUND
+#endif
+#endif
+
+#ifdef _WIN32
+define ARABICA_WINDOWS
+#endif
+
endif // ARABICA_CONFIG_H
diff --git a/SAX/SAX.vcproj b/SAX/SAX.vcproj
index 58a3cf32..37981856 100644
--- a/SAX/SAX.vcproj
+++ b/SAX/SAX.vcproj
@@ -409,6 +409,16 @@
+
+
+
+
+
::isDtd(const string_type& name)
name[4] == UnicodeT::RIGHT_SQUARE_BRACKET);
} // isDtd
-#if !(defined _MSC_VER) || !(_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
template
std::auto_ptr::PropertyBase> basic_Writer::doGetProperty(const string_type& name)
#else
@@ -312,7 +312,7 @@ std::auto_ptr::PropertyBase> basic_Writer
return XMLFilterT::doGetProperty(name);
} // doGetProperty
-#if !(defined _MSC_VER) || !(_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
template
void basic_Writer::doSetProperty(const string_type& name, std::auto_ptr::PropertyBase> value)
#else
diff --git a/SAX/helpers/InputSourceResolver.cpp b/SAX/helpers/InputSourceResolver.cpp
index 979f9619..d9a4d5b9 100644
--- a/SAX/helpers/InputSourceResolver.cpp
+++ b/SAX/helpers/InputSourceResolver.cpp
@@ -115,7 +115,7 @@ namespace
std::istream* httpResolver(const std::string& httpURL)
{
-#ifdef _MSC_VER
+#ifdef ARABICA_WINDOWS
WORD wVersionRequested;
WSADATA wsaData;
int err;
diff --git a/SAX/helpers/StringAdaptor.h b/SAX/helpers/StringAdaptor.h
index a4bd9369..0dfa5d70 100644
--- a/SAX/helpers/StringAdaptor.h
+++ b/SAX/helpers/StringAdaptor.h
@@ -23,22 +23,22 @@ public:
value_type makeValueT(char c) const;
stringT makeStringT(const char* str) const;
stringT makeStringT(const char* str, int length) const;
+#ifndef ARABICA_NO_WCHAR_T
stringT makeStringT(const wchar_t* str) const;
stringT makeStringT(const wchar_t* str, int length) const;
+#endif
// only used to constuct error strings - don't have to be highly efficient!
std::string asStdString(const stringT& str) const;
+#ifndef ARABICA_NO_WCHAR_T
std::wstring asStdWString(const stringT& str) const;
+#endif
}; // class default_string_maker
// specialize for std::string and std::wstring
template<>
class default_string_adaptor
{
- typedef basic_iconvertstream,
- char, std::char_traits > widener;
- typedef basic_oconvertstream,
- char, std::char_traits > narrower;
public:
char makeValueT(char c) const { return c; }
@@ -50,6 +50,17 @@ public:
{
return std::string(str, length);
} // makeStringT
+ const std::string& asStdString(const std::string& str) const
+ {
+ return str;
+ } // toStdString
+
+#ifndef ARABICA_NO_WCHAR_T
+ typedef basic_iconvertstream,
+ char, std::char_traits > widener;
+ typedef basic_oconvertstream,
+ char, std::char_traits > narrower;
+
std::string makeStringT(const wchar_t* str) const
{
std::wstring s;
@@ -63,19 +74,16 @@ public:
n_.str(std::wstring(str, length));
return n_.str();
} // makeStringT
-
- const std::string& asStdString(const std::string& str) const
- {
- return str;
- } // toStdString
std::wstring asStdWString(const std::string& str) const
{
w_.str(str);
return w_.str();
} // toStdWString
+#endif
+#ifndef ARABICA_NO_WCHAR_T
default_string_adaptor() :
-#if !(defined _MSC_VER) || !(_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
loc_(std::locale(), new utf8ucs2codecvt()),
#else
loc_(std::_Addfac(std::locale(), new utf8ucs2codecvt)),
@@ -91,8 +99,12 @@ private:
std::locale loc_;
mutable narrower n_;
mutable widener w_;
+#else
+ default_string_adaptor() { }
+#endif
}; // class default_string_adaptor
+#ifndef ARABICA_NO_WCHAR_T
template<>
class default_string_adaptor
{
@@ -139,7 +151,7 @@ public:
} // toStdWString
default_string_adaptor() :
-#if !(defined _MSC_VER) || !(_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
loc_(std::locale(), new utf8ucs2codecvt()),
#else
loc_(std::_Addfac(std::locale(), new utf8ucs2codecvt())),
@@ -156,6 +168,7 @@ private:
mutable narrower n_;
mutable widener w_;
}; // class default_string_adaptor
+#endif // ARABICA_NO_WCHAR_T
} // namespace SAX
diff --git a/SAX/parsers/saxgarden.h b/SAX/parsers/saxgarden.h
index 9281ccad..9ce54efc 100644
--- a/SAX/parsers/saxgarden.h
+++ b/SAX/parsers/saxgarden.h
@@ -26,6 +26,7 @@ public:
typedef basic_ContentHandler ContentHandlerT;
typedef basic_InputSource InputSourceT;
typedef basic_AttributesImpl AttributesImplT;
+ typedef typename basic_XMLReader::PropertyBase PropertyBase;
Garden();
@@ -52,9 +53,9 @@ public:
private:
void reportError(const std::string& message, bool fatal = false);
- typedef stringT::value_type char_t;
+ typedef typename stringT::value_type char_t;
typedef std::vector vector_t;
- typedef vector_t::iterator iterator_t;
+ typedef typename vector_t::iterator iterator_t;
typedef boost::spirit::scanner scanner_t;
typedef boost::spirit::rule rule_t;
@@ -95,7 +96,8 @@ private:
std::stack elements_;
AttributesImplT attrs_;
- AttributesImplT::Attr currentAttr_;
+ typedef typename AttributesImplT::Attr Attr;
+ Attr currentAttr_;
stringT piTarget_;
stringT piData_;
stringT entityRef_;
@@ -231,7 +233,7 @@ void Garden::setFeature(const stringT& name, bool value)
///////////////////////////////////////
// properties
template
-std::auto_ptr::PropertyBase> Garden::doGetProperty(const stringT& name)
+std::auto_ptr::PropertyBase> Garden::doGetProperty(const stringT& name)
{
throw SAXNotRecognizedException(name);
} // doGetProperty
@@ -266,7 +268,7 @@ void Garden::parse(InputSourceT& input)
if(contentHandler_)
contentHandler_->startDocument();
- rule_t::result_t r = document_.parse(scanner);
+ typename rule_t::result_t r = document_.parse(scanner);
if(contentHandler_)
contentHandler_->endDocument();
diff --git a/SAX/wrappers/saxxerces.h b/SAX/wrappers/saxxerces.h
index 24a23f66..878aa605 100644
--- a/SAX/wrappers/saxxerces.h
+++ b/SAX/wrappers/saxxerces.h
@@ -759,7 +759,7 @@ SAX::basic_EntityResolver* xerces_wrapper::ge
return 0;
} // getEntityResolver
-#if (defined _MSC_VER) && (_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
#define typename
#endif
template
@@ -804,7 +804,7 @@ void xerces_wrapper::doSetProperty(const stringT& name
throw SAX::SAXNotRecognizedException("Property not recognized ");
} // doSetProperty
-#if (defined _MSC_VER) && (_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
#undef typename
#endif
diff --git a/Utils/base64codecvt.cpp b/Utils/base64codecvt.cpp
index ad55233c..b4577d0c 100644
--- a/Utils/base64codecvt.cpp
+++ b/Utils/base64codecvt.cpp
@@ -202,3 +202,4 @@ void base64codecvt::consumeOutChar() const
} // consumeOutChar
// end of file
+
diff --git a/Utils/convert_adaptor.h b/Utils/convert_adaptor.h
index a075b3ee..dd006b75 100644
--- a/Utils/convert_adaptor.h
+++ b/Utils/convert_adaptor.h
@@ -12,7 +12,6 @@
// decryption (or any other transcoding) transparently. It can
// also adapt wchar_t streams to char streams, or vice versa, allowing
// you to write std::wstrings out as UTF-8 chars to a file, for instance.
-//
//////////////////////////////////////////////////////
#include
#include
@@ -20,7 +19,7 @@
#include
#include
-#if defined(_MSC_VER) && (_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
#include
#endif
@@ -137,7 +136,7 @@ bool convert_bufadaptor::flushOu
bool ok(true);
const std::codecvt& cvt =
-#if !defined(_MSC_VER) || (_MSC_VER > 1300)
+#ifndef ARABICA_VS6_WORKAROUND
std::use_facet >(this->getloc());
#else
std::use_facet(this->getloc(), (std::codecvt*)0, true);
@@ -183,7 +182,7 @@ std::streamsize convert_bufadaptor 1300)
+#ifndef ARABICA_VS6_WORKAROUND
size_t pbCount = std::min(gptr() - eback(), pbSize_);
#else
size_t pbCount = min(gptr() - eback(), pbSize_);
@@ -193,8 +192,8 @@ std::streamsize convert_bufadaptor& cvt =
-#if !defined(_MSC_VER) || (_MSC_VER > 1300)
- std::use_facet >(this->getloc());
+#ifndef ARABICA_VS6_WORKAROUND
+ std::use_facet >(this->getloc());
#else
std::use_facet(this->getloc(), (std::codecvt*)0, true);
#endif
diff --git a/Utils/convertstream.h b/Utils/convertstream.h
index d0f1efcf..3479e7ae 100644
--- a/Utils/convertstream.h
+++ b/Utils/convertstream.h
@@ -42,6 +42,7 @@
//
////////////////////////////////////////////////////////////
+#include
#include
#include
#include
@@ -84,7 +85,7 @@ public:
void str(const fromStringT& str)
{
// do conversion
-#if !(defined _MSC_VER) || !(_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
const std::codecvt& cvt =
std::use_facet >(this->getloc());
#else
@@ -130,7 +131,7 @@ private:
stringT no_conversion(const fromStringT& str)
{
stringT dest;
-#if !(defined _MSC_VER) || !(_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
std::copy(str.begin(), str.end(), std::back_inserter(dest));
#else
// hack around pre-Standard library
@@ -181,7 +182,7 @@ public:
return out;
// convert it here
-#if !(defined _MSC_VER) || !(_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
const std::codecvt& cvt =
std::use_facet >(this->getloc());
#else
@@ -232,7 +233,7 @@ private:
toStringT no_conversion(const stringT& str)
{
toStringT dest;
-#if !(defined _MSC_VER) || !(_MSC_VER < 1300)
+#ifndef ARABICA_VS6_WORKAROUND
std::copy(str.begin(), str.end(), std::back_inserter(dest));
#else
for(typename stringT::const_iterator i = str.begin(); i != str.end(); ++i)
@@ -245,8 +246,10 @@ private:
}; // basic_oconvertstream
typedef basic_iconvertstream converting_istringstream;
-typedef basic_iconvertstream converting_iwstringstream;
typedef basic_oconvertstream converting_ostringstream;
+#ifndef ARABICA_NO_WCHAR_T
+typedef basic_iconvertstream converting_iwstringstream;
typedef basic_oconvertstream converting_owstringstream;
+#endif
#endif
diff --git a/Utils/impl/iso88591_utf8.h b/Utils/impl/iso88591_utf8.h
index 3a8ffae1..a92f3680 100644
--- a/Utils/impl/iso88591_utf8.h
+++ b/Utils/impl/iso88591_utf8.h
@@ -13,5 +13,3 @@ std::codecvt_base::result utf8_2_iso88591(const char* from, const char* from_end
} // namespace ArabicaInternal
#endif
-
-
diff --git a/Utils/iso88591utf8codecvt.cpp b/Utils/iso88591utf8codecvt.cpp
index 356664de..bcc9ff18 100644
--- a/Utils/iso88591utf8codecvt.cpp
+++ b/Utils/iso88591utf8codecvt.cpp
@@ -58,23 +58,3 @@ int iso88591utf8codecvt::do_length(const std::mbstate_t&,
} // do_length
// end of file
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Utils/rot13codecvt.cpp b/Utils/rot13codecvt.cpp
index bdb3df0b..e2adeef6 100644
--- a/Utils/rot13codecvt.cpp
+++ b/Utils/rot13codecvt.cpp
@@ -42,3 +42,4 @@ int rot13codecvt::do_length(const state_t&,
} // do_length
// end of file
+
diff --git a/Utils/socket_stream.h b/Utils/socket_stream.h
index 021a6424..2e0e36f1 100644
--- a/Utils/socket_stream.h
+++ b/Utils/socket_stream.h
@@ -11,7 +11,7 @@
// $Id$
///////////////////////////////////////////////////////////////////////
-#ifndef _MSC_VER
+#ifndef ARABICA_WINDOWS
#include
#include
#include
diff --git a/Utils/utf16beucs2codecvt.cpp b/Utils/utf16beucs2codecvt.cpp
index 40e412a9..cbf23085 100644
--- a/Utils/utf16beucs2codecvt.cpp
+++ b/Utils/utf16beucs2codecvt.cpp
@@ -45,3 +45,4 @@ int utf16beucs2codecvt::do_length(const std::mbstate_t&,
} // do_length
// end of file
+
diff --git a/Utils/utf16leucs2codecvt.cpp b/Utils/utf16leucs2codecvt.cpp
index 6d3ec139..3e9d341b 100644
--- a/Utils/utf16leucs2codecvt.cpp
+++ b/Utils/utf16leucs2codecvt.cpp
@@ -45,3 +45,4 @@ int utf16leucs2codecvt::do_length(const std::mbstate_t&,
} // do_length
// end of file
+
diff --git a/Utils/utf16utf8codecvt.cpp b/Utils/utf16utf8codecvt.cpp
index 082812f7..cdccd307 100644
--- a/Utils/utf16utf8codecvt.cpp
+++ b/Utils/utf16utf8codecvt.cpp
@@ -61,3 +61,4 @@ int utf16utf8codecvt::do_length(const std::mbstate_t&,
} // do_length
// end of file
+
diff --git a/Utils/utf8iso88591codecvt.cpp b/Utils/utf8iso88591codecvt.cpp
index a30e3b29..7be56655 100644
--- a/Utils/utf8iso88591codecvt.cpp
+++ b/Utils/utf8iso88591codecvt.cpp
@@ -78,3 +78,4 @@ int utf8iso88591codecvt::do_length(const std::mbstate_t&,
} // do_length
// end of file
+
diff --git a/Utils/utf8ucs2codecvt.cpp b/Utils/utf8ucs2codecvt.cpp
index af7dc503..a8dfeebe 100644
--- a/Utils/utf8ucs2codecvt.cpp
+++ b/Utils/utf8ucs2codecvt.cpp
@@ -77,3 +77,4 @@ int utf8ucs2codecvt::do_length(const std::mbstate_t&,
} // do_length
// end of file
+
diff --git a/examples/SAX/writer.cpp b/examples/SAX/writer.cpp
index d3c975ed..ecf2bebe 100644
--- a/examples/SAX/writer.cpp
+++ b/examples/SAX/writer.cpp
@@ -41,7 +41,7 @@ int main(int argc, char* argv[])
} // for ...
}
-/*
+
{ // wide
SAX::XMLReader parser;
SAX::wWriter writer(std::wcout);
@@ -53,7 +53,7 @@ int main(int argc, char* argv[])
writer.parse(is);
}
-*/
+
return 0;
} // main
diff --git a/examples/SAX2DOM/Makefile b/examples/SAX2DOM/Makefile
index cda6765b..4b53a2e4 100644
--- a/examples/SAX2DOM/Makefile
+++ b/examples/SAX2DOM/Makefile
@@ -40,7 +40,7 @@ CCDEPFLAGS = -E -M
# Uncomment for optimisations
CXXFLAGS += -O2
-LDFLAGS += -O2
+LDFLAGS += -O2 -L../../bin
# Uncomment for debug version
CXXFLAGS += -g
@@ -53,7 +53,7 @@ INCS_DIRS = -I../..
LIBS_DIRS = -L../../bin
STATIC_LIBS =
-DYNAMIC_LIBS = -lArabica -lexpat
+DYNAMIC_LIBS = -lArabica -lstdc++
CXXFLAGS += ${INCS_DIRS}
LDFLAGS += ${LIBS_DIRS}