Backing-out changes. Sorry, should have been on branch.

This commit is contained in:
pwalford 2002-10-08 04:37:14 +00:00
parent f4c48fb092
commit c3b07a86f6
16 changed files with 4 additions and 180 deletions

View file

@ -224,9 +224,7 @@ public:
}; // class Attributes
typedef basic_Attributes<std::string> Attributes;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_Attributes<std::wstring> wAttributes;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -331,9 +331,7 @@ public:
}; // class basic_ContentHandler
typedef basic_ContentHandler<std::string> ContentHandler;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_ContentHandler<std::wstring> wContentHandler;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -118,9 +118,7 @@ public:
}; // class basic_DTDHandler
typedef basic_DTDHandler<std::string> DTDHandler;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_DTDHandler<std::wstring> wDTDHandler;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -107,9 +107,7 @@ public:
}; // class EntityResolver
typedef basic_EntityResolver<std::string> EntityResolver;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_EntityResolver<std::wstring> wEntityResolver;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -302,9 +302,7 @@ void basic_InputSource<charT, traitsT, allocatorT>::setCharacterStream(charStrea
typedef basic_InputSource<std::string> InputSource;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_InputSource<std::wstring> wInputSource;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -121,9 +121,7 @@ public:
}; // class Locator
typedef basic_Locator<std::string> Locator;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_Locator<std::wstring> wLocator;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -153,9 +153,7 @@ private:
}; // class basic_SAXParseException
typedef basic_SAXParseException<std::string> SAXParseException;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_SAXParseException<std::wstring> wSAXParseException;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -62,9 +62,7 @@ public:
}; // class basic_XMLFilter
typedef basic_XMLFilter<std::string> XMLFilter;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_XMLFilter<std::wstring> wXMLFilter;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -126,9 +126,7 @@ public:
}; // class basic_DeclHandler
typedef basic_DeclHandler<std::string> DeclHandler;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_DeclHandler<std::wstring> wDeclHandler;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -268,9 +268,7 @@ private:
}; // class basic_DefaultHandler
typedef basic_DefaultHandler2<std::string> DefaultHandler2;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_DefaultHandler2<std::wstring> wDefaultHandler2;
#endif // !(__GNUG__ && (__GNUC__ < 3))
} // namespace SAX

View file

@ -186,9 +186,7 @@ public:
}; // class basic_LexicalHandler
typedef basic_LexicalHandler<std::string> LexicalHandler;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_LexicalHandler<std::wstring> wLexicalHandler;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -368,9 +368,7 @@ private:
}; // class basic_DefaultHandler
typedef basic_DefaultHandler<std::string> DefaultHandler;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_DefaultHandler<std::wstring> wDefaultHandler;
#endif // !(__GNUG__ && (__GNUC__ < 3))
} // namespace SAX

View file

@ -5,11 +5,7 @@
#pragma warning(disable: 4786)
#include <SAX/helpers/InputSourceResolver.h>
#if !(__GNUG__ && (__GNUC__ < 3))
#include <istream>
#else
#include <istream.h>
#endif // !(__GNUG__ && (__GNUC__ < 3))
#include <fstream>
#include <Utils/socket_stream.h>
@ -115,7 +111,6 @@ namespace
static bool fileReg = InputSourceResolver::registerResolver("file", fileResolver);
#if !(__GNUG__ && (__GNUC__ < 3))
std::istream* httpResolver(const std::string& httpURL)
{
#ifdef _MSC_VER
@ -157,7 +152,6 @@ namespace
} // httpResolver
static bool httpReg = InputSourceResolver::registerResolver("http", httpResolver);
#endif // !(__GNUG__ && (__GNUC__ < 3))
} // namespace
// end of file

View file

@ -26,22 +26,17 @@ public:
// only used to constuct error strings - don't have to be highly efficient!
std::string asStdString(const stringT& str) const;
#if !(__GNUG__ && (__GNUC__ < 3))
std::wstring asStdWString(const stringT& str) const;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // class default_string_maker
// specialize for std::string and std::wstring
template<>
class default_string_adaptor<std::string>
{
#if !(__GNUG__ && (__GNUC__ < 3))
private:
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;
#endif // !(__GNUG__ && (__GNUC__ < 3))
public:
char makeValueT(char c) const { return c; }
@ -53,7 +48,6 @@ public:
{
return std::string(str, length);
} // makeStringT
#if !(__GNUG__ && (__GNUC__ < 3))
std::string makeStringT(const wchar_t* str) const
{
std::wstring s;
@ -67,50 +61,39 @@ public:
n_.str(std::wstring(str, length));
return n_.str();
} // makeStringT
#endif // !(__GNUG__ && (__GNUC__ < 3))
const std::string& asStdString(const std::string& str) const
{
return str;
} // toStdString
#if !(__GNUG__ && (__GNUC__ < 3))
std::wstring asStdWString(const std::string& str) const
{
w_.str(str);
return w_.str();
} // toStdWString
#endif // !(__GNUG__ && (__GNUC__ < 3))
default_string_adaptor()
#if !(__GNUG__ && (__GNUC__ < 3))
default_string_adaptor() :
#ifndef _MSC_VER
: loc_(std::locale(), new utf16utf8_codecvt()),
loc_(std::locale(), new utf16utf8_codecvt()),
#else
: loc_(std::_Addfac(std::locale(), new utf16utf8_codecvt)),
loc_(std::_Addfac(std::locale(), new utf16utf8_codecvt)),
#endif
n_(),
w_()
#endif // !(__GNUG__ && (__GNUC__ < 3))
{
#if !(__GNUG__ && (__GNUC__ < 3))
n_.imbue(loc_);
w_.imbue(loc_);
#endif // !(__GNUG__ && (__GNUC__ < 3))
} // default_string_adaptor
private:
#if !(__GNUG__ && (__GNUC__ < 3))
std::locale loc_;
mutable narrower n_;
mutable widener w_;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // class default_string_adaptor
#if !(__GNUG__ && (__GNUC__ < 3))
template<>
class default_string_adaptor<std::wstring>
{
private:
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>,
@ -171,7 +154,6 @@ private:
mutable narrower n_;
mutable widener w_;
}; // class default_string_adaptor
#endif // !(__GNUG__ && (__GNUC__ < 3))
} // namespace SAX

View file

@ -488,9 +488,7 @@ private:
}; // class basic_XMLFilter
typedef basic_XMLFilterImpl<std::string> XMLFilterImpl;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef basic_XMLFilterImpl<std::wstring> wXMLFilterImpl;
#endif // !(__GNUG__ && (__GNUC__ < 3))
}; // namespace SAX

View file

@ -34,9 +34,6 @@
#include <xercesc/sax/SAXParseException.hpp>
#include <xercesc/util/BinInputStream.hpp>
#include <xercesc/sax/InputSource.hpp>
#ifdef (__GNUG__ && (__GNUC__ < 3))
#include <xercesc/util/TransService.hpp>
#endif
namespace SAX
@ -143,28 +140,18 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
///////////////////////////////
// String adaptor for XMLCh
#if !(__GNUG__ && (__GNUC__ < 3))
// * For the null-terminated version, we convert the array of XMLCh to a
// null-terminated vector of wchar_t. We then pass &vector[0] to the
// parent method.
// * For the known length version, we convert the the array of XMLCh to a
// vector of wchar_t. We then pass &vector[0] and length to the parent
// method.
#else
// * For the null-terminated version, we use the Xerces XMLTranscoder
// classes to convert to a null-terminated utf-8 char array. We then
// pass this to the parent method.
// * For the known length version, we copy the array, append a
// null-character and then do the above.
#endif
class xerces_string_adaptor : public string_adaptorT
{
public:
typedef typename stringT::value_type value_type;
typedef string_adaptorT base;
#if !(__GNUG__ && (__GNUC__ < 3))
typedef std::vector<wchar_t> wVector;
stringT makeStringT(const XMLCh* str) const
@ -208,99 +195,6 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
return base::makeStringT("");
}
}
#else
xerces_string_adaptor() : transcoder_(0) { }
~xerces_string_adaptor() { delete transcoder_; }
static const int MAX_BUFFER = 4096;
/* Lazily instantiates a transcoder, but only if
* XMLPlatformUtils::Initialize() has been called.
* @see xerces_initializer */
XMLTranscoder* getTranscoder() const
{
if (!transcoder_)
{
if (xerces_initializer::isInitialized())
{
// NOTE: We are going to assume that result is always "Ok".
::XMLTransService::Codes result;
transcoder_ = ::XMLPlatformUtils::fgTransService->makeNewTranscoderFor(XMLUni::fgUTF8EncodingString, result, MAX_BUFFER);
}
}
return transcoder_;
}
char* transcode(const XMLCh* toTranscode) const
{
if (0 != getTranscoder())
{
vector<XMLByte> final;
vector<XMLByte> toFill(MAX_BUFFER);
unsigned int charsEaten = 1;
while (*toTranscode && charsEaten)
{
unsigned int srcLen = ::XMLString::stringLen(toTranscode);
// Ensure we have enough space.
toFill.resize(MAX_BUFFER);
// Resize to the number of bytes written.
unsigned int size =
getTranscoder()->transcodeTo(toTranscode,
srcLen,
&toFill[0],
MAX_BUFFER,
charsEaten,
::XMLTranscoder::UnRep_RepChar);
toFill.resize(size);
final.insert(final.end(), toFill.begin(), toFill.end());
toTranscode += charsEaten;
}
final.push_back(0);
char *result = new char[final.size()];
memcpy(result, &final[0], final.size()*sizeof(char));
return result;
}
else
{
char *result = ::XMLString::transcode(toTranscode);
return result;
}
}
// Create a string from a zero-terminated array of XMLCh
stringT makeStringT(const XMLCh* str) const
{
if (str)
{
::ArrayJanitor<char> buffer(transcode(str));
return base::makeStringT(&buffer[0]);
}
else
{
return base::makeStringT("");
}
}
// Create a string from a given number of XMLCh within an array
stringT makeStringT(const XMLCh* str, int length) const
{
if (str && length)
{
std::vector<XMLCh> nullTerminated(length+1);
nullTerminated.assign(str, str+length+1);
nullTerminated.push_back(0);
::ArrayJanitor<char> buffer(transcode(&nullTerminated[0]));
return base::makeStringT(&buffer[0]);
}
else
{
return base::makeStringT("");
}
}
#endif
XMLCh* asXMLChString(const stringT& s) const
{
@ -308,10 +202,6 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
return ::XMLString::transcode(str.c_str());
}
#if (__GNUG__ && (__GNUC__ < 3))
private:
mutable XMLTranscoder* transcoder_;
#endif
};
///////////////////////////////
@ -615,7 +505,6 @@ class xerces_wrapper : public SAX::basic_XMLReader<string_type>
typedef void(SAX::ErrorHandler::* ErrorFn)(const SAX::SAXParseException&);
void handleError(const ::SAXParseException& exception, ErrorFn fn)
{
if(!errorHandler_)
return;
@ -902,15 +791,7 @@ void xerces_wrapper<stringT, string_adaptorT>::doSetProperty(const stringT& name
SAX::basic_XMLReader<stringT>::Property<lexicalHandlerT&>* prop = dynamic_cast<SAX::basic_XMLReader<stringT>::Property<lexicalHandlerT&>*>(value.get());
if(!prop)
#if (__GNUG__)
#if (__GNUC__ < 3)
throw std::runtime_error("Property LexicalHandler is wrong type, should be SAX::LexicalHandler&");
#else // (__GNUC__ < 3)
throw std::bad_cast();
#endif // (__GNUC__ < 3)
#else (__GNUG__)
throw std::bad_cast("Property LexicalHandler is wrong type, should be SAX::LexicalHandler&");
#endif (__GNUG__)
lexicalHandlerAdaptor_.setLexicalHandler(prop->get());
return;
@ -920,15 +801,8 @@ void xerces_wrapper<stringT, string_adaptorT>::doSetProperty(const stringT& name
SAX::basic_XMLReader<stringT>::Property<SAX::basic_DeclHandler<stringT>&>* prop = dynamic_cast<SAX::basic_XMLReader<stringT>::Property<SAX::basic_DeclHandler<stringT>&>*>(value.get());
if(!prop)
#if (__GNUG__)
#if (__GNUC__ < 3)
throw std::runtime_error("Property DeclHandler is wrong type, should be SAX::DeclHandler&");
#else // (__GNUC__ < 3)
throw std::bad_cast();
#endif // (__GNUC__ < 3)
#else (__GNUG__)
throw std::bad_cast("Property DeclHandler is wrong type, should be SAX::DeclHandler&");
#endif (__GNUG__)
declHandlerAdaptor_.setDeclHandler(prop->get());
return;
} // if ...