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
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:
#/////////////////////////////////////////////////////////////////////////
#//////////////////////////////////////////////

View file

@ -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

View file

@ -409,6 +409,16 @@
</File>
</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
RelativePath=".\ParserConfig.S">
<FileConfiguration

View file

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

View file

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

View file

@ -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<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:
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<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::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<std::wstring>
{
@ -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

View file

@ -26,6 +26,7 @@ public:
typedef basic_ContentHandler<stringT> ContentHandlerT;
typedef basic_InputSource<stringT> InputSourceT;
typedef basic_AttributesImpl<stringT> AttributesImplT;
typedef typename basic_XMLReader<stringT>::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<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::rule<scanner_t> rule_t;
@ -95,7 +96,8 @@ private:
std::stack<stringT> 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<string_type>::setFeature(const stringT& name, bool value)
///////////////////////////////////////
// properties
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);
} // doGetProperty
@ -266,7 +268,7 @@ void Garden<string_type>::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();

View file

@ -759,7 +759,7 @@ SAX::basic_EntityResolver<stringT>* xerces_wrapper<stringT, string_adaptorT>::ge
return 0;
} // getEntityResolver
#if (defined _MSC_VER) && (_MSC_VER < 1300)
#ifndef ARABICA_VS6_WORKAROUND
#define typename
#endif
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 ");
} // doSetProperty
#if (defined _MSC_VER) && (_MSC_VER < 1300)
#ifndef ARABICA_VS6_WORKAROUND
#undef typename
#endif

View file

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

View file

@ -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 <locale>
#include <istream>
@ -20,7 +19,7 @@
#include <vector>
#include <algorithm>
#if defined(_MSC_VER) && (_MSC_VER < 1300)
#ifndef ARABICA_VS6_WORKAROUND
#include <minmax.h>
#endif
@ -137,7 +136,7 @@ bool convert_bufadaptor<charT, traitsT, externalCharT, externalTraitsT>::flushOu
bool ok(true);
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());
#else
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())
growInBuffer();
#if !defined(_MSC_VER) || (_MSC_VER > 1300)
#ifndef ARABICA_VS6_WORKAROUND
size_t pbCount = std::min<size_t>(gptr() - eback(), pbSize_);
#else
size_t pbCount = min(gptr() - eback(), pbSize_);
@ -193,8 +192,8 @@ std::streamsize convert_bufadaptor<charT, traitsT, externalCharT, externalTraits
pbCount*sizeof(charT));
const std::codecvt<charT, char, state_t>& cvt =
#if !defined(_MSC_VER) || (_MSC_VER > 1300)
std::use_facet<std::codecvt<charT, char, typename traitsT::state_type> >(this->getloc());
#ifndef ARABICA_VS6_WORKAROUND
std::use_facet<std::codecvt<charT, char, typename traitsT::state_type> >(this->getloc());
#else
std::use_facet(this->getloc(), (std::codecvt<charT, char, typename traitsT::state_type>*)0, true);
#endif

View file

@ -42,6 +42,7 @@
//
////////////////////////////////////////////////////////////
#include <SAX/ArabicaConfig.h>
#include <locale>
#include <sstream>
#include <algorithm>
@ -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<charT, fromCharT, typename traitsT::state_type>& cvt =
std::use_facet<std::codecvt<charT, fromCharT, typename traitsT::state_type> >(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<charT, toCharT, typename traitsT::state_type>& cvt =
std::use_facet<std::codecvt<charT, toCharT, typename traitsT::state_type> >(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<char> converting_istringstream;
typedef basic_iconvertstream<wchar_t> converting_iwstringstream;
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;
#endif
#endif

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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}