mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 08:31:43 +02:00
removing old trunk files
This commit is contained in:
@@ -1,160 +0,0 @@
|
||||
//
|
||||
// Name.h
|
||||
//
|
||||
// $Id: //poco/svn/XML/include/Poco/XML/Name.h#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
// Module: Name
|
||||
//
|
||||
// Definition of the Name class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XML_Name_INCLUDED
|
||||
#define XML_Name_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API Name
|
||||
/// An XML element or attribute name, consisting of a
|
||||
/// qualified name, a namespace URI and a local name.
|
||||
{
|
||||
public:
|
||||
Name();
|
||||
/// Creates an empty Name.
|
||||
|
||||
Name(const XMLString& qname);
|
||||
/// Creates a Name from a qualified name only.
|
||||
|
||||
Name(const XMLString& qname, const XMLString& namespaceURI);
|
||||
/// Creates a Name from a qualified name and a namespace URI.
|
||||
/// The local name is extracted from the qualified name.
|
||||
|
||||
Name(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName);
|
||||
/// Creates a Name from a qualified name, a namespace URI and a local name.
|
||||
|
||||
Name(const Name& name);
|
||||
/// Copy constructor.
|
||||
|
||||
~Name();
|
||||
/// Destroys the name.
|
||||
|
||||
Name& operator = (const Name& name);
|
||||
/// Assignment operator.
|
||||
|
||||
void swap(Name& name);
|
||||
/// Swaps the name with another one.
|
||||
|
||||
void assign(const XMLString& qname);
|
||||
/// Assigns a new value to the name.
|
||||
|
||||
void assign(const XMLString& qname, const XMLString& namespaceURI);
|
||||
/// Assigns new values to the name.
|
||||
/// The local name is extracted from the qualified name.
|
||||
|
||||
void assign(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName);
|
||||
/// Assigns new values to the name.
|
||||
|
||||
bool equals(const Name& name) const;
|
||||
/// Returns true if both names are equal.
|
||||
|
||||
bool equals(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName) const;
|
||||
/// Returns true if all the name's components are equal to the given ones.
|
||||
|
||||
bool equalsWeakly(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName) const;
|
||||
/// Returns true if either the qnames are identical or the namespaceURIs and the localNames are identical.
|
||||
|
||||
const XMLString& qname() const;
|
||||
/// Returns the qualified name.
|
||||
|
||||
const XMLString& namespaceURI() const;
|
||||
/// Returns the namespace URI.
|
||||
|
||||
const XMLString& localName() const;
|
||||
/// Returns the local name.
|
||||
|
||||
XMLString prefix() const;
|
||||
/// Returns the namespace prefix.
|
||||
|
||||
static void split(const XMLString& qname, XMLString& prefix, XMLString& localName);
|
||||
/// Splits the given qualified name into its prefix and localName parts.
|
||||
|
||||
static XMLString localName(const XMLString& qname);
|
||||
/// Returns the local name part of the given qualified name.
|
||||
|
||||
static XMLString prefix(const XMLString& qname);
|
||||
/// Returns the prefix part of the given qualified name.
|
||||
|
||||
static const XMLString EMPTY_NAME;
|
||||
|
||||
private:
|
||||
XMLString _qname;
|
||||
XMLString _namespaceURI;
|
||||
XMLString _localName;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const XMLString& Name::qname() const
|
||||
{
|
||||
return _qname;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& Name::namespaceURI() const
|
||||
{
|
||||
return _namespaceURI;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& Name::localName() const
|
||||
{
|
||||
return _localName;
|
||||
}
|
||||
|
||||
|
||||
inline void swap(Name& n1, Name& n2)
|
||||
{
|
||||
n1.swap(n2);
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // XML_Name_INCLUDED
|
@@ -1,96 +0,0 @@
|
||||
//
|
||||
// NamePool.h
|
||||
//
|
||||
// $Id: //poco/svn/XML/include/Poco/XML/NamePool.h#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
// Module: NamePool
|
||||
//
|
||||
// Definition of the NamePool class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XML_NamePool_INCLUDED
|
||||
#define XML_NamePool_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#include "Poco/XML/Name.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class NamePoolItem;
|
||||
|
||||
|
||||
class XML_API NamePool
|
||||
/// A hashtable that stores XML names consisting of an URI, a
|
||||
/// local name and a qualified name.
|
||||
{
|
||||
public:
|
||||
NamePool(unsigned long size = 251);
|
||||
/// Creates a name pool with room for up to size strings.
|
||||
|
||||
const Name& insert(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName);
|
||||
/// Returns a const reference to an Name for the given names.
|
||||
/// Creates the Name if it does not already exist.
|
||||
/// Throws a PoolOverflowException if the name pool is full.
|
||||
|
||||
const Name& insert(const Name& name);
|
||||
/// Returns a const reference to an Name for the given name.
|
||||
/// Creates the Name if it does not already exist.
|
||||
/// Throws a PoolOverflowException if the name pool is full.
|
||||
|
||||
void duplicate();
|
||||
/// Increments the reference count.
|
||||
|
||||
void release();
|
||||
/// Decrements the reference count and deletes the object if the reference count reaches zero.
|
||||
|
||||
protected:
|
||||
unsigned long hash(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName);
|
||||
~NamePool();
|
||||
|
||||
private:
|
||||
NamePool(const NamePool&);
|
||||
NamePool& operator = (const NamePool&);
|
||||
|
||||
NamePoolItem* _pItems;
|
||||
unsigned long _size;
|
||||
int _rc;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // XML_NamePool_INCLUDED
|
@@ -1,137 +0,0 @@
|
||||
//
|
||||
// NamespaceStrategy.h
|
||||
//
|
||||
// $Id: //poco/svn/XML/include/Poco/XML/NamespaceStrategy.h#3 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
// Module: NamespaceStrategy
|
||||
//
|
||||
// Definition of the NamespaceStrategy class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XML_NamespaceStrategy_INCLUDED
|
||||
#define XML_NamespaceStrategy_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#include "Poco/SAX/NamespaceSupport.h"
|
||||
#include "Poco/SAX/AttributesImpl.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class ContentHandler;
|
||||
|
||||
|
||||
class XML_API NamespaceStrategy
|
||||
/// This class is used by ParserEngine to handle the
|
||||
/// startElement, endElement, startPrefixMapping and
|
||||
/// endPrefixMapping events.
|
||||
{
|
||||
public:
|
||||
virtual ~NamespaceStrategy();
|
||||
|
||||
virtual void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler) = 0;
|
||||
/// Translate the arguments as delivered by Expat and
|
||||
/// call the startElement() method of the ContentHandler.
|
||||
|
||||
virtual void endElement(const XMLChar* name, ContentHandler* pContentHandler) = 0;
|
||||
/// Translate the arguments as delivered by Expat and
|
||||
/// call the endElement() method of the ContentHandler.
|
||||
|
||||
protected:
|
||||
static void splitName(const XMLChar* qname, XMLString& uri, XMLString& localName);
|
||||
static void splitName(const XMLChar* qname, XMLString& uri, XMLString& localName, XMLString& prefix);
|
||||
|
||||
static const XMLString NOTHING;
|
||||
};
|
||||
|
||||
|
||||
class XML_API NoNamespacesStrategy: public NamespaceStrategy
|
||||
/// The NamespaceStrategy implementation used if no namespaces
|
||||
/// processing is requested.
|
||||
{
|
||||
public:
|
||||
NoNamespacesStrategy();
|
||||
~NoNamespacesStrategy();
|
||||
|
||||
void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler);
|
||||
void endElement(const XMLChar* name, ContentHandler* pContentHandler);
|
||||
|
||||
private:
|
||||
XMLString _name;
|
||||
AttributesImpl _attrs;
|
||||
};
|
||||
|
||||
|
||||
class XML_API NoNamespacePrefixesStrategy: public NamespaceStrategy
|
||||
/// The NamespaceStrategy implementation used if namespaces
|
||||
/// processing is requested, but prefixes are not reported.
|
||||
{
|
||||
public:
|
||||
NoNamespacePrefixesStrategy();
|
||||
~NoNamespacePrefixesStrategy();
|
||||
|
||||
void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler);
|
||||
void endElement(const XMLChar* name, ContentHandler* pContentHandler);
|
||||
|
||||
private:
|
||||
XMLString _uri;
|
||||
XMLString _local;
|
||||
AttributesImpl _attrs;
|
||||
};
|
||||
|
||||
|
||||
class XML_API NamespacePrefixesStrategy: public NamespaceStrategy
|
||||
/// The NamespaceStrategy implementation used if namespaces
|
||||
/// processing is requested and prefixes are reported.
|
||||
{
|
||||
public:
|
||||
NamespacePrefixesStrategy();
|
||||
~NamespacePrefixesStrategy();
|
||||
|
||||
void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler);
|
||||
void endElement(const XMLChar* name, ContentHandler* pContentHandler);
|
||||
|
||||
private:
|
||||
XMLString _uri;
|
||||
XMLString _local;
|
||||
XMLString _qname;
|
||||
AttributesImpl _attrs;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // XML_NamespaceStrategy_INCLUDED
|
@@ -1,380 +0,0 @@
|
||||
//
|
||||
// ParserEngine.h
|
||||
//
|
||||
// $Id: //poco/svn/XML/include/Poco/XML/ParserEngine.h#3 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
// Module: ParserEngine
|
||||
//
|
||||
// Definition of the ParseEngine class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
#ifndef XML_ParserEngine_INCLUDED
|
||||
#define XML_ParserEngine_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#if defined(POCO_UNBUNDLED)
|
||||
#include <expat.h>
|
||||
#else
|
||||
#include "Poco/XML/expat.h"
|
||||
#endif
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#include "Poco/XML/XMLStream.h"
|
||||
#include "Poco/SAX/Locator.h"
|
||||
#include "Poco/TextEncoding.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class InputSource;
|
||||
class EntityResolver;
|
||||
class DTDHandler;
|
||||
class DeclHandler;
|
||||
class ContentHandler;
|
||||
class LexicalHandler;
|
||||
class ErrorHandler;
|
||||
class NamespaceStrategy;
|
||||
class ContextLocator;
|
||||
|
||||
|
||||
class XML_API ParserEngine: public Locator
|
||||
/// This class provides an object-oriented, stream-based,
|
||||
/// low-level interface to the XML Parser Toolkit (expat).
|
||||
/// It is strongly recommended, that you use the
|
||||
/// SAX parser classes (which are based on this
|
||||
/// class) instead of this class, since they provide
|
||||
/// a standardized, higher-level interface to the parser.
|
||||
{
|
||||
public:
|
||||
ParserEngine();
|
||||
/// Creates the parser engine.
|
||||
|
||||
ParserEngine(const XMLString& encoding);
|
||||
/// Creates the parser engine and passes the encoding
|
||||
/// to the underlying parser.
|
||||
|
||||
~ParserEngine();
|
||||
/// Destroys the parser.
|
||||
|
||||
void setEncoding(const XMLString& encoding);
|
||||
/// Sets the encoding used by expat. The encoding must be
|
||||
/// set before parsing begins, otherwise it will be ignored.
|
||||
|
||||
const XMLString& getEncoding() const;
|
||||
/// Returns the encoding used by expat.
|
||||
|
||||
void addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding);
|
||||
/// Adds an encoding to the parser.
|
||||
|
||||
void setNamespaceStrategy(NamespaceStrategy* pStrategy);
|
||||
/// Sets the NamespaceStrategy used by the parser.
|
||||
/// The parser takes ownership of the strategy object
|
||||
/// and deletes it when it's no longer needed.
|
||||
/// The default is NoNamespacesStrategy.
|
||||
|
||||
NamespaceStrategy* getNamespaceStrategy() const;
|
||||
/// Returns the NamespaceStrategy currently in use.
|
||||
|
||||
void setExpandInternalEntities(bool flag = true);
|
||||
/// Enables/disables expansion of internal entities (enabled by
|
||||
/// default). If entity expansion is disabled, internal entities
|
||||
/// are reported via the default handler.
|
||||
/// Must be set before parsing begins, otherwise it will be
|
||||
/// ignored.
|
||||
|
||||
bool getExpandInternalEntities() const;
|
||||
/// Returns true if internal entities will be expanded automatically,
|
||||
/// which is the default.
|
||||
|
||||
void setExternalGeneralEntities(bool flag = true);
|
||||
/// Enable or disable processing of external general entities.
|
||||
|
||||
bool getExternalGeneralEntities() const;
|
||||
/// Returns true if external general entities will be processed; false otherwise.
|
||||
|
||||
void setExternalParameterEntities(bool flag = true);
|
||||
/// Enable or disable processing of external parameter entities.
|
||||
|
||||
bool getExternalParameterEntities() const;
|
||||
/// Returns true if external parameter entities will be processed; false otherwise.
|
||||
|
||||
void setEntityResolver(EntityResolver* pResolver);
|
||||
/// Allow an application to register an entity resolver.
|
||||
|
||||
EntityResolver* getEntityResolver() const;
|
||||
/// Return the current entity resolver.
|
||||
|
||||
void setDTDHandler(DTDHandler* pDTDHandler);
|
||||
/// Allow an application to register a DTD event handler.
|
||||
|
||||
DTDHandler* getDTDHandler() const;
|
||||
/// Return the current DTD handler.
|
||||
|
||||
void setDeclHandler(DeclHandler* pDeclHandler);
|
||||
/// Allow an application to register a DTD declarations event handler.
|
||||
|
||||
DeclHandler* getDeclHandler() const;
|
||||
/// Return the current DTD declarations handler.
|
||||
|
||||
void setContentHandler(ContentHandler* pContentHandler);
|
||||
/// Allow an application to register a content event handler.
|
||||
|
||||
ContentHandler* getContentHandler() const;
|
||||
/// Return the current content handler.
|
||||
|
||||
void setLexicalHandler(LexicalHandler* pLexicalHandler);
|
||||
/// Allow an application to register a lexical event handler.
|
||||
|
||||
LexicalHandler* getLexicalHandler() const;
|
||||
/// Return the current lexical handler.
|
||||
|
||||
void setErrorHandler(ErrorHandler* pErrorHandler);
|
||||
/// Allow an application to register an error event handler.
|
||||
|
||||
ErrorHandler* getErrorHandler() const;
|
||||
/// Return the current error handler.
|
||||
|
||||
void setEnablePartialReads(bool flag = true);
|
||||
/// Enable or disable partial reads from the input source.
|
||||
///
|
||||
/// This is useful for parsing XML from a socket stream for
|
||||
/// a protocol like XMPP, where basically single elements
|
||||
/// are read one at a time from the input source's stream, and
|
||||
/// following elements depend upon responses sent back to
|
||||
/// the peer.
|
||||
///
|
||||
/// Normally, the parser always reads blocks of PARSE_BUFFER_SIZE
|
||||
/// at a time, and blocks until a complete block has been read (or
|
||||
/// the end of the stream has been reached).
|
||||
/// This allows for efficient parsing of "complete" XML documents,
|
||||
/// but fails in a case such as XMPP, where only XML fragments
|
||||
/// are sent at a time.
|
||||
|
||||
bool getEnablePartialReads() const;
|
||||
/// Returns true if partial reads are enabled (see
|
||||
/// setEnablePartialReads()), false otherwise.
|
||||
|
||||
void parse(InputSource* pInputSource);
|
||||
/// Parse an XML document from the given InputSource.
|
||||
|
||||
void parse(const char* pBuffer, std::size_t size);
|
||||
/// Parses an XML document from the given buffer.
|
||||
|
||||
// Locator
|
||||
XMLString getPublicId() const;
|
||||
/// Return the public identifier for the current document event.
|
||||
|
||||
XMLString getSystemId() const;
|
||||
/// Return the system identifier for the current document event.
|
||||
|
||||
int getLineNumber() const;
|
||||
/// Return the line number where the current document event ends.
|
||||
|
||||
int getColumnNumber() const;
|
||||
/// Return the column number where the current document event ends.
|
||||
|
||||
protected:
|
||||
void init();
|
||||
/// initializes expat
|
||||
|
||||
void parseByteInputStream(XMLByteInputStream& istr);
|
||||
/// Parses an entity from the given stream.
|
||||
|
||||
void parseCharInputStream(XMLCharInputStream& istr);
|
||||
/// Parses an entity from the given stream.
|
||||
|
||||
std::streamsize readBytes(XMLByteInputStream& istr, char* pBuffer, std::streamsize bufferSize);
|
||||
/// Reads at most bufferSize bytes from the given stream into the given buffer.
|
||||
|
||||
std::streamsize readChars(XMLCharInputStream& istr, XMLChar* pBuffer, std::streamsize bufferSize);
|
||||
/// Reads at most bufferSize chars from the given stream into the given buffer.
|
||||
|
||||
void handleError(int errorNo);
|
||||
/// Throws an XMLException with a message corresponding
|
||||
/// to the given Expat error code.
|
||||
|
||||
void parseExternal(XML_Parser extParser, InputSource* pInputSource);
|
||||
/// Parse an XML document from the given InputSource.
|
||||
|
||||
void parseExternalByteInputStream(XML_Parser extParser, XMLByteInputStream& istr);
|
||||
/// Parses an external entity from the given stream, with a separate parser.
|
||||
|
||||
void parseExternalCharInputStream(XML_Parser extParser, XMLCharInputStream& istr);
|
||||
/// Parses an external entity from the given stream, with a separate parser.
|
||||
|
||||
void pushContext(XML_Parser parser, InputSource* pInputSource);
|
||||
/// Pushes a new entry to the context stack.
|
||||
|
||||
void popContext();
|
||||
/// Pops the top-most entry from the context stack.
|
||||
|
||||
void resetContext();
|
||||
/// Resets and clears the context stack.
|
||||
|
||||
const Locator& locator() const;
|
||||
/// Returns a locator denoting the current parse location.
|
||||
|
||||
// expat handler procedures
|
||||
static void handleStartElement(void* userData, const XML_Char* name, const XML_Char** atts);
|
||||
static void handleEndElement(void* userData, const XML_Char* name);
|
||||
static void handleCharacterData(void* userData, const XML_Char* s, int len);
|
||||
static void handleProcessingInstruction(void* userData, const XML_Char* target, const XML_Char* data);
|
||||
static void handleDefault(void* userData, const XML_Char* s, int len);
|
||||
static void handleUnparsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId, const XML_Char* notationName);
|
||||
static void handleNotationDecl(void* userData, const XML_Char* notationName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId);
|
||||
static int handleExternalEntityRef(XML_Parser parser, const XML_Char* openEntityNames, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId);
|
||||
static int handleUnknownEncoding(void* encodingHandlerData, const XML_Char* name, XML_Encoding* info);
|
||||
static void handleComment(void* userData, const XML_Char* data);
|
||||
static void handleStartCdataSection(void* userData);
|
||||
static void handleEndCdataSection(void* userData);
|
||||
static void handleStartNamespaceDecl(void* userData, const XML_Char* prefix, const XML_Char* uri);
|
||||
static void handleEndNamespaceDecl(void* userData, const XML_Char* prefix);
|
||||
static void handleStartDoctypeDecl(void* userData, const XML_Char* doctypeName, const XML_Char *systemId, const XML_Char* publicId, int hasInternalSubset);
|
||||
static void handleEndDoctypeDecl(void* userData);
|
||||
static void handleEntityDecl(void *userData, const XML_Char *entityName, int isParamEntity, const XML_Char *value, int valueLength,
|
||||
const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName);
|
||||
static void handleExternalParsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId);
|
||||
static void handleInternalParsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* replacementText, int replacementTextLength);
|
||||
static void handleSkippedEntity(void* userData, const XML_Char* entityName, int isParameterEntity);
|
||||
|
||||
// encoding support
|
||||
static int convert(void *data, const char *s);
|
||||
|
||||
private:
|
||||
typedef std::map<XMLString, Poco::TextEncoding*> EncodingMap;
|
||||
typedef std::vector<ContextLocator*> ContextStack;
|
||||
|
||||
XML_Parser _parser;
|
||||
char* _pBuffer;
|
||||
bool _encodingSpecified;
|
||||
XMLString _encoding;
|
||||
bool _expandInternalEntities;
|
||||
bool _externalGeneralEntities;
|
||||
bool _externalParameterEntities;
|
||||
bool _enablePartialReads;
|
||||
NamespaceStrategy* _pNamespaceStrategy;
|
||||
EncodingMap _encodings;
|
||||
ContextStack _context;
|
||||
|
||||
EntityResolver* _pEntityResolver;
|
||||
DTDHandler* _pDTDHandler;
|
||||
DeclHandler* _pDeclHandler;
|
||||
ContentHandler* _pContentHandler;
|
||||
LexicalHandler* _pLexicalHandler;
|
||||
ErrorHandler* _pErrorHandler;
|
||||
|
||||
static const int PARSE_BUFFER_SIZE;
|
||||
static const XMLString EMPTY_STRING;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const XMLString& ParserEngine::getEncoding() const
|
||||
{
|
||||
return _encoding;
|
||||
}
|
||||
|
||||
|
||||
inline NamespaceStrategy* ParserEngine::getNamespaceStrategy() const
|
||||
{
|
||||
return _pNamespaceStrategy;
|
||||
}
|
||||
|
||||
|
||||
inline bool ParserEngine::getExpandInternalEntities() const
|
||||
{
|
||||
return _expandInternalEntities;
|
||||
}
|
||||
|
||||
|
||||
inline bool ParserEngine::getExternalGeneralEntities() const
|
||||
{
|
||||
return _externalGeneralEntities;
|
||||
}
|
||||
|
||||
|
||||
inline bool ParserEngine::getExternalParameterEntities() const
|
||||
{
|
||||
return _externalParameterEntities;
|
||||
}
|
||||
|
||||
|
||||
inline EntityResolver* ParserEngine::getEntityResolver() const
|
||||
{
|
||||
return _pEntityResolver;
|
||||
}
|
||||
|
||||
|
||||
inline DTDHandler* ParserEngine::getDTDHandler() const
|
||||
{
|
||||
return _pDTDHandler;
|
||||
}
|
||||
|
||||
|
||||
inline DeclHandler* ParserEngine::getDeclHandler() const
|
||||
{
|
||||
return _pDeclHandler;
|
||||
}
|
||||
|
||||
|
||||
inline ContentHandler* ParserEngine::getContentHandler() const
|
||||
{
|
||||
return _pContentHandler;
|
||||
}
|
||||
|
||||
|
||||
inline LexicalHandler* ParserEngine::getLexicalHandler() const
|
||||
{
|
||||
return _pLexicalHandler;
|
||||
}
|
||||
|
||||
|
||||
inline ErrorHandler* ParserEngine::getErrorHandler() const
|
||||
{
|
||||
return _pErrorHandler;
|
||||
}
|
||||
|
||||
|
||||
inline bool ParserEngine::getEnablePartialReads() const
|
||||
{
|
||||
return _enablePartialReads;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // XML_ParserEngine_INCLUDED
|
@@ -1,80 +0,0 @@
|
||||
//
|
||||
// XML.h
|
||||
//
|
||||
// $Id: //poco/svn/XML/include/Poco/XML/XML.h#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
// Module: XML
|
||||
//
|
||||
// Basic definitions for the Poco XML library.
|
||||
// This file must be the first file included by every other XML
|
||||
// header file.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XML_XML_INCLUDED
|
||||
#define XML_XML_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
//
|
||||
// The following block is the standard way of creating macros which make exporting
|
||||
// from a DLL simpler. All files within this DLL are compiled with the XML_EXPORTS
|
||||
// symbol defined on the command line. this symbol should not be defined on any project
|
||||
// that uses this DLL. This way any other project whose source files include this file see
|
||||
// XML_API functions as being imported from a DLL, wheras this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
#if defined(XML_EXPORTS)
|
||||
#define XML_API __declspec(dllexport)
|
||||
#else
|
||||
#define XML_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(XML_API)
|
||||
#define XML_API
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Automatically link XML library.
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(XML_EXPORTS)
|
||||
#pragma comment(lib, "PocoXML" POCO_LIB_SUFFIX)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif // XML_XML_INCLUDED
|
@@ -1,59 +0,0 @@
|
||||
//
|
||||
// XMLException.h
|
||||
//
|
||||
// $Id: //poco/svn/XML/include/Poco/XML/XMLException.h#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
// Module: XMLException
|
||||
//
|
||||
// Definition of the XMLException class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XML_XMLException_INCLUDED
|
||||
#define XML_XMLException_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
POCO_DECLARE_EXCEPTION(XML_API, XMLException, Poco::RuntimeException)
|
||||
/// The base class for all XML-related exceptions like SAXException
|
||||
/// and DOMException.
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // XML_XMLException_INCLUDED
|
@@ -1,93 +0,0 @@
|
||||
//
|
||||
// XMLStream.h
|
||||
//
|
||||
// $Id: //poco/svn/XML/include/Poco/XML/XMLStream.h#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
// Module: XMLStream
|
||||
//
|
||||
// Definition of the XMLByteInputStream and XMLCharInputStream classes.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XML_XMLStream_INCLUDED
|
||||
#define XML_XMLStream_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
// The byte input stream is always a narrow stream.
|
||||
typedef std::istream XMLByteInputStream;
|
||||
typedef std::ostream XMLByteOutputStream;
|
||||
|
||||
|
||||
//
|
||||
// The XML parser uses the stream classes provided by the C++
|
||||
// standard library (based on the basic_stream<> template).
|
||||
// In Unicode mode, a wide stream is used.
|
||||
// To turn on Unicode mode, #define XML_UNICODE and
|
||||
// XML_UNICODE_WCHAR_T when compiling the library.
|
||||
//
|
||||
// XML_UNICODE XML_UNICODE_WCHAR_T XMLCharInputStream XMLCharOutputStream
|
||||
// -------------------------------------------------------------------------
|
||||
// N N std::istream std::ostream
|
||||
// N Y std::wistream std::wostream
|
||||
// Y Y std::wistream std::wostream
|
||||
// Y N <not supported>
|
||||
//
|
||||
#if defined(XML_UNICODE_WCHAR_T)
|
||||
|
||||
// Unicode - use wide streams
|
||||
typedef std::wistream XMLCharInputStream;
|
||||
typedef std::wostream XMLCharOutputStream;
|
||||
|
||||
#elif defined(XML_UNICODE)
|
||||
|
||||
// not supported - leave XMLString undefined
|
||||
|
||||
#else
|
||||
|
||||
// Characters are UTF-8 encoded
|
||||
typedef std::istream XMLCharInputStream;
|
||||
typedef std::ostream XMLCharOutputStream;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // XML_XMLStream_INCLUDED
|
@@ -1,109 +0,0 @@
|
||||
//
|
||||
// XMLString.h
|
||||
//
|
||||
// $Id: //poco/1.3/XML/include/Poco/XML/XMLString.h#1 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
// Module: XMLString
|
||||
//
|
||||
// Definition of the XMLString class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XML_XMLString_INCLUDED
|
||||
#define XML_XMLString_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
//
|
||||
// The XML parser uses the string classes provided by the C++
|
||||
// standard library (based on the basic_string<> template).
|
||||
// In Unicode mode, a std::wstring is used, otherwise
|
||||
// a std::string is used.
|
||||
// To turn on Unicode mode, #define XML_UNICODE and
|
||||
// XML_UNICODE_WCHAR_T when compiling the library.
|
||||
//
|
||||
// XML_UNICODE XML_UNICODE_WCHAR_T XMLChar XMLString
|
||||
// --------------------------------------------------------------
|
||||
// N N char std::string
|
||||
// N Y wchar_t std::wstring
|
||||
// Y Y wchar_t std::wstring
|
||||
// Y N <not supported>
|
||||
//
|
||||
#if defined(XML_UNICODE_WCHAR_T)
|
||||
|
||||
// Unicode - use wchar_t
|
||||
typedef wchar_t XMLChar;
|
||||
typedef std::wstring XMLString;
|
||||
|
||||
std::string fromXMLString(const XMLString& str);
|
||||
/// Converts an XMLString into an UTF-8 encoded
|
||||
/// string.
|
||||
|
||||
XMLString toXMLString(const std::string& str);
|
||||
/// Converts an UTF-8 encoded string into an
|
||||
/// XMLString
|
||||
|
||||
#define XML_LIT(lit) L##lit
|
||||
|
||||
#elif defined(XML_UNICODE)
|
||||
|
||||
// not supported - leave XMLString undefined
|
||||
|
||||
#else
|
||||
|
||||
// Characters are UTF-8 encoded
|
||||
typedef char XMLChar;
|
||||
typedef std::string XMLString;
|
||||
|
||||
inline const std::string& fromXMLString(const XMLString& str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
inline const XMLString& toXMLString(const std::string& str)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
|
||||
#define XML_LIT(lit) lit
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // XML_XMLString_INCLUDED
|
@@ -1,363 +0,0 @@
|
||||
//
|
||||
// XMLWriter.h
|
||||
//
|
||||
// $Id: //poco/svn/XML/include/Poco/XML/XMLWriter.h#2 $
|
||||
//
|
||||
// Library: XML
|
||||
// Package: XML
|
||||
// Module: XMLWriter
|
||||
//
|
||||
// Definition of the XMLWriter class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef XML_XMLWriter_INCLUDED
|
||||
#define XML_XMLWriter_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/SAX/ContentHandler.h"
|
||||
#include "Poco/SAX/LexicalHandler.h"
|
||||
#include "Poco/SAX/DTDHandler.h"
|
||||
#include "Poco/SAX/NamespaceSupport.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#include "Poco/XML/XMLStream.h"
|
||||
#include "Poco/XML/Name.h"
|
||||
#include "Poco/TextEncoding.h"
|
||||
#include "Poco/StreamConverter.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class Locator;
|
||||
|
||||
|
||||
class XML_API XMLWriter: public ContentHandler, public LexicalHandler, public DTDHandler
|
||||
/// This class serializes SAX2 ContentHandler, LexicalHandler and
|
||||
/// DTDHandler events back into a stream.
|
||||
///
|
||||
/// Various consistency checks are performed on the written data
|
||||
/// (i.e. there must be exactly one root element and every startElement()
|
||||
/// must have a matching endElement()).
|
||||
///
|
||||
/// The XMLWriter supports optional pretty-printing of the serialized XML.
|
||||
/// Note, however, that pretty-printing XML data alters the
|
||||
/// information set of the document being written, since in
|
||||
/// XML all whitespace is potentially relevant to an application.
|
||||
///
|
||||
/// The writer contains extensive support for XML Namespaces, so that a client
|
||||
/// application does not have to keep track of prefixes and supply xmlns attributes.
|
||||
///
|
||||
/// If the client does not provide namespace prefixes (either by specifying them
|
||||
/// as part of the qualified name given to startElement(), or by calling
|
||||
/// startPrefixMapping()), the XMLWriter automatically generates namespace
|
||||
/// prefixes in the form ns1, ns2, etc.
|
||||
{
|
||||
public:
|
||||
enum Options
|
||||
{
|
||||
CANONICAL = 0x00,
|
||||
/// Do not write an XML declaration (default).
|
||||
|
||||
CANONICAL_XML = 0x01,
|
||||
/// Enables basic support for Canonical XML:
|
||||
/// - do not write an XML declaration
|
||||
/// - do not use special empty element syntax
|
||||
/// - set the New Line character to NEWLINE_LF
|
||||
|
||||
WRITE_XML_DECLARATION = 0x02,
|
||||
/// Write an XML declaration.
|
||||
|
||||
PRETTY_PRINT = 0x04,
|
||||
/// Pretty-print XML markup.
|
||||
|
||||
PRETTY_PRINT_ATTRIBUTES = 0x08
|
||||
/// Write each attribute on a separate line.
|
||||
/// PRETTY_PRINT must be specified as well.
|
||||
};
|
||||
|
||||
XMLWriter(XMLByteOutputStream& str, int options);
|
||||
/// Creates the XMLWriter and sets the specified options.
|
||||
///
|
||||
/// The resulting stream will be UTF-8 encoded.
|
||||
|
||||
XMLWriter(XMLByteOutputStream& str, int options, const std::string& encodingName, Poco::TextEncoding& textEncoding);
|
||||
/// Creates the XMLWriter and sets the specified options.
|
||||
///
|
||||
/// The encoding is reflected in the XML declaration.
|
||||
/// The caller is responsible for that the given encodingName matches with
|
||||
/// the given textEncoding.
|
||||
|
||||
XMLWriter(XMLByteOutputStream& str, int options, const std::string& encodingName, Poco::TextEncoding* pTextEncoding);
|
||||
/// Creates the XMLWriter and sets the specified options.
|
||||
///
|
||||
/// The encoding is reflected in the XML declaration.
|
||||
/// The caller is responsible for that the given encodingName matches with
|
||||
/// the given textEncoding.
|
||||
/// If pTextEncoding is null, the given encodingName is ignored and the
|
||||
/// default UTF-8 encoding is used.
|
||||
|
||||
~XMLWriter();
|
||||
/// Destroys the XMLWriter.
|
||||
|
||||
void setNewLine(const std::string& newLineCharacters);
|
||||
/// Sets the line ending for the resulting XML file.
|
||||
///
|
||||
/// Possible values are:
|
||||
/// * NEWLINE_DEFAULT (whatever is appropriate for the current platform)
|
||||
/// * NEWLINE_CRLF (Windows),
|
||||
/// * NEWLINE_LF (Unix),
|
||||
/// * NEWLINE_CR (Macintosh)
|
||||
|
||||
const std::string& getNewLine() const;
|
||||
/// Returns the line ending currently in use.
|
||||
|
||||
void setIndent(const std::string& indent);
|
||||
/// Sets the string used for one indentation step.
|
||||
///
|
||||
/// The default is a single TAB character.
|
||||
/// The given string should only contain TAB or SPACE
|
||||
/// characters (e.g., a single TAB character, or
|
||||
/// two to four SPACE characters).
|
||||
|
||||
const std::string& getIndent() const;
|
||||
/// Returns the string used for one indentation step.
|
||||
|
||||
// ContentHandler
|
||||
void setDocumentLocator(const Locator* loc);
|
||||
/// Currently unused.
|
||||
|
||||
void startDocument();
|
||||
/// Writes a generic XML declaration to the stream.
|
||||
/// If a document type has been set (see SetDocumentType),
|
||||
/// a DOCTYPE declaration is also written.
|
||||
|
||||
void endDocument();
|
||||
/// Checks that all elements are closed and prints a final newline.
|
||||
|
||||
void startFragment();
|
||||
/// Use this instead of StartDocument() if you want to write
|
||||
/// a fragment rather than a document (no XML declaration and
|
||||
/// more than one "root" element allowed).
|
||||
|
||||
void endFragment();
|
||||
/// Checks that all elements are closed and prints a final newline.
|
||||
|
||||
void startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes);
|
||||
/// Writes an XML start element tag.
|
||||
///
|
||||
/// Namespaces are handled as follows.
|
||||
/// 1. If a qname, but no namespaceURI and localName are given, the qname is taken as element name.
|
||||
/// 2. If a namespaceURI and a localName, but no qname is given, and the given namespaceURI has been
|
||||
/// declared earlier, the namespace prefix for the given namespaceURI together with the localName
|
||||
/// is taken as element name. If the namespace has not been declared, a prefix in the form
|
||||
/// "ns1", "ns2", etc. is generated and the namespace is declared with the generated prefix.
|
||||
/// 3. If all three are given, and the namespace given in namespaceURI has not been declared, it is declared now.
|
||||
/// Otherwise, see 2.
|
||||
|
||||
void startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname);
|
||||
/// Writes an XML start element tag with no attributes.
|
||||
/// See the other startElement() method for more information.
|
||||
|
||||
void endElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname);
|
||||
/// Writes an XML end element tag.
|
||||
///
|
||||
/// Throws an exception if the name of doesn't match the
|
||||
/// one of the most recent startElement().
|
||||
|
||||
void emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname);
|
||||
/// Writes an empty XML element tag (<elem/>).
|
||||
|
||||
void emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes);
|
||||
/// Writes an empty XML element tag with the given attributes (<elem attr1="value1"... />).
|
||||
|
||||
void characters(const XMLChar ch[], int start, int length);
|
||||
/// Writes XML character data. Quotes, ampersand's, less-than and
|
||||
/// greater-than signs are escaped, unless a CDATA section
|
||||
/// has been opened by calling startCDATA().
|
||||
///
|
||||
/// The characters must be encoded in UTF-8 (if XMLChar is char) or
|
||||
/// UTF-16 (if XMLChar is wchar_t).
|
||||
|
||||
void characters(const XMLString& str);
|
||||
/// Writes XML character data. Quotes, ampersand's, less-than and
|
||||
/// greater-than signs are escaped, unless a CDATA section
|
||||
/// has been opened by calling startCDATA().
|
||||
///
|
||||
/// The characters must be encoded in UTF-8 (if XMLChar is char) or
|
||||
/// UTF-16 (if XMLChar is wchar_t).
|
||||
|
||||
void rawCharacters(const XMLString& str);
|
||||
/// Writes the characters in the given string as they are.
|
||||
/// The caller is responsible for escaping characters as
|
||||
/// necessary to produce valid XML.
|
||||
///
|
||||
/// The characters must be encoded in UTF-8 (if XMLChar is char) or
|
||||
/// UTF-16 (if XMLChar is wchar_t).
|
||||
|
||||
void ignorableWhitespace(const XMLChar ch[], int start, int length);
|
||||
/// Writes whitespace characters by simply passing them to
|
||||
/// characters().
|
||||
|
||||
void processingInstruction(const XMLString& target, const XMLString& data);
|
||||
/// Writes a processing instruction.
|
||||
|
||||
void startPrefixMapping(const XMLString& prefix, const XMLString& namespaceURI);
|
||||
/// Begin the scope of a prefix-URI Namespace mapping.
|
||||
/// A namespace declaration is written with the next element.
|
||||
|
||||
void endPrefixMapping(const XMLString& prefix);
|
||||
/// End the scope of a prefix-URI mapping.
|
||||
|
||||
void skippedEntity(const XMLString& name);
|
||||
/// Does nothing.
|
||||
|
||||
void dataElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& data,
|
||||
const XMLString& attr1 = XMLString(), const XMLString& value1 = XMLString(),
|
||||
const XMLString& attr2 = XMLString(), const XMLString& value2 = XMLString(),
|
||||
const XMLString& attr3 = XMLString(), const XMLString& value3 = XMLString());
|
||||
/// Writes a data element in the form <name attr1="value1"...>data</name>.
|
||||
|
||||
// LexicalHandler
|
||||
void startCDATA();
|
||||
/// Writes the <![CDATA[ string that begins a CDATA section.
|
||||
/// Use characters() to write the actual character data.
|
||||
|
||||
void endCDATA();
|
||||
/// Writes the ]]> string that ends a CDATA section.
|
||||
|
||||
void comment(const XMLChar ch[], int start, int length);
|
||||
/// Writes a comment.
|
||||
|
||||
void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId);
|
||||
/// Writes a DTD declaration.
|
||||
|
||||
void endDTD();
|
||||
/// Writes the closing characters of a DTD declaration.
|
||||
|
||||
void startEntity(const XMLString& name);
|
||||
/// Does nothing.
|
||||
|
||||
void endEntity(const XMLString& name);
|
||||
/// Does nothing.
|
||||
|
||||
// DTDHandler
|
||||
void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId);
|
||||
void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName);
|
||||
|
||||
static const std::string NEWLINE_DEFAULT;
|
||||
static const std::string NEWLINE_CR;
|
||||
static const std::string NEWLINE_CRLF;
|
||||
static const std::string NEWLINE_LF;
|
||||
|
||||
protected:
|
||||
typedef std::map<XMLString, XMLString> AttributeMap;
|
||||
|
||||
void writeStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes);
|
||||
void writeEndElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname);
|
||||
void writeMarkup(const std::string& str) const;
|
||||
void writeXML(const XMLString& str) const;
|
||||
void writeXML(XMLChar ch) const;
|
||||
void writeNewLine() const;
|
||||
void writeIndent() const;
|
||||
void writeIndent(int indent) const;
|
||||
void writeName(const XMLString& prefix, const XMLString& localName);
|
||||
void writeXMLDeclaration();
|
||||
void closeStartTag();
|
||||
void declareAttributeNamespaces(const Attributes& attributes);
|
||||
void addNamespaceAttributes(AttributeMap& attributeMap);
|
||||
void addAttributes(AttributeMap& attributeMap, const Attributes& attributes, const XMLString& elementNamespaceURI);
|
||||
void writeAttributes(const AttributeMap& attributeMap);
|
||||
void prettyPrint() const;
|
||||
XMLString newPrefix();
|
||||
static std::string nameToString(const XMLString& localName, const XMLString& qname);
|
||||
|
||||
private:
|
||||
struct Namespace
|
||||
{
|
||||
Namespace(const XMLString& thePrefix, const XMLString& theNamespaceURI):
|
||||
prefix(thePrefix),
|
||||
namespaceURI(theNamespaceURI)
|
||||
{
|
||||
}
|
||||
|
||||
XMLString prefix;
|
||||
XMLString namespaceURI;
|
||||
};
|
||||
typedef std::vector<Name> ElementStack;
|
||||
|
||||
Poco::OutputStreamConverter* _pTextConverter;
|
||||
Poco::TextEncoding* _pInEncoding;
|
||||
Poco::TextEncoding* _pOutEncoding;
|
||||
int _options;
|
||||
std::string _encoding;
|
||||
std::string _newLine;
|
||||
int _depth;
|
||||
int _elementCount;
|
||||
bool _inFragment;
|
||||
bool _inCDATA;
|
||||
bool _inDTD;
|
||||
bool _inInternalDTD;
|
||||
bool _contentWritten;
|
||||
bool _unclosedStartTag;
|
||||
ElementStack _elementStack;
|
||||
NamespaceSupport _namespaces;
|
||||
int _prefix;
|
||||
bool _nsContextPushed;
|
||||
std::string _indent;
|
||||
|
||||
static const std::string MARKUP_QUOTENC;
|
||||
static const std::string MARKUP_APOSENC;
|
||||
static const std::string MARKUP_AMPENC;
|
||||
static const std::string MARKUP_LTENC;
|
||||
static const std::string MARKUP_GTENC;
|
||||
static const std::string MARKUP_TABENC;
|
||||
static const std::string MARKUP_CRENC;
|
||||
static const std::string MARKUP_LFENC;
|
||||
static const std::string MARKUP_LT;
|
||||
static const std::string MARKUP_GT;
|
||||
static const std::string MARKUP_SLASHGT;
|
||||
static const std::string MARKUP_LTSLASH;
|
||||
static const std::string MARKUP_COLON;
|
||||
static const std::string MARKUP_EQQUOT;
|
||||
static const std::string MARKUP_QUOT;
|
||||
static const std::string MARKUP_SPACE;
|
||||
static const std::string MARKUP_TAB;
|
||||
static const std::string MARKUP_BEGIN_CDATA;
|
||||
static const std::string MARKUP_END_CDATA;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // XML_XMLWriter_INCLUDED
|
File diff suppressed because it is too large
Load Diff
@@ -1,115 +0,0 @@
|
||||
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef Expat_External_INCLUDED
|
||||
#define Expat_External_INCLUDED 1
|
||||
|
||||
/* External API definitions */
|
||||
|
||||
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
|
||||
#define XML_USE_MSC_EXTENSIONS 1
|
||||
#endif
|
||||
|
||||
/* Expat tries very hard to make the API boundary very specifically
|
||||
defined. There are two macros defined to control this boundary;
|
||||
each of these can be defined before including this header to
|
||||
achieve some different behavior, but doing so it not recommended or
|
||||
tested frequently.
|
||||
|
||||
XMLCALL - The calling convention to use for all calls across the
|
||||
"library boundary." This will default to cdecl, and
|
||||
try really hard to tell the compiler that's what we
|
||||
want.
|
||||
|
||||
XMLIMPORT - Whatever magic is needed to note that a function is
|
||||
to be imported from a dynamically loaded library
|
||||
(.dll, .so, or .sl, depending on your platform).
|
||||
|
||||
The XMLCALL macro was added in Expat 1.95.7. The only one which is
|
||||
expected to be directly useful in client code is XMLCALL.
|
||||
|
||||
Note that on at least some Unix versions, the Expat library must be
|
||||
compiled with the cdecl calling convention as the default since
|
||||
system headers may assume the cdecl convention.
|
||||
*/
|
||||
#ifndef XMLCALL
|
||||
#if defined(_MSC_VER)
|
||||
#define XMLCALL __cdecl
|
||||
#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
|
||||
#define XMLCALL __attribute__((cdecl))
|
||||
#else
|
||||
/* For any platform which uses this definition and supports more than
|
||||
one calling convention, we need to extend this definition to
|
||||
declare the convention used on that platform, if it's possible to
|
||||
do so.
|
||||
|
||||
If this is the case for your platform, please file a bug report
|
||||
with information on how to identify your platform via the C
|
||||
pre-processor and how to specify the same calling convention as the
|
||||
platform's malloc() implementation.
|
||||
*/
|
||||
#define XMLCALL
|
||||
#endif
|
||||
#endif /* not defined XMLCALL */
|
||||
|
||||
|
||||
#if !defined(XML_STATIC) && !defined(XMLIMPORT)
|
||||
#ifndef XML_BUILDING_EXPAT
|
||||
/* using Expat from an application */
|
||||
|
||||
#ifdef XML_USE_MSC_EXTENSIONS
|
||||
#define XMLIMPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* not defined XML_STATIC */
|
||||
|
||||
|
||||
/* If we didn't define it above, define it away: */
|
||||
#ifndef XMLIMPORT
|
||||
#define XMLIMPORT
|
||||
#endif
|
||||
|
||||
|
||||
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
typedef wchar_t XML_Char;
|
||||
typedef wchar_t XML_LChar;
|
||||
#else
|
||||
typedef unsigned short XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE_WCHAR_T */
|
||||
#else /* Information is UTF-8 encoded. */
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE */
|
||||
|
||||
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
|
||||
#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
|
||||
typedef __int64 XML_Index;
|
||||
typedef unsigned __int64 XML_Size;
|
||||
#else
|
||||
typedef long long XML_Index;
|
||||
typedef unsigned long long XML_Size;
|
||||
#endif
|
||||
#else
|
||||
typedef long XML_Index;
|
||||
typedef unsigned long XML_Size;
|
||||
#endif /* XML_LARGE_SIZE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not Expat_External_INCLUDED */
|
Reference in New Issue
Block a user