Merge pull request #21 from jezhiggins/die-autoptr-die

Die autoptr die
This commit is contained in:
Jez Higgins 2020-04-25 12:26:17 +01:00 committed by GitHub
commit f89c8042d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 1126 additions and 1298 deletions

View file

@ -7,13 +7,13 @@ cmake_minimum_required(VERSION 3.5)
project(arabica)
# Enable C++11 support
set(CMAKE_CXX_STANDARD 11)
# Enable C++14 support
set(CMAKE_CXX_STANDARD 14)
set(LIB_NAME arabica)
set(ARABICA_MAJOR_VERSION 2016)
set(ARABICA_MINOR_VERSION January)
set(ARABICA_MAJOR_VERSION 2020)
set(ARABICA_MINOR_VERSION April)
#
# Packaging details
@ -196,8 +196,6 @@ set(PUBLIC_HEADER_FILES
include/SAX/helpers/InputSourceResolver.hpp
include/SAX/helpers/LocatorImpl.hpp
include/SAX/helpers/NamespaceSupport.hpp
include/SAX/helpers/ParserAdaptor.hpp
include/SAX/helpers/PropertyNames.hpp
include/SAX/helpers/XMLBaseSupport.hpp
include/SAX/helpers/XMLFilterImpl.hpp
include/SAX/parsers/saxgarden.hpp
@ -582,4 +580,5 @@ if(BUILD_ARABICA_EXAMPLES)
endif()
include(CPack)

View file

@ -1,4 +1,4 @@
AC_INIT([Arabica],[2016-January],[jez@jezuk.co.uk])
AC_INIT([Arabica],[2020-April],[jez@jezuk.co.uk])
AM_INIT_AUTOMAKE([1.9 tar-ustar dist-bzip2 dist-zip subdir-objects])
@ -8,6 +8,7 @@ AC_PROG_CXX
LT_INIT
AC_LANG([C++])
AX_CXX_COMPILE_STDCXX([14])
ARABICA_SELECT_XML_PARSER
ARABICA_HAS_EXPAT

View file

@ -5,7 +5,6 @@
#include "SimpleHandler.hpp"
#include <SAX/InputSource.hpp>
#include <SAX/helpers/FeatureNames.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <iostream>
#include <sstream>
@ -20,7 +19,6 @@ int main(int argc, char* argv[])
SimpleHandler myHandler;
Arabica::SAX::FeatureNames<std::string> fNames;
Arabica::SAX::PropertyNames<std::string> pNames;
for(int i = 1; i < argc; ++i)
{

View file

@ -25,7 +25,7 @@ int main(int argc, const char* argv[])
try
{
Arabica::SAX::InputSource<std::string> source(argv[2]);
std::auto_ptr<Arabica::XSLT::Stylesheet<std::string> > stylesheet = compiler.compile(source);
std::unique_ptr<Arabica::XSLT::Stylesheet<std::string> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0)
{
std::cerr << "Couldn't compile stylesheet: " << compiler.error() << std::endl;

View file

@ -13,7 +13,6 @@
#include <DOM/SAX2DOM/DocumentTypeImpl.hpp>
#include <map>
#include <SAX/helpers/FeatureNames.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <SAX/SAXParseException.hpp>
namespace Arabica
@ -97,8 +96,6 @@ class Parser : protected Arabica::SAX::DefaultHandler<stringT, typename ParserTy
bool parse(InputSourceT& source)
{
Arabica::SAX::PropertyNames<stringT, string_adaptorT> pNames;
DOM::DOMImplementation<stringT, string_adaptorT> di = Arabica::SimpleDOM::DOMImplementation<stringT, string_adaptorT>::getDOMImplementation();
document_ = di.createDocument(string_adaptorT::construct_from_utf8(""), string_adaptorT::construct_from_utf8(""), 0);
currentNode_ = document_;

View file

@ -173,7 +173,7 @@ int prefix_mapper(std::basic_ostream<charT, traitsT>& stream,
{
//DOM::Node<stringT, string_adaptorT> attr = attrs.getNamedItem(*a);
const DOM::Node<stringT, string_adaptorT> attr = attrNodes[a];
if(attr.getNodeName().empty() ||
if(string_adaptorT::empty(attr.getNodeName()) ||
isXmlns<stringT, string_adaptorT, charT>(attr.getNodeName()) ||
isXmlns<stringT, string_adaptorT, charT>(attr.getPrefix()))
continue;

View file

@ -40,10 +40,8 @@ sax_headers = SAX/SAXParseException.hpp \
SAX/helpers/AttributeTypes.hpp \
SAX/helpers/AttributeDefaults.hpp \
SAX/helpers/LocatorImpl.hpp \
SAX/helpers/ParserAdaptor.hpp \
SAX/helpers/NamespaceSupport.hpp \
SAX/helpers/XMLFilterImpl.hpp \
SAX/helpers/PropertyNames.hpp \
SAX/helpers/AttributesImpl.hpp \
SAX/helpers/DefaultHandler.hpp \
SAX/helpers/InputSourceResolver.hpp \

View file

@ -1,12 +1,94 @@
#ifndef ARABICA_ARABICA_CONFIG_H
#define ARABICA_ARABICA_CONFIG_H
#cmakedefine ARABICA_NO_WCHAR_T
#cmakedefine ARABICA_VS6_WORKAROUND
#cmakedefine ARABICA_NO_CODECVT_SPECIALISATIONS
#cmakedefine ARABICA_USE_WINSOCK
#cmakedefine ARABICA_WINDOWS
#cmakedefine ARABICA_HAVE_BOOST
#define ARABICA_@ARABICA_XML_BACKEND@
#endif // ARABICA_ARABICA_CONFIG_H
/* include/SAX/ArabicaConfig.hpp.in. Generated from configure.ac by autoheader. */
/* define if the Boost library is available */
#undef HAVE_BOOST
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* define to use the Elephant memory leak detector */
#undef HAVE_ELEPHANT
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* defined if we don't need extra codecvt template specialisations */
#undef NO_CODECVT_SPECIALISATIONS
/* no mbstate_t */
#undef NO_MBSTATE_T
/* no std::mbstate_t */
#undef NO_STD_MBSTATE_T
/* disables wchar_t */
#undef NO_WCHAR_T
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* define to build against Expat */
#define USE_EXPAT
/* define to build using Garden */
#undef USE_GARDEN
/* define to build against LibXML2 */
#undef USE_LIBXML2
/* defined for Windows builds using Winsock rather than BSD-style sockets */
#undef USE_WINSOCK
/* define to build against Xerces */
#undef USE_XERCES
/* Version number of package */
#undef VERSION

View file

@ -34,12 +34,12 @@ namespace SAX {
*
* \par
* Ownership of a std::istream is passed to an IStreamHandle via a
* <code>std::auto_ptr<std::istream></code>. Ownership of a
* <code>std::unique_ptr<std::istream></code>. Ownership of a
* std::istream is passed between IStreamHandle by assignment.
*
* \see IStreamHandle(std::auto_ptr<std::istream>) for passing
* \see IStreamHandle(std::unique_ptr<std::istream>) for passing
* ownership at construction.
* \see IStreamHandle::operator=(std::auto_ptr<std::istream>) for
* \see IStreamHandle::operator=(std::unique_ptr<std::istream>) for
* passing ownership after construction.
* \see IStreamHandle(std::istream&) for constructing without
* passing ownership
@ -89,7 +89,7 @@ namespace SAX {
*
* \par
* If an IStreamHandle is constructed with or assigned a
* std::auto_ptr<std::istream>, it <i>takes ownership</i> of
* std::unique_ptr<std::istream>, it <i>takes ownership</i> of
* the pointee. If an IStreamHandle is constructed with or
* assigned a std::istream&, it <i>does not take
* ownership</i> of the pointee.
@ -117,9 +117,9 @@ namespace SAX {
*
* \par
* All public API methods of IStreamHandle that take an
* auto_ptr<std::istream> parameter conform to the follow post-conditions.
* unique_ptr<std::istream> parameter conform to the follow post-conditions.
* For the purposes of these post-conditions, <code>rhs</code> will represent
* the std::auto_ptr parameter.
* the std::unique_ptr parameter.
* - <code>is_</code> contains the value returned by <code>rhs.release()</code>.
* - <code>rhs.get() == 0</code> (ownership has been transfered).
* - <code>owner_ = true</code>
@ -169,8 +169,8 @@ public:
* other IStreamHandle objects.
*
*/
explicit IStreamHandle(std::auto_ptr<std::istream> is);
explicit IStreamHandle(std::auto_ptr<std::iostream> is);
explicit IStreamHandle(std::unique_ptr<std::istream> is);
explicit IStreamHandle(std::unique_ptr<std::iostream> is);
/** Construct an IStreamHandle sharing a std::istream with <em>rhs</em>.
*
@ -225,8 +225,8 @@ public:
* shared with other IStreamHandle objects.
*
*/
IStreamHandle& operator=(std::auto_ptr<std::istream> rhs);
IStreamHandle& operator=(std::auto_ptr<std::iostream> rhs);
IStreamHandle& operator=(std::unique_ptr<std::istream> rhs);
IStreamHandle& operator=(std::unique_ptr<std::iostream> rhs);
/** Assign a new std::istream to <code>this</code>. This destroys the
* std::istream held by <code>this</code> if <code>this</code> <i>owns</i>
@ -296,7 +296,7 @@ IStreamHandle::IStreamHandle(std::istream& is)
}
inline
IStreamHandle::IStreamHandle(std::auto_ptr<std::istream> is)
IStreamHandle::IStreamHandle(std::unique_ptr<std::istream> is)
: is_(is.release()),
counter_(new int(0)),
owner_(true)
@ -307,7 +307,7 @@ IStreamHandle::IStreamHandle(std::auto_ptr<std::istream> is)
}
inline
IStreamHandle::IStreamHandle(std::auto_ptr<std::iostream> is)
IStreamHandle::IStreamHandle(std::unique_ptr<std::iostream> is)
: is_(is.release()),
counter_(new int(0)),
owner_(true)
@ -352,7 +352,7 @@ IStreamHandle& IStreamHandle::operator=(const IStreamHandle& rhs)
}
inline
IStreamHandle& IStreamHandle::operator=(std::auto_ptr<std::istream> rhs)
IStreamHandle& IStreamHandle::operator=(std::unique_ptr<std::istream> rhs)
{
removeRef();
set(rhs.release(), true);
@ -365,7 +365,7 @@ IStreamHandle& IStreamHandle::operator=(std::auto_ptr<std::istream> rhs)
}
inline
IStreamHandle& IStreamHandle::operator=(std::auto_ptr<std::iostream> rhs)
IStreamHandle& IStreamHandle::operator=(std::unique_ptr<std::iostream> rhs)
{
removeRef();
set(rhs.release(), true);

View file

@ -105,7 +105,7 @@ public:
* @param byteStream The raw byte stream containing the document. The
* InputSource does not assume ownership of
* this byteStream.
* @see #InputSource(std::auto_ptr<std::istream>)
* @see #InputSource(std::unique_ptr<std::istream>)
* @see #setPublicId
* @see #setSystemId
* @see #setEncoding
@ -136,15 +136,15 @@ public:
* @see #setEncoding
* @see #setByteStream
*/
InputSource(std::auto_ptr<std::istream> byteStream) :
byteStream_(byteStream),
InputSource(std::unique_ptr<std::istream>&& byteStream) :
byteStream_(std::move(byteStream)),
publicId_(),
systemId_(),
encoding_()
{ }
InputSource(std::auto_ptr<std::iostream> byteStream) :
byteStream_(byteStream),
InputSource(std::unique_ptr<std::iostream>&& byteStream) :
byteStream_(std::move(byteStream)),
publicId_(),
systemId_(),
encoding_()
@ -233,7 +233,7 @@ public:
* @param byteStream A byte stream containing an XML document or
* other entity. The InputSource does not assume
* ownership of byteStream.
* @see #setByteStream(std::auto_ptr<std::istream>) To transfer ownership of
* @see #setByteStream(std::unique_ptr<std::istream>) To transfer ownership of
* an std::istream to an InputSource
* @see #setEncoding
* @see #getByteStream
@ -261,7 +261,7 @@ public:
* @see #getByteStream
* @see #getEncoding
*/
void setByteStream(std::auto_ptr<std::istream> byteStream)
void setByteStream(std::unique_ptr<std::istream> byteStream)
{
byteStream_ = byteStream;
} // setByteStream

View file

@ -336,106 +336,6 @@ public:
* @see #setErrorHandler
*/
virtual void parse(InputSourceT& input) = 0;
////////////////////////////////////////////////////
// property implementation
protected:
class PropertyBase
{
public:
virtual ~PropertyBase() { }
}; // PropertyBase
template<typename propertyTypeT>
class Property : public PropertyBase
{
public:
Property(propertyTypeT wrappee) : wrappee_(wrappee) { }
propertyTypeT get() { return wrappee_; }
private:
propertyTypeT wrappee_;
}; // class Property
public:
virtual std::auto_ptr<PropertyBase> doGetProperty(const string_type& name) = 0;
virtual void doSetProperty(const string_type& name, std::auto_ptr<PropertyBase> value) = 0;
/**
* Look up the value of a property.
*
* <p>The property name is any fully-qualified URI. It is
* possible for an XMLReader to recognize a property name but
* to be unable to return its state; this is especially true
* in the case of an adapter for a SAX1 {@link Parser
* Parser}.</p>
*
* <p>XMLReaders are not required to recognize any specific
* property names, though an initial core set is documented for
* SAX2.</p>
*
* <p>Some property values may be available only in specific
* contexts, such as before, during, or after a parse.</p>
*
* <p>Implementors are free (and encouraged) to invent their own properties,
* using names built on their own URIs.</p>
*
* @param name The property name, which is a fully-qualified URI.
* @return The current value of the property.
* @exception SAXNotRecognizedException When the
* XMLReader does not recognize the property name.
* @exception SAXNotSupportedException When the
* XMLReader recognizes the property name but
* cannot determine its value at this time.
* @see #setProperty
*/
template<typename propertyTypeT>
propertyTypeT& getProperty(const string_type& name) const
{
std::auto_ptr<PropertyBase> pb = doGetProperty(name);
Property<propertyTypeT&>* prop = dynamic_cast<Property<propertyTypeT&>* >(pb.get());
if(!prop)
throw SAX::SAXNotSupportedException("Property " + name + " is wrong type.");
return prop->get();
} // getProperty
/**
* Set the value of a property.
*
* <p>The property name is any fully-qualified URI. It is
* possible for an XMLReader to recognize a property name but
* to be unable to set its value; this is especially true
* in the case of an adapter for a SAX1 {@link Parser
* Parser}.</p>
*
* <p>XMLReaders are not required to recognize setting
* any specific property names, though a core set is provided with
* SAX2.</p>
*
* <p>Some property values may be immutable or mutable only
* in specific contexts, such as before, during, or after
* a parse.</p>
*
* <p>This method is also the standard mechanism for setting
* extended handlers.</p>
*
* @param name The property name, which is a fully-qualified URI.
* @param value The requested value for the property.
* @exception SAXNotRecognizedException When the
* XMLReader does not recognize the property name.
* @exception SAXNotSupportedException When the
* XMLReader recognizes the property name but
* cannot set the requested value.
*/
template<typename propertyTypeT>
void setProperty(const string_type& name, propertyTypeT& value)
{
Property<propertyTypeT&>* prop = new Property<propertyTypeT&>(value);
doSetProperty(name, std::auto_ptr<PropertyBase>(prop));
} // setProperty
}; // class XMLReaderInterface
} // namespace SAX

View file

@ -31,13 +31,7 @@ namespace SAX
* {@link LexicalHandler#endDTD endDTD} events.</p>
*
* <p>To set the DeclHandler for an XML reader, use the
* {@link XMLReader#setProperty setProperty} method
* with the propertyId "http://xml.org/sax/properties/declaration-handler".
* If the reader does not support declaration events, it will throw a
* {@link SAXNotRecognizedException SAXNotRecognizedException}
* or a
* {@link SAXNotSupportedException SAXNotSupportedException}
* when you attempt to register the handler.</p>
* {@link XMLReader#setDeclHandler setDeclHandler}.</P>
*
* @since 2.0
* @author Jez Higgins,

View file

@ -28,21 +28,13 @@ namespace SAX
* endDocument events.</p>
*
* <p>To set the LexicalHandler for an XML reader, use the
* {@link XMLReader#setProperty setProperty} method
* with the propertyId "http://xml.org/sax/properties/lexical-handler".
* If the reader does not support lexical events, it will throw a
* {@link SAXNotRecognizedException SAXNotRecognizedException}
* or a
* {@link SAXNotSupportedException SAXNotSupportedException}
* when you attempt to register the handler.</p>
* {@link XMLReader#setLexicalHandler setLexicalHandler} method.</p>
*
* @since 2.0
* @author Jez Higgins,
* <a href="mailto:jez@jezuk.co.uk">jez@jezuk.co.uk</a>
* @version 1.0
* @see XMLReader#setProperty
* @see SAXNotRecognizedException
* @see SAXNotSupportedException
* @see XMLReader#setLexicalHandler
*/
template<class string_type, class string_adaptor = Arabica::default_string_adaptor<string_type> >
class LexicalHandler

View file

@ -3,8 +3,7 @@
#include <SAX/ArabicaConfig.hpp>
#include <string>
// $Id$
#include <memory>
namespace Arabica
{
@ -27,16 +26,16 @@ namespace SAX
class XMLPScanToken
{
public:
void setParserData(std::auto_ptr<XMLPScanTokenParserImpl>& data)
void setParserData(std::unique_ptr<XMLPScanTokenParserImpl>&& data)
{
data_ = data;
data_.swap(data);
}
XMLPScanTokenParserImpl* parserImpl()
{
return data_.get();
}
private:
std::auto_ptr<XMLPScanTokenParserImpl> data_;
std::unique_ptr<XMLPScanTokenParserImpl> data_;
}; // XMLPScanToken
template<class string_type, class string_adaptor>

View file

@ -8,7 +8,6 @@
#include <SAX/ext/LexicalHandler.hpp>
#include <SAX/ext/DeclHandler.hpp>
#include <text/UnicodeCharacters.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <XML/escaper.hpp>
#include <Arabica/StringAdaptor.hpp>
#include <Arabica/getparam.hpp>
@ -42,7 +41,6 @@ class Writer : public XMLFilterImpl<string_type, string_adaptor>
typedef LexicalHandler<string_type, string_adaptor> LexicalHandlerT;
typedef DeclHandler<string_type, string_adaptor> DeclHandlerT;
typedef typename XMLReaderT::InputSourceT InputSourceT;
typedef typename XMLReaderT::PropertyBase PropertyBaseT;
using XMLFilterT::getParent;
public:
@ -167,8 +165,6 @@ class Writer : public XMLFilterImpl<string_type, string_adaptor>
ostreamT* stream_;
string_type encoding_;
enum { startTag, endTag, docTag } lastTag_;
const SAX::PropertyNames<string_type> properties_;
}; // class Writer
template<class string_type, class string_adaptor>

View file

@ -1,548 +0,0 @@
#ifndef ARABICA_PARSER_ADAPTOR_H
#define ARABICA_PARSER_ADAPTOR_H
// ParserAdaptor
// Adapts a SAX1 Parser to a SAX2 XMLReader.
// $Id$
#include <SAX/ArabicaConfig.hpp>
#include <SAX/XMLReader.hpp>
#include <SAX/Parser.hpp>
#include <SAX/DocumentHandler.hpp>
#include <SAX/helpers/NamespaceSupport.hpp>
#include <SAX/AttributeList.hpp>
#include <SAX/helpers/AttributesImpl.hpp>
#include <SAX/SAXParseException.hpp>
#include <SAX/SAXNotSupportedException.hpp>
#include <SAX/SAXNotRecognizedException.hpp>
#include <sstream>
namespace Arabica
{
namespace SAX
{
/**
* Adapt a SAX1 Parser as a SAX2 XMLReader.
*
* <p>This class wraps a SAX1 {@link Parser Parser}
* and makes it act as a SAX2 {@link XMLReader XMLReader},
* with feature, property, and Namespace support. Note
* that it is not possible to report {@link ContentHandler#skippedEntity
* skippedEntity} events, since SAX1 does not make that information available.</p>
*
* <p>This adapter does not test for duplicate Namespace-qualified
* attribute names.</p>
*
* @since SAX 2.0
* @author Jez Higgins,
* <a href="mailto:jez@jezuk.co.uk">jez@jezuk.co.uk</a>
* @version 2.0
* @see XMLReader
* @see Parser
*/
template<class string_type, class string_adaptor_type>
class ParserAdaptor : public XMLReaderInterface<string_type, string_adaptor, int>,
public DocumentHandler<string_type, string_adaptor>
{
public:
typedef Parser<string_type, string_adaptor> ParserT;
typedef EntityResolver<string_type, string_adaptor> EntityResolverT;
typedef DTDHandler<string_type, string_adaptor> DTDHandlerT;
typedef DocumentHandler<string_type, string_adaptor> DocumentHandlerT;
typedef ContentHandler<string_type, string_adaptor> ContentHandlerT;
typedef InputSource<string_type, string_adaptor> InputSourceT;
typedef Locator<string_type, string_adaptor> LocatorT;
typedef SAXParseException<string_type, string_adaptor> SAXParseExceptionT;
typedef AttributeList<string_type, string_adaptor> AttributeListT;
ParserAdaptor(ParserT& parser) :
parser_(parser),
parsing_(false),
locator_(0),
namespaces_(true),
prefixes_(false),
entityResolver_(0),
dtdHandler_(0),
contentHandler_(0),
errorHandler_(0)
{
} // ParserAdaptor
////////////////////////////////
// implement XMLReader
/**
* Set a feature for the parser.
*
* <p>The only features supported are namespaces and
* namespace-prefixes.</p>
*
* @param name The feature name, as a complete URI.
* @param value The requested feature value.
* @exception SAXNotRecognizedException If the feature
* name is not known.
* @exception SAXNotSupportedException If the feature
* state is not supported.
* @see XMLReader#setFeature
*/
virtual void setFeature(const string_type& name, bool value)
{
if(name == NAMESPACES)
{
checkNotParsing("feature", name);
namespaces_ = value;
if(!namespaces_ && !prefixes_)
prefixes_ = true;
}
else if(name == NAMESPACE_PREFIXES)
{
checkNotParsing("feature", name);
prefixes_ = value;
if(!prefixes_ && !namespaces_)
namespaces_ = true;
}
else if(name == VALIDATION ||
name == EXTERNAL_GENERAL ||
name == EXTERNAL_PARAMETER)
{
throw SAXNotSupportedException("Feature not supported " + makeString(name));
}
else
{
throw SAXNotRecognizedException("Feature not recognized " + makeString(name));
}
} // setFeature
/**
* Check a parser feature.
*
* <p>The only features supported are namespaces and
* namespace-prefixes.</p>
*
* @param name The feature name, as a complete URI.
* @return The current feature state.
* @exception SAXNotRecognizedException If the feature
* name is not known.
* @exception SAXNotSupportedException If querying the
* feature state is not supported.
* @see XMLReader#setFeature
*/
virtual bool getFeature(const string_type& name) const
{
if(name == NAMESPACES)
{
return namespaces_;
}
else if(name == NAMESPACE_PREFIXES)
{
return prefixes_;
}
else if(name == VALIDATION ||
name == EXTERNAL_GENERAL ||
name == EXTERNAL_PARAMETER)
{
throw SAXNotSupportedException("Feature not supported " + makeString(name));
}
else
{
throw SAXNotRecognizedException("Feature not recognized " + makeString(name));
}
} // getFeature
protected:
virtual std::auto_ptr<PropertyBase> doGetProperty(const string_type& name)
{
throw SAXNotRecognizedException("Property not recognized " + makeString(name));
} // doGetProperty
virtual void doSetProperty(const string_type& name, std::auto_ptr<PropertyBase> value)
{
throw SAXNotRecognizedException("Property not recognized " + makeString(name));
} // doSetProperty
public:
/**
* Set the entity resolver.
*
* @param resolver The new entity resolver.
* @see XMLReader#setEntityResolver
*/
virtual void setEntityResolver(EntityResolverT& resolver) { entityResolver_ = &resolver; }
/**
* Return the current entity resolver.
*
* @return The current entity resolver, or null if none was supplied.
* @see XMLReader#getEntityResolver
*/
virtual EntityResolverT* getEntityResolver() const { return entityResolver_; }
/**
* Set the DTD handler.
*
* @param handler The new DTD handler.
* @see XMLReader#setEntityResolver
*/
virtual void setDTDHandler(DTDHandlerT& handler) { dtdHandler_ = &handler; }
/**
* Return the current DTD handler.
*
* @return The current DTD handler, or null if none was supplied.
* @see XMLReader#getEntityResolver
*/
virtual DTDHandlerT* getDTDHandler() const { return dtdHandler_; }
/**
* Set the content handler.
*
* @param handler The new content handler.
* @see XMLReader#setEntityResolver
*/
virtual void setContentHandler(ContentHandlerT& handler) { contentHandler_ = &handler; }
/**
* Return the current content handler.
*
* @return The current content handler, or null if none was supplied.
* @see XMLReader#getEntityResolver
*/
virtual ContentHandlerT* getContentHandler() const { return contentHandler_; }
/**
* Set the error handler.
*
* @param handler The new error handler.
* @see XMLReader#setEntityResolver
*/
virtual void setErrorHandler(ErrorHandler& handler) { errorHandler_ = &handler; }
/**
* Return the current error handler.
*
* @return The current error handler, or null if none was supplied.
* @see XMLReader#getEntityResolver
*/
virtual ErrorHandler* getErrorHandler() const { return errorHandler_; }
/**
* Parse an XML document.
*
* @param input An input source for the document.
* @see Parser#parse(InputSource&)
*/
virtual void parse(InputSourceT& input)
{
if(parsing_)
throw SAXException("Parser is already in use.");
setupParser();
parsing_ = true;
try
{
parser_.parse(input);
}
catch(...)
{
parsing_ = false;
throw;
}
parsing_ = false;
} // parse
/////////////////////////////////////
// DocumentHandler implementation
/**
* Adapt a SAX1 document locator event.
*
* @param locator A document locator.
* @see ContentHandler#setDocumentLocator
*/
virtual void setDocumentLocator(const LocatorT& locator)
{
locator_ = &locator;
if(contentHandler_)
contentHandler_->setDocumentLocator(locator);
} // setDocumentLocator
/**
* Adapt a SAX1 start document event.
*
* @see DocumentHandler#startDocument
*/
virtual void startDocument()
{
if(contentHandler_)
contentHandler_->startDocument();
} // startDocument
/**
* Adapt a SAX1 end document event.
*
* @see DocumentHandler#endDocument
*/
virtual void endDocument()
{
if(contentHandler_)
contentHandler_->endDocument();
} // endDocument
/**
* Adapt a SAX1 startElement event.
*
* <p>If necessary, perform Namespace processing.</p>
*
* @param qName The qualified (prefixed) name.
* @param qAtts The XML 1.0 attribute list (with qnames).
*/
virtual void startElement(const string_type& qName,
const AttributeListT& qAtts)
{
if(!namespaces_)
{
if(contentHandler_)
{
attAdaptor_.setAttributeList(qAtts);
contentHandler_->startElement(NULL_STRING, NULL_STRING, qName, attAdaptor_);
} // if(contentHandler_)
return;
} // if(!namespaces)
// OK we're doing Namespaces
nsSupport_.pushContext();
bool seenDecl = false;
atts_.clear();
// take a first pass and copy all the attributes, noting any declarations
int length = qAtts.getLength();
for(int i = 0; i < length; ++i)
{
string_type attQName = qAtts.getName(i);
string_type type = qAtts.getType(i);
string_type value = qAtts.getValue(i);
// declaration?
if(attQName.find(NamespaceSupportT::XMLNS) == 0)
{
string_type prefix;
int n = attQName.find(NamespaceSupportT::COLON);
if(n != string_type::npos())
prefix = string_type(attQName.begin() + n + 1, attQName.end());
if(!nsSupport_.declarePrefix(prefix, value))
reportError("Illegal Namespace prefix " + makeString(prefix));
if(contentHandler_)
contentHandler_->startPrefixMapping(prefix, value);
if(prefixes_)
atts_.addAttribute(NULL_STRING, NULL_STRING, attQName, type, value);
seenDecl = true;
}
else
{
NamespaceSupportT::Parts attName = processName(attQName, true);
atts_.addAttribute(attName.URI, attName.localName, attName.rawName, type, value);
}
} // for ...
// if there was a Namespace decl we have to go around again
if(seenDecl)
{
int length = atts_.getLength();
for(int i = 0; i < length; ++i)
{
string_type attQName = atts_.getQName(i);
if(attQName.find(NamespaceSupportT::XMLNS))
{
NamespaceSupportT::Parts attName = processName(attQName, true);
atts_.setURI(i, attName.URI);
atts_.setLocalName(i, attName.localName);
} // if ...
} // for ...
} // if(seenDecl)
// at last! report the event
if(contentHandler_)
{
NamespaceSupportT::Parts name = processName(qName, false);
contentHandler_->startElement(name.URI, name.localName, name.rawName, atts_);
} // if(contentHandler_)
} // startElement
/**
* Adapt a SAX1 end element event.
*
* @param qName The qualified (prefixed) name.
* @see DocumentHandler#endElement
*/
void endElement(const string_type& qName)
{
if(!namespaces_)
{
if(contentHandler_)
contentHandler_->endElement(NULL_STRING, NULL_STRING, qName);
return;
} // if(!namespaces_)
NamespaceSupportT::Parts name = processName(qName, false);
if(contentHandler_)
{
contentHandler_->endElement(name.URI, name.localName, name.rawName);
NamespaceSupportT::stringListT prefixes = nsSupport_.getDeclaredPrefixes();
for(int i = 0, end = prefixes.size(); i != end; ++i)
contentHandler_->endPrefixMapping(prefixes[i]);
} // if(contentHandler_)
nsSupport_.popContext();
} // endElement
/**
* Adapt a SAX1 characters event.
*
* @param ch The characters.
* @see DocumentHandler#characters
*/
virtual void characters(const string_type& ch)
{
if(contentHandler_)
contentHandler_->characters(ch);
} // characters
/**
* Adapt a SAX1 ignorable whitespace event.
*
* @param ch Thecharacters.
* @see DocumentHandler#ignorableWhitespace
*/
virtual void ignorableWhitespace(const string_type& ch)
{
if(contentHandler_)
contentHandler_->ignorableWhitespace(ch);
} // ignorableWhitespace
/**
* Adapt a SAX1 processing instruction event.
*
* @param target The processing instruction target.
* @param data The remainder of the processing instruction
* @see DocumentHandler#processingInstruction
*/
virtual void processingInstruction(const string_type& target, const string_type& data)
{
if(contentHandler_)
contentHandler_->processingInstruction(target, data);
} // processingInstruction
private:
typedef NamespaceSupport<string_type, string_adaptor> NamespaceSupportT;
typedef AttributesImpl<string_type> AttributesImplT;
void setupParser()
{
nsSupport_.reset();
if(entityResolver_)
parser_.setEntityResolver(*entityResolver_);
if(dtdHandler_)
parser_.setDTDHandler(*dtdHandler_);
if(errorHandler_)
parser_.setErrorHandler(*errorHandler_);
parser_.setDocumentHandler(*this);
locator_ = 0;
} // setupParser
NamespaceSupportT::Parts processName(const string_type& qName, bool isAttribute)
{
NamespaceSupportT::Parts p = nsSupport_.processName(qName, isAttribute);
if(p.URI == NULL_STRING && p.prefix != NULL_STRING)
reportError("Undeclared prefix " + makeString(qName));
return p;
} // processName
void reportError(const std::string& message)
{
if(errorHandler_ == 0)
return;
if(locator_)
errorHandler_->error(SAXParseExceptionT(message, *locator_));
else
errorHandler_->error(SAXParseExceptionT(message, NULL_STRING, NULL_STRING, -1, -1));
} // reportError
void checkNotParsing(const std::string& type, const string_type& name)
{
if(parsing_)
throw SAXNotSupportedException("Can't change feature while parsing");
} // checkNotParsing
std::string makeString(const string_type& str) const
{
return string_adaptor::asStdString(str);
} // makeString
// This wrapper is used only when Namespace support is disabled.
class AttributesListAdaptor : public Attributes<string_type>
{
public:
typedef typename ParserAdaptor<string_type, string_adaptor> ParserAdaptorT;
typedef typename AttributeList<string_type, string_adaptor> AttributeListT;
void setAttributeList(const AttributeListT& attList)
{
attList_ = &attList;
} // setAttributeList
virtual int getLength() const { return attList_->getLength(); }
virtual string_type getURI(int) const { return string_type(); }
virtual string_type getLocalName(int) const { return string_type(); }
virtual string_type getQName(int i) const { return attList_->getName(i); }
virtual string_type getType(int i) const { return attList_->getType(i); }
virtual string_type getValue(int i) const { return attList_->getValue(i); }
virtual int getIndex(const string_type&, const string_type&) const { return -1; }
virtual int getIndex(const string_type& qName) const
{
int max = attList_->getLength();
for(int i = 0; i < max; ++i)
if(attList_->getName(i) == qName)
return i;
return -1;
} // getIndex
virtual string_type getType(const string_type&, const string_type&) const { return string_type(); }
virtual string_type getType(const string_type& qName) const { return attList_->getType(qName); }
virtual string_type getValue(const string_type&, const string_type&) const { return string_type(); }
virtual string_type getValue(const string_type& qName) const { return attList_->getValue(qName); }
private:
static string_type empty_;
const AttributeListT* attList_;
}; // AttributesListAdaptor
// member variables
NamespaceSupportT nsSupport_;
AttributesListAdaptor attAdaptor_;
bool parsing_;
// strings?
ParserT& parser_;
AttributesImplT atts_;
// features
bool namespaces_;
bool prefixes_;
// handlers
const LocatorT* locator_;
EntityResolverT* entityResolver_;
DTDHandlerT* dtdHandler_;
ContentHandlerT* contentHandler_;
ErrorHandler* errorHandler_;
public:
const string_type NULL_STRING;
private:
ParserAdaptor();
ParserAdaptor(const ParserAdaptor&);
ParserAdaptor& operator=(const ParserAdaptor&);
bool operator==(const ParserAdaptor&);
}; // ParserAdaptor
} // namespace SAX
} // namespace Arabica
#endif

View file

@ -1,53 +0,0 @@
#ifndef ARABICA_PROPERTY_NAMES_H
#define ARABICA_PROPERTY_NAMES_H
/*
* $Id$
*/
#include <SAX/ArabicaConfig.hpp>
#include <SAX/XMLReader.hpp>
#include <Arabica/StringAdaptor.hpp>
namespace Arabica
{
namespace SAX
{
/** The core SAX 2 parser properties. */
template<class string_type, class string_adaptor_type = Arabica::default_string_adaptor<string_type> >
struct PropertyNames
{
/** @name SAX 2 Properties
* @{ */
/** Register a lexical handler.
*
* The Lexical Handler is used to see some syntax events that are essential
* in some applications: comments, CDATA delimiters, selected general
* entity inclusions, and the start and end of the DTD (and declaration of
* document element name).
*
* The value assigned must implement SAX::LexicalHandler.
*/
const string_type lexicalHandler;
/** Register a Declaration Handler.
*
* Used to see most DTD declarations except those treated as lexical
* ("document element name is ...") or which are mandatory for all SAX
* parsers (DTDHandler).
*
* The value assigned must implement SAX::DeclHandler */
const string_type declHandler;
/** @} */
PropertyNames() :
lexicalHandler(string_adaptor_type::construct_from_utf8("http://xml.org/sax/handlers/LexicalHandler")),
declHandler(string_adaptor_type::construct_from_utf8("http://xml.org/sax/handlers/DeclHandler"))
{
} // PropertyNames
}; // struct PropertyNames
} // namespace SAX
} // namespace Arabica
#endif
// end of file

View file

@ -223,29 +223,6 @@ public:
parent_->parse(input);
} // parse
virtual std::auto_ptr<typename XMLReaderT::PropertyBase> doGetProperty(const string_type& name)
{
if(parent_)
return parent_->doGetProperty(name);
string_type ex = string_adaptor::construct_from_utf8("Property: ");
string_adaptor::append(ex, name);
throw SAXNotRecognizedException(string_adaptor::asStdString(ex));
} // doGetProperty
virtual void doSetProperty(const string_type& name, typename std::auto_ptr<typename XMLReaderT::PropertyBase> value)
{
if(parent_)
{
parent_->doSetProperty(name, value);
return;
} // if(parent_)
string_type ex = string_adaptor::construct_from_utf8("Property: ");
string_adaptor::append(ex, name);
throw SAXNotRecognizedException(string_adaptor::asStdString(ex));
} // doSetProperty
public:
//////////////////////////////////////////////////
// EntityResolver

View file

@ -48,7 +48,6 @@ public:
typedef ErrorHandler<string_type, string_adaptor> ErrorHandlerT;
typedef DeclHandler<string_type, string_adaptor> declHandlerT;
typedef LexicalHandler<string_type, string_adaptor> lexicalHandlerT;
typedef typename XMLReaderT::PropertyBase PropertyBaseT;
Garden();
@ -70,9 +69,6 @@ public:
virtual void parse(InputSourceT& input);
virtual std::auto_ptr<PropertyBaseT> doGetProperty(const string_type& name);
virtual void doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value);
private:
void reportError(const std::string& message, bool fatal = false);
@ -256,20 +252,6 @@ void Garden<string_type, T0, T1>::setFeature(const string_type& name, bool value
throw SAXNotRecognizedException(string_adaptor::asStdString(name));
} // setFeature
///////////////////////////////////////
// properties
template<class string_type, class T0, class T1>
std::auto_ptr<typename Garden<string_type, T0, T1>::PropertyBaseT> Garden<string_type, T0, T1>::doGetProperty(const string_type& name)
{
throw SAXNotRecognizedException(string_adaptor::asStdString(name));
} // doGetProperty
template<class string_type, class T0, class T1>
void Garden<string_type, T0, T1>::doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value)
{
throw SAXNotRecognizedException(string_adaptor::asStdString(name));
} // doSetProperty
//////////////////////////////////////////
// parse
template<class string_type, class T0, class T1>

View file

@ -5,7 +5,6 @@
*/
#include <Arabica/StringAdaptor.hpp>
#include <SAX/helpers/PropertyNames.hpp>
namespace Arabica
{
@ -13,8 +12,7 @@ namespace SAX
{
template<class string_type,
class string_adaptor_type = Arabica::default_string_adaptor<string_type> >
struct XercesPropertyNames : public PropertyNames<string_type,
string_adaptor_type>
struct XercesPropertyNames
{
/** \name Xerces properties.
* @{ */

View file

@ -19,7 +19,6 @@
#include <SAX/helpers/NamespaceSupport.hpp>
#include <SAX/helpers/InputSourceResolver.hpp>
#include <SAX/helpers/FeatureNames.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <Arabica/StringAdaptor.hpp>
#include <SAX/helpers/AttributeDefaults.hpp>
#include <typeinfo>
@ -226,11 +225,6 @@ class expat_wrapper :
typedef SAX::NamespaceSupport<string_type, string_adaptor> namespaceSupportT;
typedef SAX::ErrorHandler<string_type, string_adaptor> errorHandlerT;
typedef SAX::SAXParseException<string_type, string_adaptor> SAXParseExceptionT;
typedef typename XMLReaderT::PropertyBase PropertyBaseT;
typedef typename XMLReaderT::template Property<lexicalHandlerT*> getLexicalHandlerT;
typedef typename XMLReaderT::template Property<lexicalHandlerT&> setLexicalHandlerT;
typedef typename XMLReaderT::template Property<declHandlerT*> getDeclHandlerT;
typedef typename XMLReaderT::template Property<declHandlerT&> setDeclHandlerT;
typedef XML::QualifiedName<string_type, string_adaptor> qualifiedNameT;
expat_wrapper();
@ -270,11 +264,6 @@ class expat_wrapper :
virtual size_t getLineNumber() const;
virtual size_t getColumnNumber() const;
///////////////////////////////////////////////////
// properties
protected:
virtual std::auto_ptr<PropertyBaseT> doGetProperty(const string_type& name);
virtual void doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value);
private:
qualifiedNameT processName(const string_type& qName, bool isAttribute);
void reportError(const std::string& message, bool fatal = false);
@ -347,7 +336,6 @@ class expat_wrapper :
string_type emptyString_;
const SAX::FeatureNames<string_type, string_adaptor> features_;
const SAX::PropertyNames<string_type, string_adaptor> properties_;
const SAX::NamespaceConstants<string_type, string_adaptor> nsc_;
const SAX::AttributeDefaults<string_type, string_adaptor> attrDefaults_;
@ -520,52 +508,6 @@ bool expat_wrapper<string_type, T0, T1>::do_parse(inputSourceT& source, XML_Pars
return true;
} // do_parse
template<class string_type, class T0, class T1>
std::auto_ptr<typename expat_wrapper<string_type, T0, T1>::PropertyBaseT> expat_wrapper<string_type, T0, T1>::doGetProperty(const string_type& name)
{
if(name == properties_.lexicalHandler)
{
getLexicalHandlerT* prop = new getLexicalHandlerT(lexicalHandler_);
return std::auto_ptr<PropertyBaseT>(prop);
}
if(name == properties_.declHandler)
{
getDeclHandlerT* prop = new getDeclHandlerT(declHandler_);
return std::auto_ptr<PropertyBaseT>(prop);
}
throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + SA::asStdString(name));
} // doGetProperty
template<class string_type, class T0, class T1>
void expat_wrapper<string_type, T0, T1>::doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value)
{
if(name == properties_.lexicalHandler)
{
setLexicalHandlerT* prop = dynamic_cast<setLexicalHandlerT*>(value.get());
if(!prop)
throw std::bad_cast();
lexicalHandler_ = &(prop->get());
}
else if(name == properties_.declHandler)
{
setDeclHandlerT* prop = dynamic_cast<setDeclHandlerT*>(value.get());
if(!prop)
throw std::bad_cast();
declHandler_ = &(prop->get());
}
else
{
std::ostringstream os;
os << "Property not recognized " << SA::asStdString(name);
throw SAX::SAXNotRecognizedException(os.str());
}
} // doSetProperty
// Locator implementation
template<class string_type, class T0, class T1>
string_type expat_wrapper<string_type, T0, T1>::getPublicId() const

View file

@ -17,7 +17,6 @@
#include <typeinfo>
#include <SAX/helpers/FeatureNames.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <SAX/helpers/NamespaceSupport.hpp>
#include <SAX/helpers/AttributeDefaults.hpp>
#include <SAX/helpers/AttributeTypes.hpp>
@ -145,11 +144,6 @@ class libxml2_wrapper :
typedef SAX::NamespaceSupport<string_type, string_adaptor> namespaceSupportT;
typedef SAX::ErrorHandler<string_type, string_adaptor> errorHandlerT;
typedef SAX::SAXParseException<string_type, string_adaptor> SAXParseExceptionT;
typedef typename XMLReaderT::PropertyBase PropertyBaseT;
typedef typename XMLReaderT::template Property<lexicalHandlerT*> getLexicalHandlerT;
typedef typename XMLReaderT::template Property<lexicalHandlerT&> setLexicalHandlerT;
typedef typename XMLReaderT::template Property<declHandlerT*> getDeclHandlerT;
typedef typename XMLReaderT::template Property<declHandlerT&> setDeclHandlerT;
typedef XML::QualifiedName<string_type, string_adaptor> qualifiedNameT;
libxml2_wrapper();
@ -179,12 +173,6 @@ class libxml2_wrapper :
// parsing
virtual void parse(inputSourceT& source);
protected:
////////////////////////////////////////////////
// properties
virtual std::auto_ptr<PropertyBaseT> doGetProperty(const string_type& name);
virtual void doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value);
public:
virtual string_type getPublicId() const;
virtual string_type getSystemId() const;
@ -245,7 +233,6 @@ class libxml2_wrapper :
string_type emptyString_;
const FeatureNames<string_type, string_adaptor> features_;
const PropertyNames<string_type, string_adaptor> properties_;
const NamespaceConstants<string_type, string_adaptor> nsc_;
const AttributeDefaults<string_type, string_adaptor> attrDefaults_;
const AttributeTypes<string_type, string_adaptor> attrTypes_;
@ -354,48 +341,6 @@ void libxml2_wrapper<string_type, T0, T1>::setFeature(const string_type& name, b
}
} // setFeature
template<class string_type, class T0, class T1>
std::auto_ptr<typename libxml2_wrapper<string_type, T0, T1>::PropertyBaseT> libxml2_wrapper<string_type, T0, T1>::doGetProperty(const string_type& name)
{
if(name == properties_.declHandler)
{
getDeclHandlerT* prop = new getDeclHandlerT(declHandler_);
return std::auto_ptr<PropertyBaseT>(prop);
}
if(name == properties_.lexicalHandler)
{
getLexicalHandlerT* prop = new getLexicalHandlerT(lexicalHandler_);
return std::auto_ptr<PropertyBaseT>(prop);
}
throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + string_adaptor::asStdString(name));
} // doGetProperty
template<class string_type, class T0, class T1>
void libxml2_wrapper<string_type, T0, T1>::doSetProperty(const string_type& name, std::auto_ptr<PropertyBaseT> value)
{
if(name == properties_.declHandler)
{
setDeclHandlerT* prop = dynamic_cast<setDeclHandlerT*>(value.get());
if(!prop)
throw std::bad_cast();
declHandler_ = &(prop->get());
}
if(name == properties_.lexicalHandler)
{
setLexicalHandlerT* prop = dynamic_cast<setLexicalHandlerT*>(value.get());
if(!prop)
throw std::bad_cast();
lexicalHandler_ = &(prop->get());
}
throw SAX::SAXNotRecognizedException(std::string("Property not recognized ") + string_adaptor::asStdString(name));
} // doSetProperty
template<class string_type, class T0, class T1>
typename XML::QualifiedName<string_type, typename libxml2_wrapper<string_type, T0, T1>::string_adaptor> libxml2_wrapper<string_type, T0, T1>::processName(const string_type& qName, bool isAttribute)
{

View file

@ -10,7 +10,6 @@
#include <SAX/SAXParseException.hpp>
#include <SAX/SAXNotRecognizedException.hpp>
#include <SAX/SAXNotSupportedException.hpp>
#include <SAX/helpers/PropertyNames.hpp>
#include <Arabica/StringAdaptor.hpp>
#include <iostream>
#include <Arabica/getparam.hpp>
@ -118,48 +117,7 @@ class msxml2_wrapper :
// Parsing
virtual void parse(inputSourceT& input);
protected:
virtual std::auto_ptr<typename XMLReaderT::PropertyBase> doGetProperty(const string_type& name)
{
if(name == properties_.lexicalHandler)
{
Property<lexicalHandlerT*>* prop = new Property<lexicalHandlerT*>(lexicalHandler_.getLexicalHandler());
return std::auto_ptr<XMLReaderT::PropertyBase>(prop);
}
if(name == properties_.declHandler)
{
Property<declHandlerT*>* prop = new Property<declHandlerT*>(declHandler_.getDeclHandler());
return std::auto_ptr<XMLReaderT::PropertyBase>(prop);
}
throw SAX::SAXNotRecognizedException("Property not recognized ");
} // doGetProperty
virtual void doSetProperty(const string_type& name, std::auto_ptr<typename XMLReaderT::PropertyBase> value)
{
if(name == properties_.lexicalHandler)
{
Property<lexicalHandlerT&>* prop = dynamic_cast<Property<lexicalHandlerT&>*>(value.get());
if(!prop)
throw std::runtime_error("bad_cast: Property LexicalHandler is wrong type, should be SAX::LexicalHandler&");
lexicalHandler_.setLexicalHandler(prop->get());
return;
} // if ...
if(name == properties_.declHandler)
{
Property<declHandlerT&>* prop = dynamic_cast<Property<declHandlerT&>*>(value.get());
if(!prop)
throw std::runtime_error("bad_cast: Property DeclHandler is wrong type, should be SAX::DeclHandler&");
declHandler_.setDeclHandler(prop->get());
return;
} // if ...
throw SAX::SAXNotRecognizedException("Property not recognized ");
} // doSetProperty
private:
private:
//////////////////////////////////////////////////////
// COM interface -> C++ interface adaptors
class LocatorAdaptor : public locatorT
@ -995,7 +953,6 @@ class msxml2_wrapper :
DeclHandlerAdaptor declHandler_;
ISAXXMLReaderPtr reader_;
SAX::PropertyNames<string_type, string_adaptor> properties_;
}; // class msxml
template<class string_type, class T0, class T1>
@ -1006,8 +963,7 @@ msxml2_wrapper<string_type, T0, T1>::msxml2_wrapper() :
contentHandler_(errorHandler_),
lexicalHandler_(),
declHandler_(),
reader_(),
properties_()
reader_()
{
reader_.CreateInstance("Msxml2.SAXXMLReader.6.0");
if(reader_.GetInterfacePtr() == 0)

View file

@ -4,35 +4,6 @@
// A SAX2 wrapper class for Xerces.
//---------------------------------------------------------------------------
// Debugging code for the doSetProperty and doGetProperty methods.
// Since these methods use runtime casting, it is often helpful to
// know the exact type of a method's arguments to compare with
// what is expected. This is hard, even with current (2003)
// debuggers, so this code can print it out, assuming you've
// compiled with gcc 3.2
//
// Example usage is given in doSetProperty
// Use only with GCC 3.2
#ifdef SAXXERCES_DEBUG
#include <iostream>
#include <typeinfo>
#include <cxxabi.h>
// Demangle Run-Time Type Information std::type_info struct.
std::ostream& operator<<(std::ostream& o, const std::type_info& ti)
{
int status;
char *realname = abi::__cxa_demangle(ti.name(), 0, 0, &status);
if (status != 0)
o.setstate(std::ios_base::failbit);
o << realname;
free(realname);
return o;
}
#endif
#include <iterator>
#include <memory>
#include <string>
@ -189,10 +160,6 @@ class xerces_wrapper : public ProgressiveParser<string_type, typename Arabica::g
virtual void parseReset(XMLPScanToken& token);
//@}
protected:
virtual std::auto_ptr<typename XMLReaderT::PropertyBase> doGetProperty(const string_type& name);
virtual void doSetProperty(const string_type& name, std::auto_ptr<typename XMLReaderT::PropertyBase> value);
private:
///////////////////////////////
// String adaptor for XMLCh
@ -282,7 +249,7 @@ class xerces_wrapper : public ProgressiveParser<string_type, typename Arabica::g
return base::construct_from_utf8(reinterpret_cast<const char*>(bytes), length);
} // construct_from_XMLByte
static std::auto_ptr<XERCES_CPP_NAMESPACE::XMLTranscoder> transcoder_;
static std::unique_ptr<XERCES_CPP_NAMESPACE::XMLTranscoder> transcoder_;
static void kickoff()
{
XERCES_CPP_NAMESPACE::XMLTransService::Codes res;
@ -841,7 +808,7 @@ class xerces_wrapper : public ProgressiveParser<string_type, typename Arabica::g
/////////////////////////////////////////////
// Member variables
std::auto_ptr<XercesImpl::xerces_initializer> initializer_;
std::unique_ptr<XercesImpl::xerces_initializer> initializer_;
XERCES_CPP_NAMESPACE::SAX2XMLReader* xerces_;
ContentHandlerAdaptor contentHandlerAdaptor_;
EntityResolverAdaptor entityResolverAdaptor_;
@ -858,7 +825,7 @@ class xerces_wrapper : public ProgressiveParser<string_type, typename Arabica::g
#ifdef ARABICA_NO_WCHAR_T
template<class string_type, class T0, class T1>
std::auto_ptr<XERCES_CPP_NAMESPACE::XMLTranscoder> xerces_wrapper<string_type, T0, T1>::xerces_string_adaptor::transcoder_;
std::unique_ptr<XERCES_CPP_NAMESPACE::XMLTranscoder> xerces_wrapper<string_type, T0, T1>::xerces_string_adaptor::transcoder_;
#endif
template<class string_type, class T0, class T1>
@ -866,8 +833,7 @@ xerces_wrapper<string_type, T0, T1>::xerces_wrapper()
{
try
{
std::auto_ptr<XercesImpl::xerces_initializer> init(new XercesImpl::xerces_initializer());
initializer_ = init;
initializer_.reset(new XercesImpl::xerces_initializer());
#ifdef ARABICA_NO_WCHAR_T
xerces_string_adaptor::kickoff();
#endif
@ -933,143 +899,6 @@ void xerces_wrapper<string_type, T0, T1>::setFeature(const string_type& name, bo
} // catch(SAXNotRecognizedException& e)
} // setFeature
template<class string_type, class T0, class T1>
std::auto_ptr<typename xerces_wrapper<string_type, T0, T1>::XMLReaderT::PropertyBase> xerces_wrapper<string_type, T0, T1>::doGetProperty(const string_type& name)
{
if(name == properties_.lexicalHandler)
{
typedef typename XMLReaderT::template Property<LexicalHandlerT *> Prop;
Prop *prop = new Prop(lexicalHandlerAdaptor_.getLexicalHandler());
return std::auto_ptr<typename XMLReaderT::PropertyBase>(prop);
}
if(name == properties_.declHandler)
{
typedef typename XMLReaderT::template Property<DeclHandlerT*> Prop;
Prop* prop = new Prop(declHandlerAdaptor_.getDeclHandler());
return std::auto_ptr<typename XMLReaderT::PropertyBase>(prop);
}
if (name == properties_.externalSchemaLocation)
{
typedef typename XMLReaderT::template Property<string_type&> StringPropertyType;
XMLCh* xercesExternalSchemaLocation =
static_cast<XMLCh*>(xerces_->getProperty(
XERCES_CPP_NAMESPACE::XMLUni::fgXercesSchemaExternalSchemaLocation));
externalSchemaLocation_ = XSA::makeStringT(xercesExternalSchemaLocation);
std::auto_ptr<typename XMLReaderT::PropertyBase> toReturn(new StringPropertyType(externalSchemaLocation_));
#ifdef SAXXERCES_DEBUG
std::cerr << "Returning " << typeid(toReturn)
<< "(*(" << typeid(*toReturn.get()) << ")"
<< toReturn.get() << ")"
<< " containing value [" << externalSchemaLocation_ << "]"
<< std::endl;
#endif
return toReturn;
}
if (name == properties_.externalNoNamespaceSchemaLocation)
{
typedef typename XMLReaderT::template Property<string_type&> StringPropertyType;
XMLCh* xercesExternalNoNamespaceSchemaLocation =
static_cast<XMLCh*>(xerces_->getProperty(
XERCES_CPP_NAMESPACE::XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation));
externalNoNamespaceSchemaLocation_ = XSA::makeStringT(xercesExternalNoNamespaceSchemaLocation);
return std::auto_ptr<typename XMLReaderT::PropertyBase>(new StringPropertyType(externalNoNamespaceSchemaLocation_));
}
throw SAX::SAXNotRecognizedException("Property not recognized ");
} // doGetProperty
template<class string_type, class T0, class T1>
void xerces_wrapper<string_type, T0, T1>::doSetProperty(const string_type& name, std::auto_ptr<typename XMLReaderT::PropertyBase> value)
{
if(name == properties_.lexicalHandler)
{
typedef typename XMLReaderT::template Property<LexicalHandlerT&> Prop;
Prop* prop = dynamic_cast<Prop*>(value.get());
if(!prop)
throw std::runtime_error("bad_cast: Property LexicalHandler is wrong type, should be SAX::LexicalHandler&");
lexicalHandlerAdaptor_.setLexicalHandler(prop->get());
return;
} // if ...
if(name == properties_.declHandler)
{
typedef typename XMLReaderT::template Property<DeclHandlerT&> Prop;
Prop* prop = dynamic_cast<Prop*>(value.get());
if(!prop)
throw std::runtime_error("bad_cast: Property DeclHandler is wrong type, should be SAX::DeclHandler&");
declHandlerAdaptor_.setDeclHandler(prop->get());
return;
} // if ...
if (name == properties_.externalSchemaLocation)
{
typename XMLReaderT::PropertyBase* propBase = value.get();
#ifdef SAXXERCES_DEBUG
std::cerr << "doSetProperty(externalSchemaLocation, &("
<< typeid(*propBase) << "))" << std::endl;
#endif
typedef typename XMLReaderT::template Property<string_type&> propertyType;
propertyType* prop = dynamic_cast<propertyType*>(propBase);
#ifdef SAXXERCES_DEBUG
std::cerr << " Extracted property to " << typeid(prop)
<< "(" << prop << ")" << std::endl;
#endif
if (prop)
{
externalSchemaLocation_ = prop->get();
#ifdef SAXXERCES_DEBUG
std::cerr << " Setting property to " << externalSchemaLocation_ << std::endl;
#endif
xerces_string_janitor<XMLCh> toDelete(XSA::asXMLChString(externalSchemaLocation_));
xerces_->setProperty(XERCES_CPP_NAMESPACE::XMLUni::fgXercesSchemaExternalSchemaLocation, const_cast<XMLCh*>(toDelete.get()));
}
else
{
throw SAXNotSupportedException("Property ExternalShemaLocation is wrong type, should be string_type");
}
return;
}
if (name == properties_.externalNoNamespaceSchemaLocation)
{
typename XMLReaderT::PropertyBase* propBase = value.get();
typedef typename XMLReaderT::template Property<string_type&> propertyType;
#ifdef SAXXERCES_DEBUG
std::cerr << "doSetProperty(externalNoNamespaceSchemaLocation, &("
<< typeid(*propBase) << "))" << std::endl;
#endif
propertyType* prop = dynamic_cast<propertyType*>(propBase);
#ifdef SAXXERCES_DEBUG
std::cerr << " Extracted property to " << typeid(prop)
<< "(" << prop << ")" << std::endl;
#endif
if (prop)
{
externalNoNamespaceSchemaLocation_ = prop->get();
#ifdef SAXXERCES_DEBUG
std::cerr << " Setting property to " << externalNoNamespaceSchemaLocation_ << std::endl;
#endif
xerces_string_janitor<XMLCh> toDelete(XSA::asXMLChString(externalNoNamespaceSchemaLocation_));
xerces_->setProperty(XERCES_CPP_NAMESPACE::XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, const_cast<XMLCh*>(toDelete.get()));
}
else
{
throw SAXNotSupportedException("Property ExternalNoNamespaceSchemaLocation is wrong type, should be string_type");
}
return;
}
throw SAX::SAXNotRecognizedException("Property not recognized ");
}
template<class string_type, class T0, class T1>
void xerces_wrapper<string_type, T0, T1>::parse(InputSourceT& source)
{
@ -1089,7 +918,7 @@ bool xerces_wrapper<string_type,
T0, T1>::parseFirst(InputSourceT& input,
XMLPScanToken& toFill)
{
std::auto_ptr<XercesXMLPScanToken> newToken(new XercesXMLPScanToken);
auto newToken = std::make_unique<XercesXMLPScanToken>();
// To store the result from Xerces parseFirst().
bool result = false;
if (input.getByteStream() == 0)
@ -1110,9 +939,9 @@ bool xerces_wrapper<string_type,
result = xerces_->parseFirst(isAdaptor, newToken->token_);
}
if (result) {
// We need to explicitly convert to auto_ptr<base class>.
std::auto_ptr<XMLPScanTokenParserImpl> toSet(newToken.release());
toFill.setParserData(toSet);
// We need to explicitly convert to unique_ptr<base class>.
std::unique_ptr<XMLPScanTokenParserImpl> toSet(newToken.release());
toFill.setParserData(std::move(toSet));
}
return result;
} // parseFirst

View file

@ -396,90 +396,7 @@ public:
CDATAElements = value;
} // setFeature
typedef typename XMLReaderInterface<string_type, string_adaptor_type>::PropertyBase PropertyBaseT;
virtual std::auto_ptr<PropertyBaseT> doGetProperty(const string_type& /*name*/)
{
return std::auto_ptr<PropertyBaseT>(0);
} // doGetProperty
virtual void doSetProperty(const string_type& /*name*/, std::auto_ptr<PropertyBaseT> /*value*/)
{
} // doSetProperty
/*
Object getProperty (std::string name)
{
if(name.equals(lexicalHandlerProperty))
{
return lexicalHandler_ == this ? null : lexicalHandler_;
}
else if(name.equals(scannerProperty))
{
return scanner_;
}
else if(name.equals(schemaProperty))
{
return schema_;
}
else if(name.equals(autoDetectorProperty))
{
return theAutoDetector;
}
else
{
throw new SAXNotRecognizedException("Unknown property " + name);
}
} // getProperty
void setProperty (std::string name, Object value)
{
if(name.equals(lexicalHandlerProperty))
{
if(value == null)
{
lexicalHandler_ = this;
}
else if(value instanceof LexicalHandler)
{
lexicalHandler_ = (LexicalHandler)value;
}
else
{
throw new SAXNotSupportedException("Your lexical handler is not a LexicalHandler");
}
}
else if(name.equals(scannerProperty))
{
if(value instanceof Scanner) {
scanner_ = (Scanner)value;
}
else {
throw new SAXNotSupportedException("Your scanner is not a Scanner");
}
}
else if(name.equals(schemaProperty)) {
if(value instanceof Schema) {
schema_ = (Schema)value;
}
else {
throw new SAXNotSupportedException("Your schema is not a Schema");
}
}
else if(name.equals(autoDetectorProperty)) {
if(value instanceof AutoDetector) {
theAutoDetector = (AutoDetector)value;
}
else {
throw new SAXNotSupportedException("Your auto-detector is not an AutoDetector");
}
}
else {
throw new SAXNotRecognizedException("Unknown property " + name);
}
}
*/
virtual void setEntityResolver(EntityResolverT& resolver)
virtual void setEntityResolver(EntityResolverT& resolver)
{
entityResolver_ = &resolver;
} // setEntityResolver

View file

@ -219,8 +219,8 @@ public:
Axis axis,
bool is_attr = false)
{
std::auto_ptr<NodeTest<string_type, string_adaptor> > test(getTest(node, end, !is_attr ? axis : ATTRIBUTE, context.namespaceContext()));
std::auto_ptr<XPathExpression_impl<string_type, string_adaptor> > thing;
std::unique_ptr<NodeTest<string_type, string_adaptor> > test(getTest(node, end, !is_attr ? axis : ATTRIBUTE, context.namespaceContext()));
std::unique_ptr<XPathExpression_impl<string_type, string_adaptor> > thing;
if(test.get() == 0)
thing.reset(XPath<string_type, string_adaptor>::compile_expression(node++, end, context));
@ -489,14 +489,14 @@ public:
const ExecutionContext<string_type, string_adaptor>& executionContext) const
{
NodeSet<string_type, string_adaptor> ns;
NodeSet<string_type, string_adaptor> nodes = expr_->evaluate(context, executionContext).asNodeSet();
for(typename NodeSet<string_type, string_adaptor>::const_iterator n = nodes.begin(), ne = nodes.end(); n != ne; ++n)
if(context == *n)
{
ns.push_back(context);
break;
} // if ...
NodeSet<string_type, string_adaptor> nodes = expr_->evaluate(context, executionContext).asNodeSet();
for(typename NodeSet<string_type, string_adaptor>::const_iterator n = nodes.begin(), ne = nodes.end(); n != ne; ++n)
if(context == *n)
{
ns.push_back(context);
break;
} // if ...
return XPathValue<string_type, string_adaptor>(new NodeSetValue<string_type, string_adaptor>(ns));
} // evaluate

View file

@ -227,11 +227,11 @@ public:
{
} // ~StylesheetCompiler
std::auto_ptr<Stylesheet<string_type, string_adaptor> > compile(InputSourceT& source)
std::unique_ptr<Stylesheet<string_type, string_adaptor> > compile(InputSourceT& source)
{
error_ = "";
std::auto_ptr<CompiledStylesheet<string_type, string_adaptor> > stylesheet(new CompiledStylesheet<string_type, string_adaptor>());
auto stylesheet = std::make_unique<CompiledStylesheet<string_type, string_adaptor>>();
StylesheetParser<string_type, string_adaptor> parser;
CompilationContext<string_type, string_adaptor> context(parser, *stylesheet.get());
@ -252,7 +252,7 @@ public:
stylesheet.reset();
} // catch
return std::auto_ptr<Stylesheet<string_type, string_adaptor> >(stylesheet.release());
return std::unique_ptr<Stylesheet<string_type, string_adaptor> >(stylesheet.release());
} // compile
const std::string& error() const

951
m4/ax_cxx_compile_stdcxx.m4 Normal file
View file

@ -0,0 +1,951 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the specified
# version of the C++ standard. If necessary, add switches to CXX and
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
# or '14' (for the C++14 standard).
#
# The second argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
# preference for an extended mode.
#
# The third argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline support for the specified C++ standard is
# required and that the macro should error out if no mode with that
# support is found. If specified 'optional', then configuration proceeds
# regardless, after defining HAVE_CXX${VERSION} if and only if a
# supporting mode is found.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
# Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
# Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 11
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).
AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
[$2], [noext], [],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
[$3], [optional], [ax_cxx_compile_cxx$1_required=false],
[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
AC_LANG_PUSH([C++])dnl
ac_success=no
m4_if([$2], [noext], [], [dnl
if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do
switch="-std=gnu++${alternative}"
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXX="$CXX $switch"
if test -n "$CXXCPP" ; then
CXXCPP="$CXXCPP $switch"
fi
ac_success=yes
break
fi
done
fi])
m4_if([$2], [ext], [], [dnl
if test x$ac_success = xno; then
dnl HP's aCC needs +std=c++11 according to:
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
dnl Cray's crayCC needs "-h std=c++11"
for alternative in ${ax_cxx_compile_alternatives}; do
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
CXX="$CXX $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXX="$ac_save_CXX"])
if eval test x\$$cachevar = xyes; then
CXX="$CXX $switch"
if test -n "$CXXCPP" ; then
CXXCPP="$CXXCPP $switch"
fi
ac_success=yes
break
fi
done
if test x$ac_success = xyes; then
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx$1_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
fi
fi
if test x$ac_success = xno; then
HAVE_CXX$1=0
AC_MSG_NOTICE([No compiler with C++$1 support was found])
else
HAVE_CXX$1=1
AC_DEFINE(HAVE_CXX$1,1,
[define if the compiler supports basic C++$1 syntax])
fi
AC_SUBST(HAVE_CXX$1)
])
dnl Test body for checking C++11 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
)
dnl Test body for checking C++14 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
)
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
)
dnl Tests for new features in C++11
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
// If the compiler admits that it is not ready for C++11, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201103L
#error "This is not a C++11 compiler"
#else
namespace cxx11
{
namespace test_static_assert
{
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
}
namespace test_final_override
{
struct Base
{
virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
virtual ~Derived() override {}
virtual void f() override {}
};
}
namespace test_double_right_angle_brackets
{
template < typename T >
struct check {};
typedef check<void> single_type;
typedef check<check<void>> double_type;
typedef check<check<check<void>>> triple_type;
typedef check<check<check<check<void>>>> quadruple_type;
}
namespace test_decltype
{
int
f()
{
int a = 1;
decltype(a) b = 2;
return a + b;
}
}
namespace test_type_deduction
{
template < typename T1, typename T2 >
struct is_same
{
static const bool value = false;
};
template < typename T >
struct is_same<T, T>
{
static const bool value = true;
};
template < typename T1, typename T2 >
auto
add(T1 a1, T2 a2) -> decltype(a1 + a2)
{
return a1 + a2;
}
int
test(const int c, volatile int v)
{
static_assert(is_same<int, decltype(0)>::value == true, "");
static_assert(is_same<int, decltype(c)>::value == false, "");
static_assert(is_same<int, decltype(v)>::value == false, "");
auto ac = c;
auto av = v;
auto sumi = ac + av + 'x';
auto sumf = ac + av + 1.0;
static_assert(is_same<int, decltype(ac)>::value == true, "");
static_assert(is_same<int, decltype(av)>::value == true, "");
static_assert(is_same<int, decltype(sumi)>::value == true, "");
static_assert(is_same<int, decltype(sumf)>::value == false, "");
static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
return (sumf > 0.0) ? sumi : add(c, v);
}
}
namespace test_noexcept
{
int f() { return 0; }
int g() noexcept { return 0; }
static_assert(noexcept(f()) == false, "");
static_assert(noexcept(g()) == true, "");
}
namespace test_constexpr
{
template < typename CharT >
unsigned long constexpr
strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
{
return *s ? strlen_c_r(s + 1, acc + 1) : acc;
}
template < typename CharT >
unsigned long constexpr
strlen_c(const CharT *const s) noexcept
{
return strlen_c_r(s, 0UL);
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("1") == 1UL, "");
static_assert(strlen_c("example") == 7UL, "");
static_assert(strlen_c("another\0example") == 7UL, "");
}
namespace test_rvalue_references
{
template < int N >
struct answer
{
static constexpr int value = N;
};
answer<1> f(int&) { return answer<1>(); }
answer<2> f(const int&) { return answer<2>(); }
answer<3> f(int&&) { return answer<3>(); }
void
test()
{
int i = 0;
const int c = 0;
static_assert(decltype(f(i))::value == 1, "");
static_assert(decltype(f(c))::value == 2, "");
static_assert(decltype(f(0))::value == 3, "");
}
}
namespace test_uniform_initialization
{
struct test
{
static const int zero {};
static const int one {1};
};
static_assert(test::zero == 0, "");
static_assert(test::one == 1, "");
}
namespace test_lambdas
{
void
test1()
{
auto lambda1 = [](){};
auto lambda2 = lambda1;
lambda1();
lambda2();
}
int
test2()
{
auto a = [](int i, int j){ return i + j; }(1, 2);
auto b = []() -> int { return '0'; }();
auto c = [=](){ return a + b; }();
auto d = [&](){ return c; }();
auto e = [a, &b](int x) mutable {
const auto identity = [](int y){ return y; };
for (auto i = 0; i < a; ++i)
a += b--;
return x + identity(a + b);
}(0);
return a + b + c + d + e;
}
int
test3()
{
const auto nullary = [](){ return 0; };
const auto unary = [](int x){ return x; };
using nullary_t = decltype(nullary);
using unary_t = decltype(unary);
const auto higher1st = [](nullary_t f){ return f(); };
const auto higher2nd = [unary](nullary_t f1){
return [unary, f1](unary_t f2){ return f2(unary(f1())); };
};
return higher1st(nullary) + higher2nd(nullary)(unary);
}
}
namespace test_variadic_templates
{
template <int...>
struct sum;
template <int N0, int... N1toN>
struct sum<N0, N1toN...>
{
static constexpr auto value = N0 + sum<N1toN...>::value;
};
template <>
struct sum<>
{
static constexpr auto value = 0;
};
static_assert(sum<>::value == 0, "");
static_assert(sum<1>::value == 1, "");
static_assert(sum<23>::value == 23, "");
static_assert(sum<1, 2>::value == 3, "");
static_assert(sum<5, 5, 11>::value == 21, "");
static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
}
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
// because of this.
namespace test_template_alias_sfinae
{
struct foo {};
template<typename T>
using member = typename T::member_type;
template<typename T>
void func(...) {}
template<typename T>
void func(member<T>*) {}
void test();
void test() { func<foo>(0); }
}
} // namespace cxx11
#endif // __cplusplus >= 201103L
]])
dnl Tests for new features in C++14
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
// If the compiler admits that it is not ready for C++14, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201402L
#error "This is not a C++14 compiler"
#else
namespace cxx14
{
namespace test_polymorphic_lambdas
{
int
test()
{
const auto lambda = [](auto&&... args){
const auto istiny = [](auto x){
return (sizeof(x) == 1UL) ? 1 : 0;
};
const int aretiny[] = { istiny(args)... };
return aretiny[0];
};
return lambda(1, 1L, 1.0f, '1');
}
}
namespace test_binary_literals
{
constexpr auto ivii = 0b0000000000101010;
static_assert(ivii == 42, "wrong value");
}
namespace test_generalized_constexpr
{
template < typename CharT >
constexpr unsigned long
strlen_c(const CharT *const s) noexcept
{
auto length = 0UL;
for (auto p = s; *p; ++p)
++length;
return length;
}
static_assert(strlen_c("") == 0UL, "");
static_assert(strlen_c("x") == 1UL, "");
static_assert(strlen_c("test") == 4UL, "");
static_assert(strlen_c("another\0test") == 7UL, "");
}
namespace test_lambda_init_capture
{
int
test()
{
auto x = 0;
const auto lambda1 = [a = x](int b){ return a + b; };
const auto lambda2 = [a = lambda1(x)](){ return a; };
return lambda2();
}
}
namespace test_digit_separators
{
constexpr auto ten_million = 100'000'000;
static_assert(ten_million == 100000000, "");
}
namespace test_return_type_deduction
{
auto f(int& x) { return x; }
decltype(auto) g(int& x) { return x; }
template < typename T1, typename T2 >
struct is_same
{
static constexpr auto value = false;
};
template < typename T >
struct is_same<T, T>
{
static constexpr auto value = true;
};
int
test()
{
auto x = 0;
static_assert(is_same<int, decltype(f(x))>::value, "");
static_assert(is_same<int&, decltype(g(x))>::value, "");
return x;
}
}
} // namespace cxx14
#endif // __cplusplus >= 201402L
]])
dnl Tests for new features in C++17
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
// If the compiler admits that it is not ready for C++17, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201703L
#error "This is not a C++17 compiler"
#else
#include <initializer_list>
#include <utility>
#include <type_traits>
namespace cxx17
{
namespace test_constexpr_lambdas
{
constexpr int foo = [](){return 42;}();
}
namespace test::nested_namespace::definitions
{
}
namespace test_fold_expression
{
template<typename... Args>
int multiply(Args... args)
{
return (args * ... * 1);
}
template<typename... Args>
bool all(Args... args)
{
return (args && ...);
}
}
namespace test_extended_static_assert
{
static_assert (true);
}
namespace test_auto_brace_init_list
{
auto foo = {5};
auto bar {5};
static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
static_assert(std::is_same<int, decltype(bar)>::value);
}
namespace test_typename_in_template_template_parameter
{
template<template<typename> typename X> struct D;
}
namespace test_fallthrough_nodiscard_maybe_unused_attributes
{
int f1()
{
return 42;
}
[[nodiscard]] int f2()
{
[[maybe_unused]] auto unused = f1();
switch (f1())
{
case 17:
f1();
[[fallthrough]];
case 42:
f1();
}
return f1();
}
}
namespace test_extended_aggregate_initialization
{
struct base1
{
int b1, b2 = 42;
};
struct base2
{
base2() {
b3 = 42;
}
int b3;
};
struct derived : base1, base2
{
int d;
};
derived d1 {{1, 2}, {}, 4}; // full initialization
derived d2 {{}, {}, 4}; // value-initialized bases
}
namespace test_general_range_based_for_loop
{
struct iter
{
int i;
int& operator* ()
{
return i;
}
const int& operator* () const
{
return i;
}
iter& operator++()
{
++i;
return *this;
}
};
struct sentinel
{
int i;
};
bool operator== (const iter& i, const sentinel& s)
{
return i.i == s.i;
}
bool operator!= (const iter& i, const sentinel& s)
{
return !(i == s);
}
struct range
{
iter begin() const
{
return {0};
}
sentinel end() const
{
return {5};
}
};
void f()
{
range r {};
for (auto i : r)
{
[[maybe_unused]] auto v = i;
}
}
}
namespace test_lambda_capture_asterisk_this_by_value
{
struct t
{
int i;
int foo()
{
return [*this]()
{
return i;
}();
}
};
}
namespace test_enum_class_construction
{
enum class byte : unsigned char
{};
byte foo {42};
}
namespace test_constexpr_if
{
template <bool cond>
int f ()
{
if constexpr(cond)
{
return 13;
}
else
{
return 42;
}
}
}
namespace test_selection_statement_with_initializer
{
int f()
{
return 13;
}
int f2()
{
if (auto i = f(); i > 0)
{
return 3;
}
switch (auto i = f(); i + 4)
{
case 17:
return 2;
default:
return 1;
}
}
}
namespace test_template_argument_deduction_for_class_templates
{
template <typename T1, typename T2>
struct pair
{
pair (T1 p1, T2 p2)
: m1 {p1},
m2 {p2}
{}
T1 m1;
T2 m2;
};
void f()
{
[[maybe_unused]] auto p = pair{13, 42u};
}
}
namespace test_non_type_auto_template_parameters
{
template <auto n>
struct B
{};
B<5> b1;
B<'a'> b2;
}
namespace test_structured_bindings
{
int arr[2] = { 1, 2 };
std::pair<int, int> pr = { 1, 2 };
auto f1() -> int(&)[2]
{
return arr;
}
auto f2() -> std::pair<int, int>&
{
return pr;
}
struct S
{
int x1 : 2;
volatile double y1;
};
S f3()
{
return {};
}
auto [ x1, y1 ] = f1();
auto& [ xr1, yr1 ] = f1();
auto [ x2, y2 ] = f2();
auto& [ xr2, yr2 ] = f2();
const auto [ x3, y3 ] = f3();
}
namespace test_exception_spec_type_system
{
struct Good {};
struct Bad {};
void g1() noexcept;
void g2();
template<typename T>
Bad
f(T*, T*);
template<typename T1, typename T2>
Good
f(T1*, T2*);
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
}
namespace test_inline_variables
{
template<class T> void f(T)
{}
template<class T> inline T g(T)
{
return T{};
}
template<> inline void f<>(int)
{}
template<> int g<>(int)
{
return 5;
}
}
} // namespace cxx17
#endif // __cplusplus < 201703L
]])

View file

@ -56,16 +56,16 @@ public:
protected:
void runTest ()
{ (m_fixture.get ()->*m_test)(); }
{ (m_fixture.get ()->*m_test)(); }
void setUp ()
{ m_fixture.get ()->setUp (); }
{ m_fixture->setUp (); }
void tearDown ()
{ m_fixture.get ()->tearDown (); }
{ m_fixture->tearDown (); }
private:
std::auto_ptr<Fixture> m_fixture;
std::unique_ptr<Fixture> m_fixture;
TestMethod m_test;
};

View file

@ -125,11 +125,11 @@ class WhitespaceStripperTest : public TestCase
} // testStrip
private:
std::auto_ptr<Arabica::SAX::InputSource<std::string> > source(const std::string& str)
std::unique_ptr<Arabica::SAX::InputSource<std::string> > source(const std::string& str)
{
std::auto_ptr<std::iostream> ss(new std::stringstream());
std::unique_ptr<std::iostream> ss(new std::stringstream());
(*ss) << str;
return std::auto_ptr<Arabica::SAX::InputSource<std::string> >(new Arabica::SAX::InputSource<std::string>(ss));
return std::make_unique<Arabica::SAX::InputSource<std::string>>(std::move(ss));
} // source
}; // WhitespaceStripperTest

View file

@ -35,11 +35,11 @@ class TaggleTest : public TestCase
} // senseTest
private:
std::auto_ptr<Arabica::SAX::InputSource<std::string> > source(const std::string& str)
std::unique_ptr<Arabica::SAX::InputSource<std::string> > source(const std::string& str)
{
std::auto_ptr<std::iostream> ss(new std::stringstream());
std::unique_ptr<std::iostream> ss(new std::stringstream());
(*ss) << str;
return std::auto_ptr<Arabica::SAX::InputSource<std::string> >(new Arabica::SAX::InputSource<std::string>(ss));
return std::make_unique<Arabica::SAX::InputSource<std::string>>(std::move(ss));
} // source
}; // TaggleTest

View file

@ -177,7 +177,7 @@ protected:
Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler;
Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_));
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() != 0)
assertImplementation(false, "Expected " + input_xslt_ + " not to compile. But it did :o");
throw SkipException(reason_ + " : " + compiler.error());
@ -209,7 +209,7 @@ protected:
Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler;
Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_));
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0)
assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error());
@ -255,7 +255,7 @@ protected:
string_type input = string_adaptor::construct(input_xslt_);
Arabica::SAX::InputSource<string_type, string_adaptor> source(input);
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0)
return;
@ -301,7 +301,7 @@ protected:
Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler;
Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_));
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0)
assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error());
@ -397,7 +397,7 @@ protected:
Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler;
Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_));
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0)
assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error());
@ -498,7 +498,7 @@ protected:
Arabica::XSLT::StylesheetCompiler<string_type, string_adaptor> compiler;
Arabica::SAX::InputSource<string_type, string_adaptor> source(string_adaptor::construct(input_xslt_));
std::auto_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
std::unique_ptr<Arabica::XSLT::Stylesheet<string_type, string_adaptor> > stylesheet = compiler.compile(source);
if(stylesheet.get() == 0)
assertImplementation(false, "Failed to compile " + input_xslt_ + " : " + compiler.error());

View file

@ -151,8 +151,6 @@
<ClInclude Include="..\include\Sax\helpers\InputSourceResolver.hpp" />
<ClInclude Include="..\include\Sax\helpers\LocatorImpl.hpp" />
<ClInclude Include="..\include\Sax\helpers\NamespaceSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\ParserAdaptor.hpp" />
<ClInclude Include="..\include\Sax\helpers\PropertyNames.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLBaseSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLFilterImpl.hpp" />
<ClInclude Include="..\include\Sax\parsers\saxgarden.hpp" />
@ -384,4 +382,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View file

@ -153,8 +153,6 @@
<ClInclude Include="..\include\Sax\helpers\InputSourceResolver.hpp" />
<ClInclude Include="..\include\Sax\helpers\LocatorImpl.hpp" />
<ClInclude Include="..\include\Sax\helpers\NamespaceSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\ParserAdaptor.hpp" />
<ClInclude Include="..\include\Sax\helpers\PropertyNames.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLBaseSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLFilterImpl.hpp" />
<ClInclude Include="..\include\Sax\parsers\saxgarden.hpp" />
@ -386,4 +384,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View file

@ -154,8 +154,6 @@
<ClInclude Include="..\include\Sax\helpers\InputSourceResolver.hpp" />
<ClInclude Include="..\include\Sax\helpers\LocatorImpl.hpp" />
<ClInclude Include="..\include\Sax\helpers\NamespaceSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\ParserAdaptor.hpp" />
<ClInclude Include="..\include\Sax\helpers\PropertyNames.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLBaseSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLFilterImpl.hpp" />
<ClInclude Include="..\include\Sax\parsers\saxgarden.hpp" />

View file

@ -154,8 +154,6 @@
<ClInclude Include="..\include\Sax\helpers\InputSourceResolver.hpp" />
<ClInclude Include="..\include\Sax\helpers\LocatorImpl.hpp" />
<ClInclude Include="..\include\Sax\helpers\NamespaceSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\ParserAdaptor.hpp" />
<ClInclude Include="..\include\Sax\helpers\PropertyNames.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLBaseSupport.hpp" />
<ClInclude Include="..\include\Sax\helpers\XMLFilterImpl.hpp" />
<ClInclude Include="..\include\Sax\parsers\saxgarden.hpp" />

View file

@ -354,14 +354,6 @@
RelativePath="..\include\Sax\helpers\NamespaceSupport.hpp"
>
</File>
<File
RelativePath="..\include\Sax\helpers\ParserAdaptor.hpp"
>
</File>
<File
RelativePath="..\include\Sax\helpers\PropertyNames.hpp"
>
</File>
<File
RelativePath="..\include\Sax\helpers\XMLBaseSupport.hpp"
>

View file

@ -354,14 +354,6 @@
RelativePath="..\include\Sax\helpers\NamespaceSupport.hpp"
>
</File>
<File
RelativePath="..\include\Sax\helpers\ParserAdaptor.hpp"
>
</File>
<File
RelativePath="..\include\Sax\helpers\PropertyNames.hpp"
>
</File>
<File
RelativePath="..\include\Sax\helpers\XMLBaseSupport.hpp"
>