more wchar_t exclusion hackery

This commit is contained in:
jez_higgins 2003-09-09 13:09:48 +00:00
parent 56408bdce2
commit ad5c42953c
22 changed files with 87 additions and 61 deletions

View file

@ -4,8 +4,12 @@
# High level rules # High level rules
all : all : SAX, examples
SAX: dummy
cd SAX; ${MAKE} cd SAX; ${MAKE}
examples: dummy
cd examples; ${MAKE} cd examples; ${MAKE}
# Cleaning up # Cleaning up
@ -25,7 +29,7 @@ tar: clean
zip: clean zip: clean
cd ..; zip -rv9 arabica/arabica.zip arabica -x arabica/arabica.tar.gz -x \*/CVS/\* cd ..; zip -rv9 arabica/arabica.zip arabica -x arabica/arabica.tar.gz -x \*/CVS/\*
dummy:
#///////////////////////////////////////////////////////////////////////// #/////////////////////////////////////////////////////////////////////////
#////////////////////////////////////////////// #//////////////////////////////////////////////

View file

@ -19,6 +19,16 @@ define ARABICA_CONFIG_H
define pasty(ARABICA, _NO_WCHAR_T) 1 define pasty(ARABICA, _NO_WCHAR_T) 1
#endif #endif
#ifdef _MSC_VER
#if (_MSC_VER < 1300)
define ARABICA_VS6_WORKAROUND
#endif
#endif
#ifdef _WIN32
define ARABICA_WINDOWS
#endif
endif // ARABICA_CONFIG_H endif // ARABICA_CONFIG_H

View file

@ -409,6 +409,16 @@
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<File
RelativePath="ArabicaConfig.S">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"
CommandLine="cl /TC /EP ArabicaConfig.S &gt; ArabicaConfig.h"
Outputs="ArabicaConfig.h"/>
</FileConfiguration>
</File>
<File <File
RelativePath=".\ParserConfig.S"> RelativePath=".\ParserConfig.S">
<FileConfiguration <FileConfiguration

View file

@ -294,7 +294,7 @@ bool basic_Writer<string_type>::isDtd(const string_type& name)
name[4] == UnicodeT::RIGHT_SQUARE_BRACKET); name[4] == UnicodeT::RIGHT_SQUARE_BRACKET);
} // isDtd } // isDtd
#if !(defined _MSC_VER) || !(_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
template<class string_type> template<class string_type>
std::auto_ptr<typename basic_Writer<string_type>::PropertyBase> basic_Writer<string_type>::doGetProperty(const string_type& name) std::auto_ptr<typename basic_Writer<string_type>::PropertyBase> basic_Writer<string_type>::doGetProperty(const string_type& name)
#else #else
@ -312,7 +312,7 @@ std::auto_ptr<basic_Writer<string_type>::PropertyBase> basic_Writer<string_type>
return XMLFilterT::doGetProperty(name); return XMLFilterT::doGetProperty(name);
} // doGetProperty } // doGetProperty
#if !(defined _MSC_VER) || !(_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
template<class string_type> template<class string_type>
void basic_Writer<string_type>::doSetProperty(const string_type& name, std::auto_ptr<typename basic_Writer<string_type>::PropertyBase> value) void basic_Writer<string_type>::doSetProperty(const string_type& name, std::auto_ptr<typename basic_Writer<string_type>::PropertyBase> value)
#else #else

View file

@ -115,7 +115,7 @@ namespace
std::istream* httpResolver(const std::string& httpURL) std::istream* httpResolver(const std::string& httpURL)
{ {
#ifdef _MSC_VER #ifdef ARABICA_WINDOWS
WORD wVersionRequested; WORD wVersionRequested;
WSADATA wsaData; WSADATA wsaData;
int err; int err;

View file

@ -23,22 +23,22 @@ public:
value_type makeValueT(char c) const; value_type makeValueT(char c) const;
stringT makeStringT(const char* str) const; stringT makeStringT(const char* str) const;
stringT makeStringT(const char* str, int length) 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) const;
stringT makeStringT(const wchar_t* str, int length) const; stringT makeStringT(const wchar_t* str, int length) const;
#endif
// only used to constuct error strings - don't have to be highly efficient! // only used to constuct error strings - don't have to be highly efficient!
std::string asStdString(const stringT& str) const; std::string asStdString(const stringT& str) const;
#ifndef ARABICA_NO_WCHAR_T
std::wstring asStdWString(const stringT& str) const; std::wstring asStdWString(const stringT& str) const;
#endif
}; // class default_string_maker }; // class default_string_maker
// specialize for std::string and std::wstring // specialize for std::string and std::wstring
template<> template<>
class default_string_adaptor<std::string> class default_string_adaptor<std::string>
{ {
typedef basic_iconvertstream<wchar_t, std::char_traits<wchar_t>,
char, std::char_traits<char> > widener;
typedef basic_oconvertstream<wchar_t, std::char_traits<wchar_t>,
char, std::char_traits<char> > narrower;
public: public:
char makeValueT(char c) const { return c; } char makeValueT(char c) const { return c; }
@ -50,6 +50,17 @@ public:
{ {
return std::string(str, length); return std::string(str, length);
} // makeStringT } // makeStringT
const std::string& asStdString(const std::string& str) const
{
return str;
} // toStdString
#ifndef ARABICA_NO_WCHAR_T
typedef basic_iconvertstream<wchar_t, std::char_traits<wchar_t>,
char, std::char_traits<char> > widener;
typedef basic_oconvertstream<wchar_t, std::char_traits<wchar_t>,
char, std::char_traits<char> > narrower;
std::string makeStringT(const wchar_t* str) const std::string makeStringT(const wchar_t* str) const
{ {
std::wstring s; std::wstring s;
@ -63,19 +74,16 @@ public:
n_.str(std::wstring(str, length)); n_.str(std::wstring(str, length));
return n_.str(); return n_.str();
} // makeStringT } // makeStringT
const std::string& asStdString(const std::string& str) const
{
return str;
} // toStdString
std::wstring asStdWString(const std::string& str) const std::wstring asStdWString(const std::string& str) const
{ {
w_.str(str); w_.str(str);
return w_.str(); return w_.str();
} // toStdWString } // toStdWString
#endif
#ifndef ARABICA_NO_WCHAR_T
default_string_adaptor() : default_string_adaptor() :
#if !(defined _MSC_VER) || !(_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
loc_(std::locale(), new utf8ucs2codecvt()), loc_(std::locale(), new utf8ucs2codecvt()),
#else #else
loc_(std::_Addfac(std::locale(), new utf8ucs2codecvt)), loc_(std::_Addfac(std::locale(), new utf8ucs2codecvt)),
@ -91,8 +99,12 @@ private:
std::locale loc_; std::locale loc_;
mutable narrower n_; mutable narrower n_;
mutable widener w_; mutable widener w_;
#else
default_string_adaptor() { }
#endif
}; // class default_string_adaptor }; // class default_string_adaptor
#ifndef ARABICA_NO_WCHAR_T
template<> template<>
class default_string_adaptor<std::wstring> class default_string_adaptor<std::wstring>
{ {
@ -139,7 +151,7 @@ public:
} // toStdWString } // toStdWString
default_string_adaptor() : default_string_adaptor() :
#if !(defined _MSC_VER) || !(_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
loc_(std::locale(), new utf8ucs2codecvt()), loc_(std::locale(), new utf8ucs2codecvt()),
#else #else
loc_(std::_Addfac(std::locale(), new utf8ucs2codecvt())), loc_(std::_Addfac(std::locale(), new utf8ucs2codecvt())),
@ -156,6 +168,7 @@ private:
mutable narrower n_; mutable narrower n_;
mutable widener w_; mutable widener w_;
}; // class default_string_adaptor }; // class default_string_adaptor
#endif // ARABICA_NO_WCHAR_T
} // namespace SAX } // namespace SAX

View file

@ -26,6 +26,7 @@ public:
typedef basic_ContentHandler<stringT> ContentHandlerT; typedef basic_ContentHandler<stringT> ContentHandlerT;
typedef basic_InputSource<stringT> InputSourceT; typedef basic_InputSource<stringT> InputSourceT;
typedef basic_AttributesImpl<stringT> AttributesImplT; typedef basic_AttributesImpl<stringT> AttributesImplT;
typedef typename basic_XMLReader<stringT>::PropertyBase PropertyBase;
Garden(); Garden();
@ -52,9 +53,9 @@ public:
private: private:
void reportError(const std::string& message, bool fatal = false); 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<char_t> vector_t; typedef std::vector<char_t> vector_t;
typedef vector_t::iterator iterator_t; typedef typename vector_t::iterator iterator_t;
typedef boost::spirit::scanner<iterator_t> scanner_t; typedef boost::spirit::scanner<iterator_t> scanner_t;
typedef boost::spirit::rule<scanner_t> rule_t; typedef boost::spirit::rule<scanner_t> rule_t;
@ -95,7 +96,8 @@ private:
std::stack<stringT> elements_; std::stack<stringT> elements_;
AttributesImplT attrs_; AttributesImplT attrs_;
AttributesImplT::Attr currentAttr_; typedef typename AttributesImplT::Attr Attr;
Attr currentAttr_;
stringT piTarget_; stringT piTarget_;
stringT piData_; stringT piData_;
stringT entityRef_; stringT entityRef_;
@ -231,7 +233,7 @@ void Garden<string_type>::setFeature(const stringT& name, bool value)
/////////////////////////////////////// ///////////////////////////////////////
// properties // properties
template<class string_type> template<class string_type>
std::auto_ptr<Garden<string_type>::PropertyBase> Garden<string_type>::doGetProperty(const stringT& name) std::auto_ptr<typename Garden<string_type>::PropertyBase> Garden<string_type>::doGetProperty(const stringT& name)
{ {
throw SAXNotRecognizedException(name); throw SAXNotRecognizedException(name);
} // doGetProperty } // doGetProperty
@ -266,7 +268,7 @@ void Garden<string_type>::parse(InputSourceT& input)
if(contentHandler_) if(contentHandler_)
contentHandler_->startDocument(); contentHandler_->startDocument();
rule_t::result_t r = document_.parse(scanner); typename rule_t::result_t r = document_.parse(scanner);
if(contentHandler_) if(contentHandler_)
contentHandler_->endDocument(); contentHandler_->endDocument();

View file

@ -759,7 +759,7 @@ SAX::basic_EntityResolver<stringT>* xerces_wrapper<stringT, string_adaptorT>::ge
return 0; return 0;
} // getEntityResolver } // getEntityResolver
#if (defined _MSC_VER) && (_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
#define typename #define typename
#endif #endif
template<class stringT, class string_adaptorT> template<class stringT, class string_adaptorT>
@ -804,7 +804,7 @@ void xerces_wrapper<stringT, string_adaptorT>::doSetProperty(const stringT& name
throw SAX::SAXNotRecognizedException("Property not recognized "); throw SAX::SAXNotRecognizedException("Property not recognized ");
} // doSetProperty } // doSetProperty
#if (defined _MSC_VER) && (_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
#undef typename #undef typename
#endif #endif

View file

@ -202,3 +202,4 @@ void base64codecvt::consumeOutChar() const
} // consumeOutChar } // consumeOutChar
// end of file // end of file

View file

@ -12,7 +12,6 @@
// decryption (or any other transcoding) transparently. It can // decryption (or any other transcoding) transparently. It can
// also adapt wchar_t streams to char streams, or vice versa, allowing // 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. // you to write std::wstrings out as UTF-8 chars to a file, for instance.
//
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
#include <locale> #include <locale>
#include <istream> #include <istream>
@ -20,7 +19,7 @@
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#if defined(_MSC_VER) && (_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
#include <minmax.h> #include <minmax.h>
#endif #endif
@ -137,7 +136,7 @@ bool convert_bufadaptor<charT, traitsT, externalCharT, externalTraitsT>::flushOu
bool ok(true); bool ok(true);
const std::codecvt<charT, char, state_t>& cvt = const std::codecvt<charT, char, state_t>& cvt =
#if !defined(_MSC_VER) || (_MSC_VER > 1300) #ifndef ARABICA_VS6_WORKAROUND
std::use_facet<std::codecvt<charT, char, typename traitsT::state_type> >(this->getloc()); std::use_facet<std::codecvt<charT, char, typename traitsT::state_type> >(this->getloc());
#else #else
std::use_facet(this->getloc(), (std::codecvt<charT, char, typename traitsT::state_type>*)0, true); std::use_facet(this->getloc(), (std::codecvt<charT, char, typename traitsT::state_type>*)0, true);
@ -183,7 +182,7 @@ std::streamsize convert_bufadaptor<charT, traitsT, externalCharT, externalTraits
if(!inBuffer_.capacity()) if(!inBuffer_.capacity())
growInBuffer(); growInBuffer();
#if !defined(_MSC_VER) || (_MSC_VER > 1300) #ifndef ARABICA_VS6_WORKAROUND
size_t pbCount = std::min<size_t>(gptr() - eback(), pbSize_); size_t pbCount = std::min<size_t>(gptr() - eback(), pbSize_);
#else #else
size_t pbCount = min(gptr() - eback(), pbSize_); size_t pbCount = min(gptr() - eback(), pbSize_);
@ -193,7 +192,7 @@ std::streamsize convert_bufadaptor<charT, traitsT, externalCharT, externalTraits
pbCount*sizeof(charT)); pbCount*sizeof(charT));
const std::codecvt<charT, char, state_t>& cvt = const std::codecvt<charT, char, state_t>& cvt =
#if !defined(_MSC_VER) || (_MSC_VER > 1300) #ifndef ARABICA_VS6_WORKAROUND
std::use_facet<std::codecvt<charT, char, typename traitsT::state_type> >(this->getloc()); std::use_facet<std::codecvt<charT, char, typename traitsT::state_type> >(this->getloc());
#else #else
std::use_facet(this->getloc(), (std::codecvt<charT, char, typename traitsT::state_type>*)0, true); std::use_facet(this->getloc(), (std::codecvt<charT, char, typename traitsT::state_type>*)0, true);

View file

@ -42,6 +42,7 @@
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SAX/ArabicaConfig.h>
#include <locale> #include <locale>
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
@ -84,7 +85,7 @@ public:
void str(const fromStringT& str) void str(const fromStringT& str)
{ {
// do conversion // do conversion
#if !(defined _MSC_VER) || !(_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
const std::codecvt<charT, fromCharT, typename traitsT::state_type>& cvt = const std::codecvt<charT, fromCharT, typename traitsT::state_type>& cvt =
std::use_facet<std::codecvt<charT, fromCharT, typename traitsT::state_type> >(this->getloc()); std::use_facet<std::codecvt<charT, fromCharT, typename traitsT::state_type> >(this->getloc());
#else #else
@ -130,7 +131,7 @@ private:
stringT no_conversion(const fromStringT& str) stringT no_conversion(const fromStringT& str)
{ {
stringT dest; stringT dest;
#if !(defined _MSC_VER) || !(_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
std::copy(str.begin(), str.end(), std::back_inserter(dest)); std::copy(str.begin(), str.end(), std::back_inserter(dest));
#else #else
// hack around pre-Standard library // hack around pre-Standard library
@ -181,7 +182,7 @@ public:
return out; return out;
// convert it here // convert it here
#if !(defined _MSC_VER) || !(_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
const std::codecvt<charT, toCharT, typename traitsT::state_type>& cvt = const std::codecvt<charT, toCharT, typename traitsT::state_type>& cvt =
std::use_facet<std::codecvt<charT, toCharT, typename traitsT::state_type> >(this->getloc()); std::use_facet<std::codecvt<charT, toCharT, typename traitsT::state_type> >(this->getloc());
#else #else
@ -232,7 +233,7 @@ private:
toStringT no_conversion(const stringT& str) toStringT no_conversion(const stringT& str)
{ {
toStringT dest; toStringT dest;
#if !(defined _MSC_VER) || !(_MSC_VER < 1300) #ifndef ARABICA_VS6_WORKAROUND
std::copy(str.begin(), str.end(), std::back_inserter(dest)); std::copy(str.begin(), str.end(), std::back_inserter(dest));
#else #else
for(typename stringT::const_iterator i = str.begin(); i != str.end(); ++i) for(typename stringT::const_iterator i = str.begin(); i != str.end(); ++i)
@ -245,8 +246,10 @@ private:
}; // basic_oconvertstream }; // basic_oconvertstream
typedef basic_iconvertstream<char> converting_istringstream; typedef basic_iconvertstream<char> converting_istringstream;
typedef basic_iconvertstream<wchar_t> converting_iwstringstream;
typedef basic_oconvertstream<char> converting_ostringstream; typedef basic_oconvertstream<char> converting_ostringstream;
#ifndef ARABICA_NO_WCHAR_T
typedef basic_iconvertstream<wchar_t> converting_iwstringstream;
typedef basic_oconvertstream<wchar_t> converting_owstringstream; typedef basic_oconvertstream<wchar_t> converting_owstringstream;
#endif
#endif #endif

View file

@ -13,5 +13,3 @@ std::codecvt_base::result utf8_2_iso88591(const char* from, const char* from_end
} // namespace ArabicaInternal } // namespace ArabicaInternal
#endif #endif

View file

@ -58,23 +58,3 @@ int iso88591utf8codecvt::do_length(const std::mbstate_t&,
} // do_length } // do_length
// end of file // end of file

View file

@ -42,3 +42,4 @@ int rot13codecvt::do_length(const state_t&,
} // do_length } // do_length
// end of file // end of file

View file

@ -11,7 +11,7 @@
// $Id$ // $Id$
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
#ifndef _MSC_VER #ifndef ARABICA_WINDOWS
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>

View file

@ -45,3 +45,4 @@ int utf16beucs2codecvt::do_length(const std::mbstate_t&,
} // do_length } // do_length
// end of file // end of file

View file

@ -45,3 +45,4 @@ int utf16leucs2codecvt::do_length(const std::mbstate_t&,
} // do_length } // do_length
// end of file // end of file

View file

@ -61,3 +61,4 @@ int utf16utf8codecvt::do_length(const std::mbstate_t&,
} // do_length } // do_length
// end of file // end of file

View file

@ -78,3 +78,4 @@ int utf8iso88591codecvt::do_length(const std::mbstate_t&,
} // do_length } // do_length
// end of file // end of file

View file

@ -77,3 +77,4 @@ int utf8ucs2codecvt::do_length(const std::mbstate_t&,
} // do_length } // do_length
// end of file // end of file

View file

@ -41,7 +41,7 @@ int main(int argc, char* argv[])
} // for ... } // for ...
} }
/*
{ // wide { // wide
SAX::XMLReader<std::wstring> parser; SAX::XMLReader<std::wstring> parser;
SAX::wWriter writer(std::wcout); SAX::wWriter writer(std::wcout);
@ -53,7 +53,7 @@ int main(int argc, char* argv[])
writer.parse(is); writer.parse(is);
} }
*/
return 0; return 0;
} // main } // main

View file

@ -40,7 +40,7 @@ CCDEPFLAGS = -E -M
# Uncomment for optimisations # Uncomment for optimisations
CXXFLAGS += -O2 CXXFLAGS += -O2
LDFLAGS += -O2 LDFLAGS += -O2 -L../../bin
# Uncomment for debug version # Uncomment for debug version
CXXFLAGS += -g CXXFLAGS += -g
@ -53,7 +53,7 @@ INCS_DIRS = -I../..
LIBS_DIRS = -L../../bin LIBS_DIRS = -L../../bin
STATIC_LIBS = STATIC_LIBS =
DYNAMIC_LIBS = -lArabica -lexpat DYNAMIC_LIBS = -lArabica -lstdc++
CXXFLAGS += ${INCS_DIRS} CXXFLAGS += ${INCS_DIRS}
LDFLAGS += ${LIBS_DIRS} LDFLAGS += ${LIBS_DIRS}