summaryrefslogtreecommitdiff
path: root/ACE/ACEXML/common
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:30 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:30 +0000
commitc44379cc7d9c7aa113989237ab0f56db12aa5219 (patch)
tree66a84b20d47f2269d8bdc6e0323f338763424d3a /ACE/ACEXML/common
parent3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (diff)
downloadATCD-c44379cc7d9c7aa113989237ab0f56db12aa5219.tar.gz
Repo restructuring
Diffstat (limited to 'ACE/ACEXML/common')
-rw-r--r--ACE/ACEXML/common/ACEXML.pc.in11
-rw-r--r--ACE/ACEXML/common/ACEXML_Export.h49
-rw-r--r--ACE/ACEXML/common/Attributes.cpp11
-rw-r--r--ACE/ACEXML/common/Attributes.h130
-rw-r--r--ACE/ACEXML/common/AttributesImpl.cpp293
-rw-r--r--ACE/ACEXML/common/AttributesImpl.h309
-rw-r--r--ACE/ACEXML/common/AttributesImpl.i154
-rw-r--r--ACE/ACEXML/common/Attributes_Def_Builder.cpp14
-rw-r--r--ACE/ACEXML/common/Attributes_Def_Builder.h153
-rw-r--r--ACE/ACEXML/common/CharStream.cpp7
-rw-r--r--ACE/ACEXML/common/CharStream.h88
-rw-r--r--ACE/ACEXML/common/ContentHandler.cpp11
-rw-r--r--ACE/ACEXML/common/ContentHandler.h131
-rw-r--r--ACE/ACEXML/common/DTDHandler.cpp11
-rw-r--r--ACE/ACEXML/common/DTDHandler.h78
-rw-r--r--ACE/ACEXML/common/DTD_Manager.cpp8
-rw-r--r--ACE/ACEXML/common/DTD_Manager.h82
-rw-r--r--ACE/ACEXML/common/DefaultHandler.cpp159
-rw-r--r--ACE/ACEXML/common/DefaultHandler.h191
-rw-r--r--ACE/ACEXML/common/Element_Def_Builder.cpp9
-rw-r--r--ACE/ACEXML/common/Element_Def_Builder.h133
-rw-r--r--ACE/ACEXML/common/Encoding.cpp59
-rw-r--r--ACE/ACEXML/common/Encoding.h61
-rw-r--r--ACE/ACEXML/common/EntityResolver.cpp11
-rw-r--r--ACE/ACEXML/common/EntityResolver.h61
-rw-r--r--ACE/ACEXML/common/Env.cpp34
-rw-r--r--ACE/ACEXML/common/Env.h72
-rw-r--r--ACE/ACEXML/common/Env.i25
-rw-r--r--ACE/ACEXML/common/ErrorHandler.cpp11
-rw-r--r--ACE/ACEXML/common/ErrorHandler.h75
-rw-r--r--ACE/ACEXML/common/Exception.cpp36
-rw-r--r--ACE/ACEXML/common/Exception.h87
-rw-r--r--ACE/ACEXML/common/Exception.i13
-rw-r--r--ACE/ACEXML/common/FileCharStream.cpp255
-rw-r--r--ACE/ACEXML/common/FileCharStream.h130
-rw-r--r--ACE/ACEXML/common/HttpCharStream.cpp464
-rw-r--r--ACE/ACEXML/common/HttpCharStream.h140
-rw-r--r--ACE/ACEXML/common/InputSource.cpp106
-rw-r--r--ACE/ACEXML/common/InputSource.h131
-rw-r--r--ACE/ACEXML/common/Locator.cpp11
-rw-r--r--ACE/ACEXML/common/Locator.h74
-rw-r--r--ACE/ACEXML/common/LocatorImpl.cpp49
-rw-r--r--ACE/ACEXML/common/LocatorImpl.h159
-rw-r--r--ACE/ACEXML/common/LocatorImpl.i65
-rw-r--r--ACE/ACEXML/common/Makefile.am135
-rw-r--r--ACE/ACEXML/common/Mem_Map_Stream.cpp264
-rw-r--r--ACE/ACEXML/common/Mem_Map_Stream.h191
-rw-r--r--ACE/ACEXML/common/NamespaceSupport.cpp247
-rw-r--r--ACE/ACEXML/common/NamespaceSupport.h235
-rw-r--r--ACE/ACEXML/common/SAXExceptions.cpp261
-rw-r--r--ACE/ACEXML/common/SAXExceptions.h208
-rw-r--r--ACE/ACEXML/common/SAXExceptions.i57
-rw-r--r--ACE/ACEXML/common/StrCharStream.cpp129
-rw-r--r--ACE/ACEXML/common/StrCharStream.h102
-rw-r--r--ACE/ACEXML/common/StreamFactory.cpp56
-rw-r--r--ACE/ACEXML/common/StreamFactory.h58
-rw-r--r--ACE/ACEXML/common/Transcode.cpp311
-rw-r--r--ACE/ACEXML/common/Transcode.h172
-rw-r--r--ACE/ACEXML/common/URL_Addr.cpp177
-rw-r--r--ACE/ACEXML/common/URL_Addr.h135
-rw-r--r--ACE/ACEXML/common/URL_Addr.inl65
-rw-r--r--ACE/ACEXML/common/Validator.cpp8
-rw-r--r--ACE/ACEXML/common/Validator.h64
-rw-r--r--ACE/ACEXML/common/XMLFilter.h56
-rw-r--r--ACE/ACEXML/common/XMLFilterImpl.cpp339
-rw-r--r--ACE/ACEXML/common/XMLFilterImpl.h294
-rw-r--r--ACE/ACEXML/common/XMLFilterImpl.i14
-rw-r--r--ACE/ACEXML/common/XMLReader.cpp11
-rw-r--r--ACE/ACEXML/common/XMLReader.h136
-rw-r--r--ACE/ACEXML/common/XML_Codecs.cpp94
-rw-r--r--ACE/ACEXML/common/XML_Codecs.h73
-rw-r--r--ACE/ACEXML/common/XML_Macros.h443
-rw-r--r--ACE/ACEXML/common/XML_Types.h83
-rw-r--r--ACE/ACEXML/common/XML_Util.cpp46
-rw-r--r--ACE/ACEXML/common/XML_Util.h33
-rw-r--r--ACE/ACEXML/common/ZipCharStream.cpp255
-rw-r--r--ACE/ACEXML/common/ZipCharStream.h144
-rw-r--r--ACE/ACEXML/common/codecs.mpb8
-rw-r--r--ACE/ACEXML/common/common.mpc33
79 files changed, 9098 insertions, 0 deletions
diff --git a/ACE/ACEXML/common/ACEXML.pc.in b/ACE/ACEXML/common/ACEXML.pc.in
new file mode 100644
index 00000000000..78a706c17c0
--- /dev/null
+++ b/ACE/ACEXML/common/ACEXML.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ACEXML
+Description: ACE XML Library
+Requires: ACE
+Version: @VERSION@
+Libs: -L${libdir} -lACEXML
+Cflags: -I${includedir}
diff --git a/ACE/ACEXML/common/ACEXML_Export.h b/ACE/ACEXML/common/ACEXML_Export.h
new file mode 100644
index 00000000000..39546eeafcc
--- /dev/null
+++ b/ACE/ACEXML/common/ACEXML_Export.h
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ACEXML_Export.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl
+// ------------------------------
+#ifndef ACEXML_EXPORT_H
+#define ACEXML_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if defined (ACE_AS_STATIC_LIBS)
+# if !defined (ACEXML_HAS_DLL)
+# define ACEXML_HAS_DLL 0
+# endif /* ! ACEXML_HAS_DLL */
+#else
+# if !defined (ACEXML_HAS_DLL)
+# define ACEXML_HAS_DLL 1
+# endif /* ! ACEXML_HAS_DLL */
+#endif /* ACE_AS_STATIC_LIB */
+
+#if defined (ACEXML_HAS_DLL) && (ACEXML_HAS_DLL == 1)
+# if defined (ACEXML_BUILD_DLL)
+# define ACEXML_Export ACE_Proper_Export_Flag
+# define ACEXML_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define ACEXML_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* ACEXML_BUILD_DLL */
+# define ACEXML_Export ACE_Proper_Import_Flag
+# define ACEXML_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define ACEXML_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* ACEXML_BUILD_DLL */
+#else /* ACEXML_HAS_DLL == 1 */
+# define ACEXML_Export
+# define ACEXML_SINGLETON_DECLARATION(T)
+# define ACEXML_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* ACEXML_HAS_DLL == 1 */
+
+#endif /* ACEXML_EXPORT_H */
+
+// End of auto generated file.
diff --git a/ACE/ACEXML/common/Attributes.cpp b/ACE/ACEXML/common/Attributes.cpp
new file mode 100644
index 00000000000..3f7c758ce8f
--- /dev/null
+++ b/ACE/ACEXML/common/Attributes.cpp
@@ -0,0 +1,11 @@
+#include "Attributes.h"
+
+
+ACE_RCSID (common,
+ Attributes,
+ "$Id$")
+
+
+ACEXML_Attributes::~ACEXML_Attributes (void)
+{
+}
diff --git a/ACE/ACEXML/common/Attributes.h b/ACE/ACEXML/common/Attributes.h
new file mode 100644
index 00000000000..45982ed459e
--- /dev/null
+++ b/ACE/ACEXML/common/Attributes.h
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Attributes.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_ATTRIBUTES_H_
+#define _ACEXML_ATTRIBUTES_H_
+#include /**/ "ace/pre.h"
+
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_Attributes Attributes.h "ACEXML/common/Attributes.h"
+ *
+ * @brief ACEXML_Attributes defines a collection of attributes of an XML element.
+ *
+ * This is an abstract class (interface in Java) that defines
+ * the API for accessing attributes of an XML entity.
+ *
+ * This interface allows access to a list of attributes in three different ways:
+ *
+ * - by attribute index;
+ * - by Namespace-qualified name; or
+ * - by qualified (prefixed) name.
+ *
+ * The list will not contain attributes that were declared #IMPLIED
+ * but not specified in the start tag. It will also not contain
+ * attributes used as Namespace declarations (xmlns*) unless the
+ * http://xml.org/sax/features/namespace-prefixes feature is set to
+ * true (it is false by default).
+ *
+ * If the namespace-prefixes feature (see above) is false, access by
+ * qualified name may not be available; if the
+ * http://xml.org/sax/features/namespaces feature is false, access by
+ * Namespace-qualified names may not be available.
+ *
+ * This interface replaces the now-deprecated SAX1 AttributeList
+ * interface, which does not contain Namespace support. In addition to
+ * Namespace support, it adds the getIndex methods (below).
+ *
+ * The order of attributes in the list is unspecified, and will vary
+ * from implementation to implementation.
+ */
+class ACEXML_Export ACEXML_Attributes
+{
+public:
+
+ /// Destructor.
+ virtual ~ACEXML_Attributes (void);
+
+ /**
+ * Look up the index of an attribute by XML 1.0 qualified name.
+ */
+ virtual int getIndex (const ACEXML_Char *qName) = 0;
+
+ /**
+ * Look up the index of an attribute by Namespace name.
+ */
+ virtual int getIndex (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart) = 0;
+
+ /**
+ * Return the number of attributes in the list.
+ */
+ virtual size_t getLength (void) = 0;
+
+ /**
+ * Look up an attribute's local name by index.
+ */
+ virtual const ACEXML_Char *getLocalName (size_t index) = 0;
+
+ /**
+ * Look up an attribute's XML 1.0 qualified name by index.
+ */
+ virtual const ACEXML_Char *getQName (size_t index) = 0;
+
+ /**
+ * Look up an attribute's type by index.
+ */
+ virtual const ACEXML_Char *getType (size_t index) = 0;
+
+ /**
+ * Look up an attribute's type by XML 1.0 qualified name.
+ */
+ virtual const ACEXML_Char *getType (const ACEXML_Char *qName) = 0;
+
+ /**
+ * Look up an attribute's type by Namespace name.
+ */
+ virtual const ACEXML_Char *getType (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart) = 0;
+
+ /**
+ * Look up an attribute's Namespace URI by index.
+ */
+ virtual const ACEXML_Char *getURI (size_t index) = 0;
+
+ /**
+ * Look up an attribute's value by index.
+ */
+ virtual const ACEXML_Char *getValue (size_t index) = 0;
+
+ /**
+ * Look up an attribute's value by XML 1.0 qualified name.
+ */
+ virtual const ACEXML_Char *getValue (const ACEXML_Char *qName) = 0;
+
+ /**
+ * Look up an attribute's value by Namespace name.
+ */
+ virtual const ACEXML_Char *getValue (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart) = 0;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ ATTRIBUTES_H_ */
diff --git a/ACE/ACEXML/common/AttributesImpl.cpp b/ACE/ACEXML/common/AttributesImpl.cpp
new file mode 100644
index 00000000000..a11d34c52e2
--- /dev/null
+++ b/ACE/ACEXML/common/AttributesImpl.cpp
@@ -0,0 +1,293 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/AttributesImpl.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/AttributesImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_AttributesImpl::ACEXML_AttributesImpl (int size)
+ : attrs_ (size)
+{
+ this->attrs_.size (0); // attrs array contains nothing
+}
+
+ACEXML_AttributesImpl::ACEXML_AttributesImpl (const
+ ACEXML_AttributesImpl &attrs)
+ : ACEXML_Attributes (attrs),
+ attrs_ (attrs.attrs_.size ())
+{
+ for (size_t i = 0; i < attrs.attrs_.size (); i++)
+ this->attrs_[i] = attrs.attrs_[i];
+}
+
+ACEXML_AttributesImpl::~ACEXML_AttributesImpl (void)
+{
+}
+
+int
+ACEXML_AttributesImpl::addAttribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value)
+{
+ if (this->isDuplicate (uri, localName, qName))
+ return -1;
+ size_t length = this->attrs_.size ();
+ this->attrs_.size (length+1);
+ this->setAttribute (length,
+ uri,
+ localName,
+ qName,
+ type,
+ value);
+ return static_cast<int> (length);
+}
+
+int
+ACEXML_AttributesImpl::addAttribute (const ACEXML_Attribute &att)
+{
+ if (this->isDuplicate (att.uri(), att.localName(), att.qName()))
+ return -1;
+ size_t length = this->attrs_.size ();
+ this->attrs_.size (length+1);
+ this->attrs_[length] = att;
+ return static_cast<int> (length);
+}
+
+int
+ACEXML_AttributesImpl::isDuplicate (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName)
+{
+ for (size_t i = 0; i < this->attrs_.size(); ++i)
+ {
+ if (ACE_OS::strcmp (this->attrs_[i].localName(), localName) == 0)
+ {
+ if (qName != 0 && this->attrs_[i].qName() != 0
+ && ACE_OS::strcmp (this->attrs_[i].qName(), qName) == 0)
+ {
+ if (uri != 0 && this->attrs_[i].uri() != 0
+ && ACE_OS::strcmp (this->attrs_[i].uri(), uri) == 0)
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+int
+ACEXML_AttributesImpl::removeAttribute (size_t index)
+{
+ size_t length = this->attrs_.size ();
+
+ if (index >= length)
+ return -1;
+
+ this->attrs_[index] = this->attrs_[length - 1];
+ this->attrs_.size (length - 1);
+
+ return 0;
+}
+
+
+int
+ACEXML_AttributesImpl::getIndex (const ACEXML_Char *qName)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
+ return static_cast<int> (i);
+
+ return -1;
+}
+
+int
+ACEXML_AttributesImpl::getIndex (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
+ ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
+ return static_cast<int> (i);
+
+ return -1;
+}
+
+size_t
+ACEXML_AttributesImpl::getLength (void)
+{
+ return this->attrs_.size ();
+}
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getLocalName (size_t index)
+{
+ if (index < this->attrs_.size ())
+ return this->attrs_[index].localName ();
+ return 0;
+}
+
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getQName (size_t index)
+{
+ if (index < this->attrs_.size ())
+ return this->attrs_[index].qName ();
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getType (size_t index)
+{
+ if (index < this->attrs_.size ())
+ return this->attrs_[index].type ();
+ return 0;
+}
+
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getType (const ACEXML_Char *qName)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
+ return this->attrs_[i].type ();
+
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getType (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
+ ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
+ return this->attrs_[i].type ();
+
+ return 0;
+}
+
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getURI (size_t index)
+{
+ if (index < this->attrs_.size ())
+ return this->attrs_[index].uri ();
+ return 0;
+}
+
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getValue (size_t index)
+{
+ if (index < this->attrs_.size ())
+ return this->attrs_[index].value ();
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getValue (const ACEXML_Char *qName)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
+ return this->attrs_[i].value ();
+
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_AttributesImpl::getValue (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart)
+{
+ for (size_t i = 0; i < this->attrs_.size (); i++)
+ if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
+ ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
+ return this->attrs_[i].value ();
+
+ return 0;
+}
+
+int
+ACEXML_AttributesImpl::setAttribute (size_t index,
+ const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].setAttribute (uri,
+ localName,
+ qName,
+ type,
+ value);
+ return 0;
+ }
+
+ return -1;
+}
+
+
+int
+ACEXML_AttributesImpl::setLocalName (size_t index,
+ const ACEXML_Char *localName)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].localName (localName);
+ return 0;
+ }
+ return -1;
+}
+
+int
+ACEXML_AttributesImpl::setQName (size_t index,
+ const ACEXML_Char *qName)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].qName (qName);
+ return 0;
+ }
+ return -1;
+}
+
+
+int
+ACEXML_AttributesImpl::setURI (size_t index,
+ const ACEXML_Char *uri)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].uri (uri);
+ return 0;
+ }
+ return -1;
+}
+
+int
+ACEXML_AttributesImpl::setType (size_t index,
+ const ACEXML_Char *type)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].type (type);
+ return 0;
+ }
+ return -1;
+}
+
+int
+ACEXML_AttributesImpl::setValue (size_t index,
+ const ACEXML_Char *value)
+{
+ if (index < this->attrs_.size ())
+ {
+ this->attrs_[index].value (value);
+ return 0;
+ }
+ return -1;
+}
+
diff --git a/ACE/ACEXML/common/AttributesImpl.h b/ACE/ACEXML/common/AttributesImpl.h
new file mode 100644
index 00000000000..85c48ed1c2e
--- /dev/null
+++ b/ACE/ACEXML/common/AttributesImpl.h
@@ -0,0 +1,309 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file AttributesImpl.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef ACEXML_ATTRIBUTESIMPL_H
+#define ACEXML_ATTRIBUTESIMPL_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Attributes.h"
+#include "ace/Containers_T.h"
+
+#if !defined ACEXML_AttributesImpl_Default_Size
+#define ACEXML_AttributesImpl_Default_Size 20
+#endif /* ACEXML_AttributesImpl_Default_Size */
+
+class ACEXML_AttributesImpl;
+
+/**
+ * @class ACEXML_Attribute AttributesImpl.h "ACEXML/common/AttributesImpl.h"
+ *
+ * @brief ACEXML_Attribute defines the data structure of an attribute
+ *
+ * @sa ACEXML_AttributesImpl
+ */
+class ACEXML_Export ACEXML_Attribute
+{
+public:
+ friend class ACEXML_AttributesImpl;
+
+ /// Default constructor.
+ ACEXML_Attribute (void);
+
+ /// Copy constructor.
+ ACEXML_Attribute (const ACEXML_Attribute &attr);
+
+ /// Initialize all constructor.
+ ACEXML_Attribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value);
+
+ /// Destructor.
+ ~ACEXML_Attribute (void);
+
+ /// Set all members.
+ void setAttribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value);
+
+ /// Get \a uri_.
+ const ACEXML_Char *uri (void) const;
+
+ /// Set \a uri_.
+ void uri (const ACEXML_Char *uri);
+
+ /// Get \a localName_.
+ const ACEXML_Char *localName (void) const;
+
+ /// Set \a localName_.
+ void localName (const ACEXML_Char *localName);
+
+ /// Get \a qName_.
+ const ACEXML_Char *qName (void) const;
+
+ /// Set \a qName_.
+ void qName (const ACEXML_Char *qName);
+
+ /// Get \a type_.
+ const ACEXML_Char *type (void) const;
+
+ /// Set \a type_.
+ void type (const ACEXML_Char *type);
+
+ /// Get \a value_.
+ const ACEXML_Char *value (void) const;
+
+ /// Set \a value_.
+ void value (const ACEXML_Char *value);
+
+ /// Assignment operator.
+ ACEXML_Attribute &operator= (const ACEXML_Attribute &rhs);
+
+ /// Comparison operator.
+ bool operator!= (const ACEXML_Attribute&rhs) const;
+
+private:
+ /// Namespace URI of an attribute
+ ACEXML_Char *uri_;
+
+ ACEXML_Char *localName_;
+ ACEXML_Char *qName_;
+ ACEXML_Char *type_;
+ ACEXML_Char *value_;
+};
+
+/**
+ * @typedef ACE_Array<ACEXML_Attribute> ACEXML_Attribute_Array
+ */
+typedef ACE_Array<ACEXML_Attribute> ACEXML_Attribute_Array;
+
+/**
+ * @class ACEXML_AttributesImpl AttributesImpl.h "ACEXML/common/AttributesImpl.h"
+ *
+ * @brief ACEXML_AttributesImpl provides the default implementation
+ * of interface ACEXML_Attributes.
+ *
+ * This class provides a default implementation of the SAX2 Attributes
+ * interface, with the addition of manipulators so that the list can
+ * be modified or reused.
+ *
+ * There are two typical uses of this class:
+ *
+ * - to take a persistent snapshot of an Attributes object in a
+ * startElement event; or
+ * - to construct or modify an Attributes object in a SAX2 driver or filter.
+ *
+ * This class replaces the now-deprecated SAX1 AttributeListImpl
+ * class; in addition to supporting the updated Attributes interface
+ * rather than the deprecated AttributeList interface, it also
+ * includes a much more efficient implementation using a single array
+ * rather than a set of Vectors.
+ *
+ * @sa ACEXML_Attributes
+ */
+class ACEXML_Export ACEXML_AttributesImpl
+ : public ACEXML_Attributes
+{
+public:
+ /**
+ * Initialize an AttributesImpl that holds <size> attributes.
+ */
+ ACEXML_AttributesImpl (int size = ACEXML_AttributesImpl_Default_Size);
+ ACEXML_AttributesImpl (const ACEXML_AttributesImpl &attrs);
+ virtual ~ACEXML_AttributesImpl (void);
+
+ /**
+ * Add a new attribute using the argument(s) supplied.
+ * Return -1 if an attribute with the same name already exists.
+ */
+ virtual int addAttribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value);
+ virtual int addAttribute (const ACEXML_Attribute &att);
+
+ /**
+ * Check for duplicate attributes.
+ */
+ virtual int isDuplicate (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName);
+ /**
+ * Remove an attribute from the array. Notice that this
+ * operation can invalidate previously acquired <index>
+ * value. (It will repack the array.)
+ */
+ virtual int removeAttribute (size_t index);
+
+
+ /**
+ * Look up the index of an attribute by XML 1.0 qualified name.
+ * Return -1 if we fail to find a match.
+ */
+ virtual int getIndex (const ACEXML_Char *qName);
+
+ /**
+ * Look up the index of an attribute by Namespace name.
+ * Return -1 if we fail to find a match.
+ */
+ virtual int getIndex (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart);
+
+ /**
+ * Return the number of attributes in the list.
+ */
+ virtual size_t getLength (void);
+
+ /**
+ * Look up an attribute's local name by index.
+ * Return 0 if index is out of range.
+ */
+ virtual const ACEXML_Char *getLocalName (size_t index);
+
+ /**
+ * Look up an attribute's XML 1.0 qualified name by index.
+ * Return 0 if index is out of range.
+ */
+ virtual const ACEXML_Char *getQName (size_t index);
+
+ /**
+ * Look up an attribute's type by index.
+ * Return 0 if index is out of range.
+ */
+ virtual const ACEXML_Char *getType (size_t index);
+
+ /**
+ * Look up an attribute's type by XML 1.0 qualified name.
+ * Return 0 if we fail to find a match.
+ */
+ virtual const ACEXML_Char *getType (const ACEXML_Char *qName);
+
+ /**
+ * Look up an attribute's type by Namespace name.
+ * Return 0 if we fail to find a match.
+ */
+ virtual const ACEXML_Char *getType (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart);
+
+ /**
+ * Look up an attribute's Namespace URI by index.
+ * Return 0 if index is out of range.
+ */
+ virtual const ACEXML_Char *getURI (size_t index);
+
+ /**
+ * Look up an attribute's value by index.
+ * Return 0 if index is out of range.
+ */
+ virtual const ACEXML_Char *getValue (size_t index);
+
+ /**
+ * Look up an attribute's value by XML 1.0 qualified name.
+ * Return 0 if we fail to find a match.
+ */
+ virtual const ACEXML_Char *getValue (const ACEXML_Char *qName);
+
+ /**
+ * Look up an attribute's value by Namespace name.
+ * Return 0 if we fail to find a match.
+ */
+ virtual const ACEXML_Char *getValue (const ACEXML_Char *uri,
+ const ACEXML_Char *localPart);
+
+ /**
+ * Set an attribute at index. Return -1 if index is out of
+ * range.
+ */
+ virtual int setAttribute (size_t index,
+ const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value);
+
+ /**
+ * Set the localName of the attribute at <index>.
+ * return -1 if <index> is out of range.
+ */
+ virtual int setLocalName (size_t index,
+ const ACEXML_Char *localName);
+
+ /**
+ * Set the qName of the attribute at <index>.
+ * return -1 if <index> is out of range.
+ */
+ virtual int setQName (size_t index,
+ const ACEXML_Char *qName);
+
+ /**
+ * Set the URI of the attribute at <index>.
+ * return -1 if <index> is out of range.
+ */
+ virtual int setURI (size_t index,
+ const ACEXML_Char *uri);
+
+ /**
+ * Set the type of the attribute at <index>.
+ * return -1 if <index> is out of range.
+ */
+ virtual int setType (size_t index,
+ const ACEXML_Char *type);
+
+ /**
+ * Set the value of the attribute at <index>.
+ * return -1 if <index> is out of range.
+ */
+ virtual int setValue (size_t index,
+ const ACEXML_Char *value);
+private:
+ /// Container for all attributes.
+ ACEXML_Attribute_Array attrs_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/AttributesImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_ATTRIBUTESIMPL_H */
diff --git a/ACE/ACEXML/common/AttributesImpl.i b/ACE/ACEXML/common/AttributesImpl.i
new file mode 100644
index 00000000000..75fc288950d
--- /dev/null
+++ b/ACE/ACEXML/common/AttributesImpl.i
@@ -0,0 +1,154 @@
+// -*- C++ -*-
+//
+//$Id$
+
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+
+ACEXML_INLINE
+ACEXML_Attribute::ACEXML_Attribute (void)
+ : uri_ (0),
+ localName_ (0),
+ qName_ (0),
+ type_ (0),
+ value_ (0)
+{
+}
+
+ACEXML_INLINE
+ACEXML_Attribute::ACEXML_Attribute (const ACEXML_Attribute &attr)
+ : uri_ (ACE::strnew (attr.uri_)),
+ localName_ (ACE::strnew (attr.localName_)),
+ qName_ (ACE::strnew (attr.qName_)),
+ type_ (ACE::strnew (attr.type_)),
+ value_ (ACE::strnew (attr.value_))
+{
+}
+
+ACEXML_INLINE
+ACEXML_Attribute::ACEXML_Attribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value)
+ : uri_ (ACE::strnew (uri)),
+ localName_ (ACE::strnew (localName)),
+ qName_ (ACE::strnew (qName)),
+ type_ (ACE::strnew (type)),
+ value_ (ACE::strnew (value))
+{
+}
+
+ACEXML_INLINE
+ACEXML_Attribute::~ACEXML_Attribute (void)
+{
+ delete[] this->uri_;
+ delete[] this->localName_;
+ delete[] this->qName_;
+ delete[] this->type_;
+ delete[] this->value_;
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Attribute::uri (void) const
+{
+ return this->uri_;
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::uri (const ACEXML_Char *uri)
+{
+ delete[] this->uri_;
+ this->uri_ = ACE::strnew (uri);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Attribute::localName (void) const
+{
+ return this->localName_;
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::localName (const ACEXML_Char *localName)
+{
+ delete[] this->localName_;
+ this->localName_ = ACE::strnew (localName);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Attribute::qName (void) const
+{
+ return this->qName_;
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::qName (const ACEXML_Char *qName)
+{
+ delete[] this->qName_;
+ this->qName_ = ACE::strnew (qName);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Attribute::type (void) const
+{
+ return this->type_;
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::type (const ACEXML_Char *type)
+{
+ delete[] this->type_;
+ this->type_ = ACE::strnew (type);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Attribute::value (void) const
+{
+ return this->value_;
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::value (const ACEXML_Char *value)
+{
+ delete[] this->value_;
+ this->value_ = ACE::strnew (value);
+}
+
+ACEXML_INLINE void
+ACEXML_Attribute::setAttribute (const ACEXML_Char *uri,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ const ACEXML_Char *type,
+ const ACEXML_Char *value)
+{
+ this->uri (uri);
+ this->qName (qName);
+ this->localName (localName);
+ this->type (type);
+ this->value (value);
+}
+
+ACEXML_INLINE ACEXML_Attribute &
+ACEXML_Attribute::operator= (const ACEXML_Attribute &rhs)
+{
+ if (this != &rhs) // Check for self assignment
+ {
+ this->uri (rhs.uri ());
+ this->qName (rhs.qName ());
+ this->localName (rhs.localName ());
+ this->type (rhs.type ());
+ this->value (rhs.value ());
+ }
+ return *this;
+}
+
+ACEXML_INLINE bool
+ACEXML_Attribute::operator!= (const ACEXML_Attribute &rhs) const
+{
+ return (ACE_OS::strcmp (this->uri_, rhs.uri ()) == 0 &&
+ ACE_OS::strcmp (this->localName_, rhs.localName ()) == 0 &&
+ ACE_OS::strcmp (this->qName_, rhs .qName ()) == 0 &&
+ ACE_OS::strcmp (this->type_, rhs.type ()) == 0 &&
+ ACE_OS::strcmp (this->value_, rhs.value ()) == 0 ? false : true);
+
+}
diff --git a/ACE/ACEXML/common/Attributes_Def_Builder.cpp b/ACE/ACEXML/common/Attributes_Def_Builder.cpp
new file mode 100644
index 00000000000..8b748dce3ce
--- /dev/null
+++ b/ACE/ACEXML/common/Attributes_Def_Builder.cpp
@@ -0,0 +1,14 @@
+// $Id$
+
+#include "ACEXML/common/Attributes_Def_Builder.h"
+
+ACEXML_Attribute_Def_Builder::~ACEXML_Attribute_Def_Builder ()
+{
+
+}
+
+ACEXML_Attributes_Def_Builder::~ACEXML_Attributes_Def_Builder ()
+{
+
+}
+
diff --git a/ACE/ACEXML/common/Attributes_Def_Builder.h b/ACE/ACEXML/common/Attributes_Def_Builder.h
new file mode 100644
index 00000000000..c0b5c144208
--- /dev/null
+++ b/ACE/ACEXML/common/Attributes_Def_Builder.h
@@ -0,0 +1,153 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Attributes_Def_Builder.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_ATTRIBUTES_DEF_BUILDER_H_
+#define _ACEXML_ATTRIBUTES_DEF_BUILDER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+#include "ace/Auto_Ptr.h"
+
+/**
+ * @class ACEXML_Attribute_Def_Builder Attributes_Def_Builder.h "common/Attributes_Def_Builder.h"
+ *
+ * @brief An abstract virtual class defining an interface for building an
+ * attribute definition from DTD.
+ *
+ * This class should be invisible to application programmers and is only
+ * used for validator implementors.
+ */
+class ACEXML_Export ACEXML_Attribute_Def_Builder
+{
+public:
+
+ typedef auto_ptr<ACEXML_Attribute_Def_Builder> VAR;
+
+ enum ATT_TYPE {
+ CDATA,
+ ID,
+ IDREF,
+ IDREFS,
+ ENTITY,
+ ENTITIES,
+ NMTOKEN,
+ NMTOKENS,
+ NOTATION,
+ ENUMERATION,
+ ERROR_TYPE
+ };
+
+ enum DEFAULT_DECL {
+ REQUIRED,
+ IMPLIED,
+ FIXED,
+ INVALID
+ };
+
+ virtual ~ACEXML_Attribute_Def_Builder () = 0;
+
+ /**
+ * Specify the name of the attribute.
+ */
+ virtual int setName (const ACEXML_Char *n) = 0;
+
+ /**
+ * Get the name of the attribute.
+ */
+ virtual const ACEXML_Char *getName (void) = 0;
+
+ /**
+ * Set the attribute type.
+ */
+ virtual int setAttType (const ATT_TYPE type ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Insert an element for NOTATION or ENUMERATION type attribute.
+ */
+ virtual int insertList (const ACEXML_Char *Name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Set default attribute declaration.
+ */
+ virtual int setDefault (const DEFAULT_DECL def,
+ const ACEXML_Char *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Check validity of the current attribute definition being built.
+ *
+ * @retval 0 if the attribute is not a valid combo.
+ */
+ virtual int validAttr (void) = 0;
+
+ /**
+ * Dump the content of the attribute definition.
+ */
+ virtual void dump (void) = 0;
+};
+
+/**
+ * @ class ACEXML_Attributes_Def_Builder Attributes_Def_Builder.h "common/Attributes_Def_Builder.h"
+ *
+ * @ brief An abstract virtual class defining an interface for building
+ * attribute definitions from DTD.
+ *
+ * This class should be invisible to application programmers and
+ * is only used for validator implementors.
+ */
+class ACEXML_Export ACEXML_Attributes_Def_Builder
+{
+public:
+
+ typedef auto_ptr<ACEXML_Attributes_Def_Builder> VAR;
+
+ virtual ~ACEXML_Attributes_Def_Builder () = 0;
+
+ /**
+ * Set the element name that the attribute builder applies.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int setElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Acquire an Attribute_Builder.
+ */
+ virtual ACEXML_Attribute_Def_Builder *getAttribute_Def_Builder () = 0;
+
+ /**
+ * Add a definition for one attribute.
+ */
+ virtual int insertAttribute (ACEXML_Attribute_Def_Builder *def ACEXML_ENV_ARG_DECL) = 0;
+
+
+ /**
+ * Dump the content of the attribute definition.
+ */
+ virtual void dump (void) = 0;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ATTRIBUTES_DEF_BUILDER_H_ */
diff --git a/ACE/ACEXML/common/CharStream.cpp b/ACE/ACEXML/common/CharStream.cpp
new file mode 100644
index 00000000000..2c6ea29600f
--- /dev/null
+++ b/ACE/ACEXML/common/CharStream.cpp
@@ -0,0 +1,7 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/CharStream.h"
+
+ACEXML_CharStream::~ACEXML_CharStream (void)
+{
+}
diff --git a/ACE/ACEXML/common/CharStream.h b/ACE/ACEXML/common/CharStream.h
new file mode 100644
index 00000000000..e0355d4721a
--- /dev/null
+++ b/ACE/ACEXML/common/CharStream.h
@@ -0,0 +1,88 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file CharStream.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_CHARSTREAM_H_
+#define _ACEXML_CHARSTREAM_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_CharStream CharStream.h "ACEXML/common/CharStream.h"
+ *
+ * ACEXML_CharStream is an abstract class (interface) which defines the
+ * basic opertions a parser could use to retrieve XML charater sequence.
+ * The sequence can be read from a file or a character buffer.
+ */
+class ACEXML_Export ACEXML_CharStream
+{
+public:
+
+ /**
+ * Virtual destructor, must have.
+ */
+ virtual ~ACEXML_CharStream () = 0;
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void) = 0;
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void) = 0;
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed.
+ */
+ virtual int get (ACEXML_Char& ch) = 0;
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str, size_t len) = 0;
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if succeess, -1 if EOS is reached.
+ */
+ virtual int peek (void) = 0;
+
+ /**
+ * Resets the pointer to the beginning of the stream.
+ */
+ virtual void rewind (void) = 0;
+
+ /*
+ * Get the character encoding for a byte stream or URI.
+ */
+ virtual const ACEXML_Char *getEncoding (void) = 0;
+
+ /*
+ * Get the systemId for the underlying CharStream
+ */
+ virtual const ACEXML_Char* getSystemId (void) = 0;
+
+};
+
+#include /**/ "ace/post.h"
+
+
+#endif /* _ACEXML_CHARSTREAM_H_ */
diff --git a/ACE/ACEXML/common/ContentHandler.cpp b/ACE/ACEXML/common/ContentHandler.cpp
new file mode 100644
index 00000000000..633342fd6b1
--- /dev/null
+++ b/ACE/ACEXML/common/ContentHandler.cpp
@@ -0,0 +1,11 @@
+#include "ContentHandler.h"
+
+
+ACE_RCSID (common,
+ ContentHandler,
+ "$Id$")
+
+
+ACEXML_ContentHandler::~ACEXML_ContentHandler (void)
+{
+}
diff --git a/ACE/ACEXML/common/ContentHandler.h b/ACE/ACEXML/common/ContentHandler.h
new file mode 100644
index 00000000000..f1bee32a75d
--- /dev/null
+++ b/ACE/ACEXML/common/ContentHandler.h
@@ -0,0 +1,131 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ContentHandler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_CONTENTHANDLER_H_
+#define _ACEXML_CONTENTHANDLER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+#include "ACEXML/common/Locator.h"
+#include "ACEXML/common/Attributes.h"
+
+/**
+ * @class ACEXML_ContentHandler ContentHandler.h "ACEXML/common/ContentHandler.h"
+ *
+ * @brief ACEXML_ContentHandler
+ *
+ * This is the main interface that most SAX applications implement: if the
+ * application needs to be informed of basic parsing events, it implements
+ * this interface and registers an instance with the SAX parser using the
+ * setContentHandler method. The parser uses the instance to report basic
+ * document-related events like the start and end of elements and character
+ * data.
+ *
+ * The order of events in this interface is very important, and mirrors the
+ * order of information in the document itself. For example, all of an
+ * element's content (character data, processing instructions, and/or
+ * subelements) will appear, in order, between the startElement event and
+ * the corresponding endElement event.
+ */
+class ACEXML_Export ACEXML_ContentHandler
+{
+public:
+
+ virtual ~ACEXML_ContentHandler (void);
+
+ /**
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator) = 0;
+
+ /**
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+};
+
+#include /**/ "ace/post.h"
+
+
+#endif /* _ACEXML_CONTENTHANDLER_H_ */
diff --git a/ACE/ACEXML/common/DTDHandler.cpp b/ACE/ACEXML/common/DTDHandler.cpp
new file mode 100644
index 00000000000..199f469b578
--- /dev/null
+++ b/ACE/ACEXML/common/DTDHandler.cpp
@@ -0,0 +1,11 @@
+#include "DTDHandler.h"
+
+
+ACE_RCSID (common,
+ DTDHandler,
+ "$Id$")
+
+
+ACEXML_DTDHandler::~ACEXML_DTDHandler (void)
+{
+}
diff --git a/ACE/ACEXML/common/DTDHandler.h b/ACE/ACEXML/common/DTDHandler.h
new file mode 100644
index 00000000000..4f5f785552c
--- /dev/null
+++ b/ACE/ACEXML/common/DTDHandler.h
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file DTDHandler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_DTDHANDLER_H_
+#define _ACEXML_DTDHANDLER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+
+/**
+ * @class ACEXML_DTDHandler DTDHandler.h "ACEXML/common/DTDHandler.h"
+ *
+ * @brief ACEXML_DTDHandler
+ *
+ * If a SAX application needs information about notations and unparsed
+ * entities, then the application implements this interface and registers
+ * an instance with the SAX parser using the parser's setDTDHandler method.
+ * The parser uses the instance to report notation and unparsed entity
+ * declarations to the application.
+ *
+ * Note that this interface includes only those DTD events that the XML
+ * recommendation requires processors to report: notation and unparsed
+ * entity declarations.
+ *
+ * The SAX parser may report these events in any order, regardless of the
+ * order in which the notations and unparsed entities were declared;
+ * however, all DTD events must be reported after the document handler's
+ * startDocument event, and before the first startElement event.
+ *
+ * It is up to the application to store the information for future use
+ * (perhaps in a hash table or object tree). If the application encounters
+ * attributes of type "NOTATION", "ENTITY", or "ENTITIES", it can use the
+ * information that it obtained through this interface to find the entity
+ * and/or notation corresponding with the attribute value.
+ */
+class ACEXML_Export ACEXML_DTDHandler
+{
+public:
+
+ virtual ~ACEXML_DTDHandler (void);
+
+ /**
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_DTDHANDLER_H_ */
diff --git a/ACE/ACEXML/common/DTD_Manager.cpp b/ACE/ACEXML/common/DTD_Manager.cpp
new file mode 100644
index 00000000000..39b3d2acef0
--- /dev/null
+++ b/ACE/ACEXML/common/DTD_Manager.cpp
@@ -0,0 +1,8 @@
+// $Id$
+
+#include "ACEXML/common/DTD_Manager.h"
+
+ACEXML_DTD_Manager::~ACEXML_DTD_Manager ()
+{
+
+}
diff --git a/ACE/ACEXML/common/DTD_Manager.h b/ACE/ACEXML/common/DTD_Manager.h
new file mode 100644
index 00000000000..51ab3791551
--- /dev/null
+++ b/ACE/ACEXML/common/DTD_Manager.h
@@ -0,0 +1,82 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file DTD_Manager.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_DTD_Manager_H_
+#define _ACEXML_DTD_Manager_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Attributes_Def_Builder.h"
+#include "ACEXML/common/Element_Def_Builder.h"
+#include "ACEXML/common/Validator.h"
+
+/**
+ * @class ACEXML_DTD_Manager DTD_Manager.h "common/DTD_Manager.h"
+ *
+ * @todo Fill in the blank.
+ */
+class ACEXML_Export ACEXML_DTD_Manager
+{
+public:
+ virtual ~ACEXML_DTD_Manager () = 0;
+
+ /**
+ * Acquire a pointer to an element definition builder.
+ * The XML parser use this interface to acquire the
+ * definition builder and use the builder to create
+ * the DTD element definition. The resulting builder
+ * is then registered with the DTD Manager or destroyed
+ * if error occured when the builder encountered errors.
+ *
+ * @retval 0 if error occurs creating the builder.
+ */
+ virtual ACEXML_Element_Def_Builder *getElement_Def_Builder () = 0;
+
+ /**
+ * Insert a new element definition into the DTD Manager.
+ *
+ * @retval 0 if success, -1 if error.
+ */
+ virtual int insertElement_Definition (ACEXML_Element_Def_Builder *def ACEXML_ENV_ARG_DECL) = 0;
+
+ /**
+ * Acquire a pointer to an attributes definition builder.
+ *
+ */
+ virtual ACEXML_Attributes_Def_Builder *getAttribute_Def_Builder () = 0;
+
+ /**
+ * Insert a new attributes definition into the DTD Manager.
+ *
+ * @retval 0 if success, -1 otherwise.
+ */
+ virtual int insertAttributes_Definition (ACEXML_Attributes_Def_Builder *def ACEXML_ENV_ARG_DECL) = 0;
+
+ /**
+ * Acquire an element validator to validate an XML element.
+ *
+ * @todo I haven't figured out what memory management scheme
+ * we should use for the acquired validator.
+ */
+ virtual ACEXML_Validator *getValidator (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_DTD_Manager_H_ */
diff --git a/ACE/ACEXML/common/DefaultHandler.cpp b/ACE/ACEXML/common/DefaultHandler.cpp
new file mode 100644
index 00000000000..25e2f4dcf9d
--- /dev/null
+++ b/ACE/ACEXML/common/DefaultHandler.cpp
@@ -0,0 +1,159 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/DefaultHandler.h"
+
+ACEXML_DefaultHandler::ACEXML_DefaultHandler (void)
+{
+ // no-op
+}
+
+ACEXML_DefaultHandler::~ACEXML_DefaultHandler (void)
+{
+ // no-op
+}
+
+void
+ACEXML_DefaultHandler::characters (const ACEXML_Char *,
+ int,
+ int
+ ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::endDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::endElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::endPrefixMapping (const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::ignorableWhitespace (const ACEXML_Char *,
+ int,
+ int ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::processingInstruction (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::setDocumentLocator (ACEXML_Locator * )
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::skippedEntity (const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::startDocument (ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::startElement (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ ACEXML_Attributes * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::startPrefixMapping (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+ // *** Methods inherited from ACEXML_DTDHandler.
+
+void
+ACEXML_DefaultHandler::notationDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::unparsedEntityDecl (const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+ // Methods inherited from ACEXML_EntityResolver.
+
+ACEXML_InputSource *
+ACEXML_DefaultHandler::resolveEntity (const ACEXML_Char *,
+ const ACEXML_Char * ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+ return 0;
+}
+
+ // Methods inherited from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+void
+ACEXML_DefaultHandler::error (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::fatalError (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
+
+void
+ACEXML_DefaultHandler::warning (ACEXML_SAXParseException & ACEXML_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ // No-op.
+}
diff --git a/ACE/ACEXML/common/DefaultHandler.h b/ACE/ACEXML/common/DefaultHandler.h
new file mode 100644
index 00000000000..149254c18e6
--- /dev/null
+++ b/ACE/ACEXML/common/DefaultHandler.h
@@ -0,0 +1,191 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file DefaultHandler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef ACEXML_DEFAULTHANDLER_H
+#define ACEXML_DEFAULTHANDLER_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/ContentHandler.h"
+#include "ACEXML/common/DTDHandler.h"
+#include "ACEXML/common/EntityResolver.h"
+#include "ACEXML/common/ErrorHandler.h"
+
+/**
+ * @class ACEXML_DefaultHandler DefaultHandler.h "ACEXML/common/DefaultHandler.h"
+ *
+ * @brief ACEXML_DefaultHandler
+ *
+ * This class is available as a convenience base class for SAX2
+ * applications: it provides default implementations for all of the
+ * callbacks in the four core SAX2 handler classes:
+ *
+ * - EntityResolver
+ * - DTDHandler
+ * - ContentHandler
+ * - ErrorHandler
+ *
+ * Application writers can extend this class when they need to implement
+ * only part of an interface; parser writers can instantiate this class to
+ * provide default handlers when the application has not supplied its own.
+ */
+class ACEXML_Export ACEXML_DefaultHandler
+ : public ACEXML_ContentHandler,
+ public ACEXML_DTDHandler,
+ public ACEXML_EntityResolver,
+ public ACEXML_ErrorHandler
+{
+public:
+ /**
+ * Default constructor.
+ */
+ ACEXML_DefaultHandler (void);
+
+ /**
+ * destructor.
+ */
+ virtual ~ACEXML_DefaultHandler (void);
+
+ // Methods inherit from ACEXML_ContentHandler.
+
+ /*
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator) ;
+
+ /*
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // *** Methods inherit from ACEXML_DTDHandler.
+
+ /*
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // Methods inherit from ACEXML_EnitityResolver.
+
+ /*
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_DEFAULTHANDLER_H */
diff --git a/ACE/ACEXML/common/Element_Def_Builder.cpp b/ACE/ACEXML/common/Element_Def_Builder.cpp
new file mode 100644
index 00000000000..2bcef84f16d
--- /dev/null
+++ b/ACE/ACEXML/common/Element_Def_Builder.cpp
@@ -0,0 +1,9 @@
+// $Id$
+
+#include "ACEXML/common/Element_Def_Builder.h"
+
+ACEXML_Element_Def_Builder::~ACEXML_Element_Def_Builder ()
+{
+
+}
+
diff --git a/ACE/ACEXML/common/Element_Def_Builder.h b/ACE/ACEXML/common/Element_Def_Builder.h
new file mode 100644
index 00000000000..9854dfad295
--- /dev/null
+++ b/ACE/ACEXML/common/Element_Def_Builder.h
@@ -0,0 +1,133 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Element_Def_Builder.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_ELEMENT_DEF_BUILDER_H_
+#define _ACEXML_ELEMENT_DEF_BUILDER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+#include "ace/Auto_Ptr.h"
+#include "ACEXML/common/XML_Types.h"
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+
+/**
+ * @class ACEXML_Element_Def_Builder Element_Def_Builder.h "common/Element_Def_Builder.h"
+ *
+ * @brief An abstract virtual class that defines the interface to define an
+ * element definition.
+ *
+ * This class defines how to define an element definition after parsing a
+ * DTD.
+ */
+class ACEXML_Export ACEXML_Element_Def_Builder
+{
+public:
+
+ typedef auto_ptr<ACEXML_Element_Def_Builder> VAR;
+
+ typedef enum {
+ EMPTY,
+ ANY,
+ MIXED,
+ CHILDREN,
+ UNDEFINED
+ } CONTENT_TYPE;
+
+ typedef enum {
+ ONE,
+ ZERO_OR_MORE,
+ ONE_OR_MORE,
+ ONE_OR_ZERO
+ } CARDINALITY;
+
+ virtual ~ACEXML_Element_Def_Builder () = 0;
+
+ /**
+ * Define the name of the element.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int setElementName (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Define the content type of the element.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int setContentType (CONTENT_TYPE type ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Insert one more element into Mixed definition.
+ */
+ virtual int insertMixedElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Start a new group of children.
+ */
+ virtual int startChildGroup () = 0;
+
+ /**
+ * End a new group of children.
+ *
+ * @retval 0 on success.
+ */
+ virtual int endChildGroup (CARDINALITY card ACEXML_ENV_ARG_DECL) = 0;
+
+ /**
+ * Set the type of current child group to Choice.
+ *
+ * @retval 0 on success, -1 if the type of the child group has
+ * already been set and this action conflicts with the previous
+ * setting.
+ */
+ virtual int setChoice () = 0;
+
+ /**
+ * Set the type of current child group to Sequence.
+ *
+ * @retval 0 on success, -1 if the type of the child group has
+ * already been set and this action conflicts with the previous
+ * setting.
+ */
+ virtual int setSequence () = 0;
+
+ /**
+ * Insert an new element into the current child group.
+ *
+ * @retval 0 on success, -1 otherwise.
+ */
+ virtual int insertElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Dump the content of the attribute definition.
+ */
+ virtual void dump (void) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ELEMENT_DEF_BUILDER_H_ */
diff --git a/ACE/ACEXML/common/Encoding.cpp b/ACE/ACEXML/common/Encoding.cpp
new file mode 100644
index 00000000000..4531fad20c3
--- /dev/null
+++ b/ACE/ACEXML/common/Encoding.cpp
@@ -0,0 +1,59 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/Encoding.h"
+#include "ace/OS_NS_string.h"
+
+const ACEXML_Char* ACEXML_Encoding::encoding_names_[8] = {
+ ACE_TEXT ("UCS-4BE"),
+ ACE_TEXT ("UCS-4LE"),
+ ACE_TEXT ("UCS-4_2143"),
+ ACE_TEXT ("UCS-4_3412"),
+ ACE_TEXT ("UTF-16"),
+ ACE_TEXT ("UTF-16"),
+ ACE_TEXT ("UTF-8"),
+ ACE_TEXT ("Unsupported Encoding")
+};
+
+const ACEXML_UTF8 ACEXML_Encoding::byte_order_mark_[][4] = {
+ { '\x00', '\x00', '\xFE', '\xFF' }, // UCS-4, big-endian (1234 order)
+ { '\xFF', '\xFE', '\x00', '\x00' }, // UCS-4, little-endian (4321 order)
+ { '\x00', '\x00', '\xFF', '\xFE' }, // UCS-4, unusual octet order (2143)
+ { '\xFE', '\xFF', '\x00', '\x00' }, // UCS-4, unusual octet order (3412)
+ { '\xFE', '\xFF', '\xFF', '\xFF' }, // UTF-16, big-endian (3 & 4 != 0)
+ { '\xFF', '\xFE', '\xFF', '\xFF' }, // UTF-16, little-endian ( 3 & 4 != 0)
+ { '\xEF', '\xBB', '\xBF', '\xFF' } // UTF-8
+};
+
+const ACEXML_UTF8 ACEXML_Encoding::magic_values_[][4] = {
+ { '\x00', '\x00', '\x00', '\x3c' }, //
+ { '\x3c', '\x00', '\x00', '\x00' }, // UCS-4 and variants
+ { '\x00', '\x00', '\x3c', '\x00' }, //
+ { '\x00', '\x3c', '\x00', '\x00' }, //
+ { '\x00', '\x3c', '\x00', '\x3f' }, // UTF-16BE
+ { '\x3c', '\x00', '\x3f', '\x00' }, // UTF-16LE
+ { '\x3c', '\x3f', '\x78', '\x6d' }, // UTF-8
+};
+
+const ACEXML_Char*
+ACEXML_Encoding::get_encoding (const char* input)
+{
+ if ((ACE_OS::memcmp (&ACEXML_Encoding::byte_order_mark_[ACEXML_Encoding::UTF16BE][0], input, 2) == 0)
+ && (input[2] != 0 || input[3] != 0)) // 3 & 4 should not be both zero
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16BE];
+ else if ((ACE_OS::memcmp (&ACEXML_Encoding::byte_order_mark_[ACEXML_Encoding::UTF16LE][0], input, 2) == 0)
+ && (input[2] != 0 || input[3] != 0)) // 3 & 4 should not be both zero
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16LE];
+ else if (ACE_OS::memcmp (&ACEXML_Encoding::byte_order_mark_[ACEXML_Encoding::UTF8][0], input, 3) == 0)
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF8];
+ else if (ACE_OS::memcmp (&ACEXML_Encoding::magic_values_[ACEXML_Encoding::UTF16BE][0], input, 4) == 0)
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16BE];
+ else if (ACE_OS::memcmp (&ACEXML_Encoding::magic_values_[ACEXML_Encoding::UTF16LE][0], input, 4) == 0)
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF16LE];
+ else if (ACE_OS::memcmp (&ACEXML_Encoding::magic_values_[ACEXML_Encoding::UTF8][0], input, 4) == 0)
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF8];
+ else
+ {
+ // ACE_ERROR ((LM_ERROR, "Unknown encoding. Assuming UTF-8\n"));
+ return ACEXML_Encoding::encoding_names_[ACEXML_Encoding::UTF8];
+ }
+}
diff --git a/ACE/ACEXML/common/Encoding.h b/ACE/ACEXML/common/Encoding.h
new file mode 100644
index 00000000000..3e957fabbe1
--- /dev/null
+++ b/ACE/ACEXML/common/Encoding.h
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Encoding.h
+ *
+ * This file provides utility functions to determine the encoding of a file
+ * or a byte stream automatically.
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_ENCODING_H
+#define _ACEXML_ENCODING_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_Encoding Encoding.h "ACEXML/common/Encoding.h"
+ *
+ * @brief ACEXML_Encoding
+ *
+ * Wrapper class for determining the encoding of a file or a byte stream.
+ */
+class ACEXML_Export ACEXML_Encoding
+{
+public:
+ enum {
+ UCS4BE,
+ UCS4LE,
+ UCS4_2143,
+ UCS4_3412,
+ UTF16BE,
+ UTF16LE,
+ UTF8,
+ OTHER
+ } ENCODING;
+
+ static const ACEXML_Char* encoding_names_[8];
+
+ static const ACEXML_UTF8 byte_order_mark_[][4];
+
+ static const ACEXML_UTF8 magic_values_[][4];
+
+ static const ACEXML_Char* get_encoding (const char* input);
+
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ENCODING_H */
diff --git a/ACE/ACEXML/common/EntityResolver.cpp b/ACE/ACEXML/common/EntityResolver.cpp
new file mode 100644
index 00000000000..bcd08c1af70
--- /dev/null
+++ b/ACE/ACEXML/common/EntityResolver.cpp
@@ -0,0 +1,11 @@
+#include "EntityResolver.h"
+
+
+ACE_RCSID (common,
+ EntityResolver,
+ "$Id$")
+
+
+ACEXML_EntityResolver::~ACEXML_EntityResolver (void)
+{
+}
diff --git a/ACE/ACEXML/common/EntityResolver.h b/ACE/ACEXML/common/EntityResolver.h
new file mode 100644
index 00000000000..80311b34d52
--- /dev/null
+++ b/ACE/ACEXML/common/EntityResolver.h
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file EntityResolver.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_ENTITYHANDLER_H_
+#define _ACEXML_ENTITYHANDLER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/InputSource.h"
+#include "ACEXML/common/SAXExceptions.h"
+
+/**
+ * @class ACEXML_EntityResolver EntityResolver.h "ACEXML/common/EntityResolver.h"
+ *
+ * @brief ACEXML_EntityResolver
+ *
+ * If a SAX application needs to implement customized handling for
+ * external entities, it must implement this interface and register an
+ * instance with the SAX driver using the setEntityResolver method.
+ *
+ * The XML reader will then allow the application to intercept any
+ * external entities (including the external DTD subset and external
+ * parameter entities, if any) before including them.
+ *
+ * Many SAX applications will not need to implement this interface,
+ * but it will be especially useful for applications that build XML
+ * documents from databases or other specialised input sources, or for
+ * applications that use URI types other than URLs.
+ */
+class ACEXML_Export ACEXML_EntityResolver
+{
+public:
+
+ virtual ~ACEXML_EntityResolver (void);
+
+ /**
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ENTITYHANDLER_H_ */
diff --git a/ACE/ACEXML/common/Env.cpp b/ACE/ACEXML/common/Env.cpp
new file mode 100644
index 00000000000..6d1ce2158d6
--- /dev/null
+++ b/ACE/ACEXML/common/Env.cpp
@@ -0,0 +1,34 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/Env.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/Env.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_Env::ACEXML_Env (void)
+ : exception_ (0)
+{
+}
+
+ACEXML_Env::ACEXML_Env (const ACEXML_Env &rhs)
+ : exception_ (0)
+{
+ if (rhs.exception())
+ this->exception_ = rhs.exception_->duplicate();
+}
+
+ACEXML_Env&
+ACEXML_Env::operator= (const ACEXML_Env& rhs)
+{
+ ACEXML_Env tmp (rhs);
+ ACEXML_Exception* tmp_ex = this->exception_;
+ this->exception_ = tmp.exception_;
+ tmp.exception_ = tmp_ex;
+ return *this;
+}
+
+ACEXML_Env::~ACEXML_Env (void)
+{
+ this->clear();
+}
diff --git a/ACE/ACEXML/common/Env.h b/ACE/ACEXML/common/Env.h
new file mode 100644
index 00000000000..c17bba6a4bc
--- /dev/null
+++ b/ACE/ACEXML/common/Env.h
@@ -0,0 +1,72 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Env.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_ENV_H_
+#define _ACEXML_ENV_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Macros.h"
+#include "ACEXML/common/Exception.h"
+
+/**
+ * @class ACEXML_Env Env.h "ACEXML/common/Env.h"
+ *
+ * @brief ACEXML_Env
+ *
+ * ACEXML_Env is modeled after CORBA_Environment class. It provides a place
+ * holder for callees to propagate exceptions back to callers. ACEXML does
+ * not support native exceptions at this moment.
+ *
+ * @sa ACEXML_Exception
+ */
+class ACEXML_Export ACEXML_Env
+{
+public:
+ /// Default constructor.
+ ACEXML_Env (void);
+
+ /// Copy constructor.
+ ACEXML_Env (const ACEXML_Env& ACEXML_TRY_ENV);
+
+ /// Assignment
+ ACEXML_Env& operator= (const ACEXML_Env& ACEXML_TRY_ENV);
+
+ /// Destructor.
+ ~ACEXML_Env (void);
+
+ /// Return the contained exception.
+ ACEXML_Exception *exception (void) const;
+
+ /// Set the contained exception to @arg ex
+ void exception (ACEXML_Exception* ex);
+
+ /// Clear the exception and reset the evnrionment.
+ void clear (void);
+
+private:
+ /// Place holder for exception (if one occurs.)
+ ACEXML_Exception *exception_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/Env.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ENV_H_ */
diff --git a/ACE/ACEXML/common/Env.i b/ACE/ACEXML/common/Env.i
new file mode 100644
index 00000000000..95c3f41c8aa
--- /dev/null
+++ b/ACE/ACEXML/common/Env.i
@@ -0,0 +1,25 @@
+// -*- C++ -*- $Id$
+
+#include "ace/Log_Msg.h" /* to get ACE_ASSERT */
+#include "ACEXML/common/Exception.h"
+
+ACEXML_INLINE ACEXML_Exception *
+ACEXML_Env::exception (void) const
+{
+ return this->exception_;
+}
+
+ACEXML_INLINE void
+ACEXML_Env::exception (ACEXML_Exception *ex)
+{
+ ACE_ASSERT (ex != this->exception_);
+ this->clear();
+ this->exception_ = ex;
+}
+
+ACEXML_INLINE void
+ACEXML_Env::clear (void)
+{
+ delete this->exception_;
+ this->exception_ = 0;
+}
diff --git a/ACE/ACEXML/common/ErrorHandler.cpp b/ACE/ACEXML/common/ErrorHandler.cpp
new file mode 100644
index 00000000000..42d9552d859
--- /dev/null
+++ b/ACE/ACEXML/common/ErrorHandler.cpp
@@ -0,0 +1,11 @@
+#include "ErrorHandler.h"
+
+
+ACE_RCSID (common,
+ ErrorHandler,
+ "$Id$")
+
+
+ACEXML_ErrorHandler::~ACEXML_ErrorHandler (void)
+{
+}
diff --git a/ACE/ACEXML/common/ErrorHandler.h b/ACE/ACEXML/common/ErrorHandler.h
new file mode 100644
index 00000000000..7103aaceaf5
--- /dev/null
+++ b/ACE/ACEXML/common/ErrorHandler.h
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ErrorHandler.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_ERRORHANDLER_H_
+#define _ACEXML_ERRORHANDLER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+
+/**
+ * @class ACEXML_ErrorHandler ErrorHandler.h "ACEXML/common/ErrorHandler.h"
+ *
+ * @brief ACEXML_ErrorHandler
+ *
+ * If a SAX application needs to implement customized error handling,
+ * it must implement this interface and then register an instance with
+ * the XML reader using the setErrorHandler method. The parser will
+ * then report all errors and warnings through this interface.
+ *
+ * @b WARNING: If an application does not register an ErrorHandler,
+ * XML parsing errors will go unreported and bizarre behaviour may
+ * result.
+ *
+ * For XML processing errors, a SAX driver must use this interface
+ * instead of throwing an exception: it is up to the application to
+ * decide whether to throw an exception for different types of errors
+ * and warnings. Note, however, that there is no requirement that the
+ * parser continue to provide useful information after a call to
+ * fatalError (in other words, a SAX driver class could catch an
+ * exception and report a fatalError).
+ */
+class ACEXML_Export ACEXML_ErrorHandler
+{
+public:
+
+ virtual ~ACEXML_ErrorHandler (void);
+
+ /**
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_ERRORHANDLER_H_ */
diff --git a/ACE/ACEXML/common/Exception.cpp b/ACE/ACEXML/common/Exception.cpp
new file mode 100644
index 00000000000..65d3c373091
--- /dev/null
+++ b/ACE/ACEXML/common/Exception.cpp
@@ -0,0 +1,36 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/Exception.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/OS_NS_string.h"
+
+const ACEXML_Char *ACEXML_Exception::exception_name_ = ACE_TEXT ("ACEXML_Exception");
+
+const ACEXML_Char *ACEXML_Exception::null_ = ACE_TEXT ("");
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/Exception.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_Exception::ACEXML_Exception()
+{
+}
+
+ACEXML_Exception::~ACEXML_Exception()
+{
+}
+
+int
+ACEXML_Exception::is_a (const ACEXML_Char *name)
+{
+ return ACE_OS::strcmp (ACEXML_Exception::exception_name_, name) == 0;
+}
+
+void
+ACEXML_Exception::print (void)
+{
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACEXML: (%P|%t) EXCEPTION : %s\n"),
+ this->exception_name_));
+}
diff --git a/ACE/ACEXML/common/Exception.h b/ACE/ACEXML/common/Exception.h
new file mode 100644
index 00000000000..09995b473fa
--- /dev/null
+++ b/ACE/ACEXML/common/Exception.h
@@ -0,0 +1,87 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Exception.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_EXCEPTION_H_
+#define _ACEXML_EXCEPTION_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+#include "ACEXML/common/XML_Macros.h"
+
+#if defined (ACE_USES_NATIVE_EXCEPTIONS)
+# define ACEXML_RAISE(EXCEPTION) throw EXCEPTION
+#else
+# define ACEXML_RAISE(EXCEPTION)
+#endif
+
+
+/**
+ * @class ACEXML_Exception Exception.h "ACEXML/common/Exception.h"
+ *
+ * @brief ACEXML_Exception
+ *
+ * ACEXML_Exception is the base class for all ACEXML related exceptions.
+ * Since ACEXML currently does not support native exceptions, all
+ * exceptions should be thrown thru ACEXML_Env.
+ *
+ * @sa ACEXML_Env
+ */
+class ACEXML_Export ACEXML_Exception
+{
+public:
+
+ /// Destructor.
+ virtual ~ACEXML_Exception (void);
+
+ /// Throw the exception.
+ virtual void _raise (void) = 0;
+
+ /// Static narrow operation.
+ static ACEXML_Exception* _downcast (ACEXML_Exception* ex);
+
+ /// Return the exception type. (for safe downcast.)
+ virtual const ACEXML_Char *id (void) const ;
+
+ /// Dynamically create a copy of this exception.
+ virtual ACEXML_Exception *duplicate (void) const = 0;
+
+ /// Check whether this is an exception of type specified by <name>.
+ virtual int is_a (const ACEXML_Char *name);
+
+ /// Print out exception using ACE_DEBUG.
+ virtual void print (void) = 0;
+
+protected:
+ /// Default contructor.
+ ACEXML_Exception (void);
+
+ /// All exceptions have names. This name is used to identify the
+ /// type of an exception.
+ static const ACEXML_Char *exception_name_;
+
+ /// A null string that we return when there is no exception.
+ static const ACEXML_Char *null_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/Exception.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_EXCEPTION_H_ */
diff --git a/ACE/ACEXML/common/Exception.i b/ACE/ACEXML/common/Exception.i
new file mode 100644
index 00000000000..e2d97fa37ea
--- /dev/null
+++ b/ACE/ACEXML/common/Exception.i
@@ -0,0 +1,13 @@
+// -*- C++ -*- $Id$
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_Exception::id (void) const
+{
+ return ACEXML_Exception::exception_name_;
+}
+
+ACEXML_INLINE ACEXML_Exception*
+ACEXML_Exception::_downcast (ACEXML_Exception* x)
+{
+ return x;
+}
diff --git a/ACE/ACEXML/common/FileCharStream.cpp b/ACE/ACEXML/common/FileCharStream.cpp
new file mode 100644
index 00000000000..cafc0696b5c
--- /dev/null
+++ b/ACE/ACEXML/common/FileCharStream.cpp
@@ -0,0 +1,255 @@
+// $Id$
+
+#include "ACEXML/common/FileCharStream.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_sys_stat.h"
+
+#if defined (ACE_USES_WCHAR)
+# include "ace/OS_NS_wchar.h"
+#endif /* ACE_USES_WCHAR */
+
+ACEXML_FileCharStream::ACEXML_FileCharStream (void)
+ : filename_ (0), encoding_ (0), size_ (0), infile_ (0), peek_ (0)
+{
+}
+
+ACEXML_FileCharStream::~ACEXML_FileCharStream (void)
+{
+ this->close();
+}
+
+int
+ACEXML_FileCharStream::open (const ACEXML_Char *name)
+{
+ delete[] this->filename_;
+ this->filename_ = 0;
+
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+
+ this->infile_ = ACE_OS::fopen (name, ACE_TEXT ("r"));
+ if (this->infile_ == 0)
+ return -1;
+
+ ACE_stat statbuf;
+ if (ACE_OS::stat (name, &statbuf) < 0)
+ return -1;
+
+ this->size_ = statbuf.st_size;
+ this->filename_ = ACE::strnew (name);
+ return this->determine_encoding();
+}
+
+int
+ACEXML_FileCharStream::determine_encoding (void)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ char input[4];
+ int retval = 0;
+ int i = 0;
+ for (; i < 4 && retval != -1; ++i)
+ retval = this->getchar_i(input[i]);
+ if (i < 4)
+ return -1;
+
+ // Rewind the stream
+ ACE_OS::rewind (this->infile_);
+
+ const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input);
+ if (!temp)
+ return -1;
+ else
+ {
+ if (this->encoding_)
+ delete [] this->encoding_;
+ this->encoding_ = ACE::strnew (temp);
+// ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("File's encoding is %s\n"),
+// this->encoding_));
+ }
+ // Move over the byte-order-mark if present.
+ char ch;
+ for (int j = 0; j < 3; ++j)
+ {
+ if (this->getchar_i (ch) < 0)
+ return -1;
+ if (ch == '\xFF' || ch == '\xFE' || ch == '\xEF' || ch == '\xBB' ||
+ ch == '\xBF')
+ continue;
+ else
+ {
+ ungetc (ch, this->infile_);
+ break;
+ }
+ }
+ return 0;
+}
+
+void
+ACEXML_FileCharStream::rewind()
+{
+ if (this->infile_ == 0)
+ return;
+ ACE_OS::rewind (this->infile_);
+ this->determine_encoding();
+}
+
+int
+ACEXML_FileCharStream::available (void)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ long curr;
+ if ((curr = ACE_OS::ftell (this->infile_)) < 0)
+ return -1;
+ return (this->size_ - curr);
+}
+
+int
+ACEXML_FileCharStream::close (void)
+{
+ if (this->infile_ != 0)
+ {
+ ACE_OS::fclose (this->infile_);
+ this->infile_ = 0;
+ }
+ delete[] this->filename_;
+ this->filename_ = 0;
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+ this->size_ = 0;
+ this->peek_ = 0;
+ return 0;
+}
+
+
+int
+ACEXML_FileCharStream::getchar_i (char& ch)
+{
+ ch = static_cast<char> (ACE_OS::fgetc (this->infile_));
+ return (feof(this->infile_) ? -1 : 0);
+}
+
+int
+ACEXML_FileCharStream::read (ACEXML_Char *str,
+ size_t len)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ return static_cast<int> (ACE_OS::fread (str, sizeof (ACEXML_Char), len, this->infile_));
+}
+
+int
+ACEXML_FileCharStream::get (ACEXML_Char& ch)
+{
+ if (this->infile_ == 0)
+ return -1;
+#if defined (ACE_USES_WCHAR)
+ return this->get_i (ch);
+#else
+ ch = (ACEXML_Char) ACE_OS::fgetc (this->infile_);
+ return (feof(this->infile_) ? -1 : 0);
+#endif /* ACE_USES_WCHAR */
+}
+
+int
+ACEXML_FileCharStream::peek (void)
+{
+ if (this->infile_ == 0)
+ return -1;
+#if defined (ACE_USES_WCHAR)
+ return this->peek_i();
+#else
+
+ ACEXML_Char ch = static_cast<ACEXML_Char> (ACE_OS::fgetc (this->infile_));
+ ::ungetc (ch, this->infile_);
+ return ch;
+#endif /* ACE_USES_WCHAR */
+}
+
+#if defined (ACE_USES_WCHAR)
+int
+ACEXML_FileCharStream::get_i (ACEXML_Char& ch)
+{
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ {
+ ch = (ACEXML_Char) ACE_OS::fgetc (this->infile_);
+ return (feof(this->infile_) ? -1 : 0);
+ }
+ // If we have a value in peek_, return it.
+ if (this->peek_ != 0)
+ {
+ ch = this->peek_;
+ this->peek_ = 0;
+ return 0;
+ }
+
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+ ACEXML_Char input[2];
+ int i = 0;
+ for (; i < 2 && !feof (this->infile_); ++i)
+ {
+ input[i] = ACE_OS::fgetwc (this->infile_);
+ }
+ if (i < 2)
+ {
+ ch = 0;
+ return -1;
+ }
+ ch = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0];
+ return 0;
+}
+
+int
+ACEXML_FileCharStream::peek_i (void)
+{
+ // If we are reading a UTF-8 encoded file, just use the plain unget.
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ {
+ ACEXML_Char ch = (ACEXML_Char) ACE_OS::fgetc (this->infile_);
+ ::ungetc (ch, this->infile_);
+ return ch;
+ }
+
+ // If somebody had already called peek() and not consumed it, return the
+ // value held in this->peek_.
+ if (this->peek_ != 0)
+ return this->peek_;
+
+ // Peek into the stream. This reads two characters off the stream, keeps
+ // it in peek_.
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+ ACEXML_Char input[2];
+ int i = 0;
+ for (; i < 2 && !feof (this->infile_); ++i)
+ {
+ input[i] = ACE_OS::fgetwc (this->infile_);
+ }
+ if (i < 2)
+ {
+ this->peek_ = 0;
+ return -1;
+ }
+ this->peek_ = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0];
+ return this->peek_;
+}
+#endif /* ACE_USES_WCHAR */
+
+const ACEXML_Char*
+ACEXML_FileCharStream::getEncoding (void)
+{
+ return this->encoding_;
+}
+
+const ACEXML_Char*
+ACEXML_FileCharStream::getSystemId (void)
+{
+ return this->filename_;
+}
diff --git a/ACE/ACEXML/common/FileCharStream.h b/ACE/ACEXML/common/FileCharStream.h
new file mode 100644
index 00000000000..0f3408ae18e
--- /dev/null
+++ b/ACE/ACEXML/common/FileCharStream.h
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file FileCharStream.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_FILECHARSTREAM_H_
+#define _ACEXML_FILECHARSTREAM_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/CharStream.h"
+#include "ACEXML/common/Encoding.h"
+
+/**
+ * @class ACEXML_FileCharStream FileCharStream.h "ACEXML/common/FileCharStream.h"
+ *
+ * An implementation of ACEXML_CharStream for reading input from a file.
+ */
+class ACEXML_Export ACEXML_FileCharStream : public ACEXML_CharStream
+{
+public:
+ /// Default constructor.
+ ACEXML_FileCharStream (void);
+
+ /// Destructor
+ virtual ~ACEXML_FileCharStream (void);
+
+ /// Open a file.
+ int open (const ACEXML_Char *name);
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void);
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void);
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if succees.
+ */
+ virtual int get (ACEXML_Char& ch);
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str,
+ size_t len);
+
+ /**
+ * Determine the encoding of the file.
+ */
+ virtual int determine_encoding (void);
+
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if success, -1 if EOF is reached.
+ */
+ virtual int peek (void);
+
+ /**
+ * Resets the file pointer to the beginning of the stream.
+ */
+ virtual void rewind (void);
+
+ /*
+ * Get the character encoding for the file.
+ */
+ virtual const ACEXML_Char *getEncoding (void);
+
+ /*
+ * Get the systemId for the underlying CharStream
+ */
+ virtual const ACEXML_Char* getSystemId (void);
+
+private:
+
+ /** Read the next character as a normal character. Return -1 if EOF is
+ * reached, else return 0.
+ */
+ int getchar_i (char& ch);
+
+#if defined (ACE_USES_WCHAR)
+ /**
+ * Read the next character from the stream taking into account the
+ * encoding of the file.
+ */
+ int get_i (ACEXML_Char& ch);
+
+ /**
+ * Read the next character from the stream taking into account the
+ * encoding of the file. Subsequent call to get() returns this
+ * character.
+ */
+ int peek_i (void);
+
+#endif /* ACE_USES_WCHAR */
+
+ ACEXML_Char* filename_;
+ ACEXML_Char* encoding_;
+ off_t size_;
+ FILE* infile_;
+ // This is needed to ensure that we can implement a peek operation on a
+ // UTF-16 encoded file. It is a bit hackish, but there is no other way of
+ // implementing a peek() as the standard I/O FILE* guarantees only one
+ // pushback.
+ ACEXML_Char peek_;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_FILECHARSTREAM_H_ */
diff --git a/ACE/ACEXML/common/HttpCharStream.cpp b/ACE/ACEXML/common/HttpCharStream.cpp
new file mode 100644
index 00000000000..b6f5e6aa423
--- /dev/null
+++ b/ACE/ACEXML/common/HttpCharStream.cpp
@@ -0,0 +1,464 @@
+// $Id$
+
+#include "ace/ACE.h"
+#include "ace/ace_wchar.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_string.h"
+#include "ACEXML/common/HttpCharStream.h"
+#include "ACEXML/common/Encoding.h"
+
+ACE_RCSID (common, HttpCharStream, "$Id$")
+
+/* Header FSM states. */
+static const int HDST_LINE1_PROTOCOL = 0;
+static const int HDST_LINE1_WHITESPACE = 1;
+static const int HDST_LINE1_STATUS = 2;
+static const int HDST_BOL = 10;
+static const int HDST_TEXT = 11;
+static const int HDST_LF = 12;
+static const int HDST_CR = 13;
+static const int HDST_CRLF = 14;
+static const int HDST_CRLFCR = 15;
+
+ACEXML_HttpCharStream::ACEXML_HttpCharStream (void)
+ : url_(0),
+ url_addr_(0),
+ stream_(0),
+ connector_(0),
+ size_(0),
+ data_offset_ (0),
+ encoding_ (0)
+{
+
+}
+
+ACEXML_HttpCharStream::~ACEXML_HttpCharStream (void)
+{
+ this->close ();
+}
+
+int
+ACEXML_HttpCharStream::open (const ACEXML_Char *url)
+{
+ this->url_ = ACE::strnew (url);
+
+ ACE_NEW_RETURN (this->url_addr_, ACEXML_URL_Addr, -1);
+ ACE_NEW_RETURN (this->stream_, ACEXML_Mem_Map_Stream, -1);
+
+ if (this->url_addr_->string_to_addr (this->url_) == -1) {
+ this->close();
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "cannot convert URL"), -1);
+ }
+
+ ACE_NEW_RETURN (this->connector_,
+ Connector (0, ACE_NONBLOCK),
+ -1);
+
+ if (this->stream_->open (this->connector_, *this->url_addr_) == -1) {
+ this->close();
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "cannot open backing store"), -1);
+ }
+
+ int result = this->send_request();
+ if (result == -1) {
+ this->close();
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send_request"), -1);
+ }
+
+ size_t len = 0;
+ result = this->get_url(len);
+ if (result == -1) {
+ this->close();
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_url"), -1);
+ }
+ if (result != 200) {
+ this->close();
+ ACE_ERROR_RETURN ((LM_ERROR, "Server returned status %d : %s\n",
+ result,
+ "Refer HTTP/1.0 error code for details"), -1);
+ }
+
+ this->size_ = static_cast<off_t> (len);
+ return this->determine_encoding();
+}
+
+// The FSM was taken from the implementation of http_get and that falls
+// under the following license:
+//
+// Copyrigh (c) 2000 by Jef Poskanzer <jef@acme.com>. All rights reserved.
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+
+
+int
+ACEXML_HttpCharStream::get_url (size_t& len)
+{
+ if (this->stream_ == 0)
+ return -1;
+
+ int header_state = HDST_LINE1_PROTOCOL;
+ int status = 0;
+ size_t b = 0;
+ char* buf = 0;
+ size_t buflen = BUFSIZ;
+ for (;;)
+ {
+ if ((buf = const_cast<char*> (this->stream_->recv (buflen))) == 0)
+ if (buflen <= 0)
+ break;
+
+ for (b = 0; b < buflen; ++b)
+ {
+ switch ( header_state )
+ {
+ case HDST_LINE1_PROTOCOL:
+ switch ( buf[b] )
+ {
+ case ' ': case '\t':
+ header_state = HDST_LINE1_WHITESPACE; break;
+ case '\n': header_state = HDST_LF ; break;
+ case '\r': header_state = HDST_CR; break;
+ }
+ break;
+ case HDST_LINE1_WHITESPACE:
+ switch ( buf[b] )
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ status = buf[b] - '0';
+ header_state = HDST_LINE1_STATUS;
+ break;
+ case '\n': header_state = HDST_LF ; break;
+ case '\r': header_state = HDST_CR; break;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+ case HDST_LINE1_STATUS:
+ switch ( buf[b] )
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ status = status * 10 + buf[b] - '0';
+ break;
+ case '\n': header_state = HDST_LF ; break;
+ case '\r': header_state = HDST_CR; break;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+ case HDST_BOL:
+ switch ( buf[b] )
+ {
+ case '\n': header_state = HDST_LF; break;
+ case '\r': header_state = HDST_CR; break;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+ case HDST_TEXT:
+ switch ( buf[b] )
+ {
+ case '\n': header_state = HDST_LF; break;
+ case '\r': header_state = HDST_CR; break;
+ }
+ break;
+
+ case HDST_LF:
+ switch ( buf[b] )
+ {
+ case '\n': goto end_of_headers;
+ case '\r': header_state = HDST_CR; break;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+
+ case HDST_CR:
+ switch ( buf[b] )
+ {
+ case '\n': header_state = HDST_CRLF; break;
+ case '\r': goto end_of_headers;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+
+ case HDST_CRLF:
+ switch ( buf[b] )
+ {
+ case '\n': goto end_of_headers;
+ case '\r': header_state = HDST_CRLFCR; break;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+
+ case HDST_CRLFCR:
+ switch ( buf[b] )
+ {
+ case '\n': case '\r': goto end_of_headers;
+ default: header_state = HDST_TEXT; break;
+ }
+ break;
+ }
+ }
+ }
+ end_of_headers:
+ if (b == 0)
+ return -1;
+ ++b;
+ // Store the address of the beginning of data. We will use it to seek to
+ // beginning of the data in the URL.
+ char* data_beg = buf + b;
+ buflen = BUFSIZ;
+
+ // Get all of the data. Since this is backed by file store, we won't lose
+ // any of the data.
+ while (( buf = const_cast<char*> (this->stream_->recv (buflen))) != 0)
+ ;
+
+ // Length of data in the URL.
+ len = this->stream_->recv() - data_beg;
+
+ // Move the pointer to the beginning of the file store.
+ this->stream_->rewind();
+
+ this->data_offset_ = data_beg - this->stream_->recv();
+ // Forward to the beginning of data.
+ if (this->stream_->seek (this->data_offset_, SEEK_SET) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%s: %m",
+ "Error in seeking to beginning of data"), -1);
+
+ return status;
+}
+
+
+int
+ACEXML_HttpCharStream::send_request (void)
+{
+ char* path = ACE::strnew (ACE_TEXT_ALWAYS_CHAR (this->url_addr_->get_path_name()));
+ ACE_Auto_Basic_Array_Ptr<char> path_ptr (path);
+ size_t commandsize = ACE_OS::strlen (path)
+ + ACE_OS::strlen (this->url_addr_->get_host_name ())
+ + 20 // Extra
+ + 1 // NUL byte
+ + 16 ; // Protocol filler...
+
+ char* command;
+ ACE_NEW_RETURN (command, char[commandsize], -1);
+
+ // Ensure that the <command> memory is deallocated.
+ ACE_Auto_Basic_Array_Ptr<char> cmd_ptr (command);
+
+ int bytes = ACE_OS::sprintf (command, "GET %s HTTP/1.0\r\n", path);
+ bytes += ACE_OS::sprintf (&command[bytes], "Host: %s\r\n",
+ this->url_addr_->get_host_name ());
+ bytes += ACE_OS::sprintf (&command[bytes], "\r\n");
+
+ ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT);
+
+ // Send the command to the connected server.
+ int retval = this->stream_->send_n (command, bytes, &tv);
+ if (retval <= 0)
+ return -1;
+ return retval;
+}
+
+
+int
+ACEXML_HttpCharStream::available (void)
+{
+ if (this->stream_ == 0)
+ return -1;
+ return static_cast<int> (this->stream_->available());
+}
+
+int
+ACEXML_HttpCharStream::close (void)
+{
+ delete[] this->url_;
+ this->url_ = 0;
+
+ delete this->url_addr_;
+ this->url_addr_ = 0;
+
+ delete this->stream_;
+ this->stream_ = 0;
+
+ delete this->connector_;
+ this->connector_ = 0;
+
+ this->size_ = 0;
+ this->data_offset_ = 0;
+
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+
+ return 0;
+}
+
+int
+ACEXML_HttpCharStream::determine_encoding (void)
+{
+ if (this->stream_ == 0)
+ return -1;
+
+ char input[4] = {0, 0, 0, 0};
+ int i = 0;
+ for (; i < 4 && input[i] != (char)-1; ++i)
+ input[i] = static_cast<char> (this->stream_->peek_char(i));
+ if (i < 4)
+ return -1;
+ const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input);
+ if (!temp)
+ return -1;
+ else
+ {
+ if (this->encoding_)
+ delete [] this->encoding_;
+ this->encoding_ = ACE::strnew (temp);
+ // ACE_DEBUG ((LM_DEBUG, "URI's encoding is %s\n", this->encoding_));
+ }
+ // Move over the byte-order-mark if present.
+ for (int j = 0; j < 3; ++j)
+ {
+ if (input[i] == '\xFF' || input[i] == '\xFE' || input[i] == '\xEF' ||
+ input[i] == '\xBB' || input[i] == '\xBF')
+ {
+ this->stream_->get_char();
+ continue;
+ }
+ break;
+ }
+ return 0;
+}
+
+void
+ACEXML_HttpCharStream::rewind (void)
+{
+ if (this->stream_ == 0)
+ return;
+ this->stream_->rewind();
+
+ // Forward to the beginning of data.
+ if (this->stream_->seek (this->data_offset_, SEEK_SET) == -1)
+ ACE_ERROR ((LM_ERROR, "%s: %m", "Error in seeking to beginning of data"));
+ this->determine_encoding();
+}
+
+const ACEXML_Char*
+ACEXML_HttpCharStream::getEncoding (void)
+{
+ return this->encoding_;
+}
+
+const ACEXML_Char*
+ACEXML_HttpCharStream::getSystemId (void)
+{
+ return this->url_;
+}
+
+
+int
+ACEXML_HttpCharStream::read (ACEXML_Char *str,
+ size_t len)
+{
+ if (this->stream_ == 0)
+ return -1;
+ len = len * sizeof (ACEXML_Char);
+ char* temp = const_cast<char*> (this->stream_->recv (len));
+ str = ACE_TEXT_CHAR_TO_TCHAR (temp);
+ if (str == 0)
+ return -1;
+ return static_cast<int> (len);
+}
+
+
+int
+ACEXML_HttpCharStream::get (ACEXML_Char& ch)
+{
+ if (this->stream_ == 0)
+ return -1;
+#if defined (ACE_USES_WCHAR)
+ return this->get_i (ch);
+#else
+ ch = (ACEXML_Char) this->stream_->get_char();
+ return (ch == (ACEXML_Char)EOF ? -1 :0);
+#endif /* ACE_USES_WCHAR */
+}
+
+int
+ACEXML_HttpCharStream::peek (void)
+{
+ if (this->stream_ == 0)
+ return -1;
+
+#if defined (ACE_USES_WCHAR)
+ return this->peek_i();
+#else
+ return this->stream_->peek_char (0);
+#endif /* ACE_USES_WCHAR */
+}
+
+
+#if defined (ACE_USES_WCHAR)
+int
+ACEXML_HttpCharStream::get_i (ACEXML_Char& ch)
+{
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ {
+ ch = (ACEXML_Char) this->stream_->get_char();
+ return (ch == (ACEXML_Char)EOF ? -1 : 0);
+ }
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+ ACEXML_Char input[2] = {0};
+ int i = 0;
+ for (; i < 2 && (input[i] = this->stream_->get_char()) > 0; ++i)
+ ;
+ if (i < 2)
+ {
+ ch = 0;
+ return input[i];
+ }
+ ch = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0];
+ return 0;
+}
+
+int
+ACEXML_HttpCharStream::peek_i (void)
+{
+ // If we are reading a UTF-8 encoded file, just use the plain unget.
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ {
+ ACEXML_Char ch = (ACEXML_Char) this->stream_->peek_char (0);
+ return ch;
+ }
+
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+ // Peek into the stream.
+ ACEXML_Char input[2];
+ int i = 0;
+ for (; i < 2 && (input[i] = this->stream_->peek_char (i)) > 0; ++i)
+ ;
+ if (i < 2)
+ return -1;
+ return (BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0]);
+}
+#endif /* ACE_USES_WCHAR */
diff --git a/ACE/ACEXML/common/HttpCharStream.h b/ACE/ACEXML/common/HttpCharStream.h
new file mode 100644
index 00000000000..ba29e756e5b
--- /dev/null
+++ b/ACE/ACEXML/common/HttpCharStream.h
@@ -0,0 +1,140 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file HttpCharStream.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_HTTPCHARSTREAM_H_
+#define _ACEXML_HTTPCHARSTREAM_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/CharStream.h"
+#include "ACEXML/common/URL_Addr.h"
+#include "ACEXML/common/Mem_Map_Stream.h"
+
+/**
+ * @class ACEXML_HttpCharStream HttpCharStream.h "ACEXML/common/HttpCharStream.h"
+ *
+ * An implementation of ACEXML_CharStream for reading input from a URL.
+ */
+class ACEXML_Export ACEXML_HttpCharStream : public ACEXML_CharStream
+{
+public:
+ /// Default constructor.
+ ACEXML_HttpCharStream (void);
+
+ /// Destructor
+ virtual ~ACEXML_HttpCharStream (void);
+
+ /// Open an URL.
+ int open (const ACEXML_Char *url);
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void);
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void);
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed.
+ */
+ virtual int get (ACEXML_Char& ch);
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str, size_t len);
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if succeess, -1 if EOS is reached.
+ */
+ virtual int peek (void);
+
+ /**
+ * Resets the file pointer to the beginning of the stream.
+ */
+ virtual void rewind (void);
+
+ /**
+ * Determine the encoding of the file.
+ */
+ virtual int determine_encoding (void);
+
+ /**
+ * Get the encoding of the file
+ */
+ virtual const ACEXML_Char* getEncoding (void);
+
+ /*
+ * Get the systemId for the underlying CharStream
+ */
+ virtual const ACEXML_Char* getSystemId (void);
+
+
+private:
+
+#if defined (ACE_USES_WCHAR)
+ /**
+ * Read the next character from the stream taking into account the
+ * encoding of the file.
+ */
+ int get_i (ACEXML_Char& ch);
+
+ /**
+ * Read the next character from the stream taking into account the
+ * encoding of the file. Subsequent call to get() returns this
+ * character.
+ */
+ int peek_i (void);
+
+#endif /* ACE_USES_WCHAR */
+
+ /**
+ * Send a HTTP/1.1 request to fetch the contents of the URL.
+ */
+ int send_request (void);
+
+ /**
+ * Fetch the URL and save it in backing store.
+ */
+ int get_url (size_t& len);
+
+ ACEXML_Char *url_;
+
+ ACEXML_URL_Addr* url_addr_;
+
+ ACEXML_Mem_Map_Stream* stream_;
+
+ Connector* connector_;
+
+ off_t size_;
+
+ off_t data_offset_;
+
+ ACEXML_Char* encoding_;
+
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_HTTPCHARSTREAM_H_ */
diff --git a/ACE/ACEXML/common/InputSource.cpp b/ACE/ACEXML/common/InputSource.cpp
new file mode 100644
index 00000000000..8673420d732
--- /dev/null
+++ b/ACE/ACEXML/common/InputSource.cpp
@@ -0,0 +1,106 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/InputSource.h"
+#include "ACEXML/common/StreamFactory.h"
+#include "ace/ACE.h"
+#include "ace/Swap.h"
+
+ACEXML_InputSource::ACEXML_InputSource (void)
+ : charStream_ (0),
+ encoding_ (0),
+ publicId_ (0),
+ systemId_ (0)
+{
+}
+
+ACEXML_InputSource::ACEXML_InputSource (ACEXML_CharStream *stm)
+ : charStream_ (stm),
+ encoding_ (ACE::strnew (stm->getEncoding())),
+ publicId_ (0),
+ systemId_ (stm->getSystemId() ? ACE::strnew (stm->getSystemId()): 0)
+{
+}
+
+ /*
+ * Create a new input source with a character stream.
+ *
+ */
+
+ACEXML_InputSource::ACEXML_InputSource (const ACEXML_Char *systemId)
+ : charStream_ (0),
+ encoding_ (0),
+ publicId_ (0),
+ systemId_ (ACE::strnew (systemId))
+{
+ ACEXML_StreamFactory factory;
+ ACEXML_CharStream* stm = factory.create_stream (this->systemId_);
+ if (stm)
+ {
+ this->setCharStream (stm);
+ this->setEncoding (this->charStream_->getEncoding());
+ }
+}
+
+ACEXML_InputSource::~ACEXML_InputSource (void)
+{
+ delete[] this->publicId_;
+ this->publicId_ = 0;
+ delete[] this->systemId_;
+ this->systemId_ = 0;
+ delete this->charStream_;
+ this->charStream_ = 0;
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+}
+
+ACEXML_CharStream *
+ACEXML_InputSource::getCharStream (void) const
+{
+ return this->charStream_;
+}
+
+const ACEXML_Char *
+ACEXML_InputSource::getEncoding (void) const
+{
+ return this->encoding_;
+}
+
+const ACEXML_Char *
+ACEXML_InputSource::getPublicId (void) const
+{
+ return this->publicId_;
+}
+
+const ACEXML_Char *
+ACEXML_InputSource::getSystemId (void) const
+{
+ return this->systemId_;
+}
+
+void
+ACEXML_InputSource::setCharStream (ACEXML_CharStream *stm)
+{
+ delete this->charStream_;
+ this->charStream_ = stm;
+}
+
+void
+ACEXML_InputSource::setEncoding (const ACEXML_Char *encoding)
+{
+ delete[] this->encoding_;
+ this->encoding_ = ACE::strnew (encoding);
+}
+
+void
+ACEXML_InputSource::setPublicId (const ACEXML_Char *publicId)
+{
+ delete[] this->publicId_;
+ this->publicId_ = ACE::strnew (publicId);
+}
+
+void
+ACEXML_InputSource::setSystemId (const ACEXML_Char *systemId)
+{
+ delete[] this->systemId_;
+ this->systemId_ = ACE::strnew (systemId);
+}
diff --git a/ACE/ACEXML/common/InputSource.h b/ACE/ACEXML/common/InputSource.h
new file mode 100644
index 00000000000..ae2b70b130e
--- /dev/null
+++ b/ACE/ACEXML/common/InputSource.h
@@ -0,0 +1,131 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file InputSource.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_INPUTSOURCE_H_
+#define _ACEXML_INPUTSOURCE_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/CharStream.h"
+
+/**
+ * @class ACEXML_InputSource InputSource.h "ACEXML/common/InputSource.h"
+ *
+ * @brief ACEXML_InputSource encapsulates the actual input stream with some
+ * added information.
+ *
+ * This class allows a SAX application to encapsulate information
+ * about an input source in a single object, which may include a
+ * public identifier, a system identifier, a byte stream (possibly
+ * with a specified encoding), and/or a character stream.
+ *
+ * There are two places that the application will deliver this input
+ * source to the parser: as the argument to the Parser.parse method,
+ * or as the return value of the EntityResolver.resolveEntity method.
+ *
+ * The SAX parser will use the InputSource object to determine how to
+ * read XML input. If there is a character stream available, the
+ * parser will read that stream directly; if not, the parser will use
+ * a byte stream, if available; if neither a character stream nor a
+ * byte stream is available, the parser will attempt to open a URI
+ * connection to the resource identified by the system identifier.
+ *
+ * An InputSource object belongs to the application: the SAX parser
+ * shall never modify it in any way (it may modify a copy if
+ * necessary).
+ *
+ * @sa ACEXML_CharStream
+ */
+class ACEXML_Export ACEXML_InputSource
+{
+public:
+ /**
+ * Default constructor.
+ */
+ ACEXML_InputSource (void);
+
+
+ /**
+ * Create a new input source with a ACEXML_Char stream.
+ * Notice that ACEXML_InputSource assumes the ownership
+ * of <stream>
+ */
+ explicit ACEXML_InputSource (ACEXML_CharStream *stream);
+
+ /**
+ * Create a new input source with a system identifier.
+ */
+ ACEXML_InputSource (const ACEXML_Char *systemId);
+
+ /**
+ * Default destructor.
+ */
+ virtual ~ACEXML_InputSource (void);
+
+ /**
+ * Get the ACEXML_Char stream for this input source.
+ */
+ virtual ACEXML_CharStream *getCharStream (void) const;
+
+ /**
+ * Get the character encoding for a byte stream or URI.
+ */
+ virtual const ACEXML_Char *getEncoding (void) const;
+
+ /**
+ * Get the public identifier for this input source.
+ */
+ virtual const ACEXML_Char *getPublicId (void) const;
+
+ /**
+ * Get the system identifier for this input source.
+ */
+ virtual const ACEXML_Char *getSystemId (void) const;
+
+ /**
+ * Set the ACEXML_Char stream for this input source.
+ * Notice that ACEXML_InputSource assumes the ownership
+ * of <stream>
+ */
+ virtual void setCharStream (ACEXML_CharStream *charStream);
+
+ /**
+ * Set the character encoding, if known.
+ */
+ virtual void setEncoding (const ACEXML_Char *encoding);
+
+ /**
+ * Set the public identifier for this input source.
+ */
+ virtual void setPublicId (const ACEXML_Char *publicId);
+
+ /**
+ * Set the public identifier for this input source.
+ */
+ virtual void setSystemId (const ACEXML_Char *systemId);
+
+private:
+ ACEXML_CharStream *charStream_;
+ ACEXML_Char *encoding_;
+ ACEXML_Char *publicId_;
+ ACEXML_Char *systemId_;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_INPUTSOURCE_H_ */
diff --git a/ACE/ACEXML/common/Locator.cpp b/ACE/ACEXML/common/Locator.cpp
new file mode 100644
index 00000000000..5de6d3a1516
--- /dev/null
+++ b/ACE/ACEXML/common/Locator.cpp
@@ -0,0 +1,11 @@
+#include "Locator.h"
+
+
+ACE_RCSID (common,
+ Locator,
+ "$Id$")
+
+
+ACEXML_Locator::~ACEXML_Locator (void)
+{
+}
diff --git a/ACE/ACEXML/common/Locator.h b/ACE/ACEXML/common/Locator.h
new file mode 100644
index 00000000000..c6504b706a4
--- /dev/null
+++ b/ACE/ACEXML/common/Locator.h
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Locator.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_LOCATOR_H_
+#define _ACEXML_LOCATOR_H_
+#include /**/ "ace/pre.h"
+
+#include "ACEXML/common/ACEXML_Export.h"
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_Locator Locator.h "ACEXML/common/Locator.h"
+ *
+ * @brief ACEXML_Locator defines operations that an XML locator should support.
+ *
+ * If a SAX parser provides location information to the SAX
+ * application, it does so by implementing this interface and then
+ * passing an instance to the application using the content handler's
+ * setDocumentLocator method. The application can use the object to
+ * obtain the location of any other content handler event in the XML
+ * source document.
+ *
+ * Note that the results returned by the object will be valid only
+ * during the scope of each content handler method: the application
+ * will receive unpredictable results if it attempts to use the
+ * locator at any other time.
+ *
+ * SAX parsers are not required to supply a locator, but they are very
+ * strongly encouraged to do so. If the parser supplies a locator, it
+ * must do so before reporting any other document events. If no
+ * locator has been set by the time the application receives the
+ * startDocument event, the application should assume that a locator
+ * is not available.
+ */
+class ACEXML_Export ACEXML_Locator
+{
+public:
+
+ virtual ~ACEXML_Locator (void);
+
+ /*
+ * Return the column number where the current document event ends.
+ */
+ virtual int getColumnNumber (void) const = 0;
+
+ /*
+ * Return the line number where the current document event ends.
+ */
+ virtual int getLineNumber (void) const = 0;
+
+ /*
+ * Return the public identifier for the current document event.
+ */
+ virtual const ACEXML_Char *getPublicId (void) const = 0;
+
+ /*
+ * Return the system identifier for the current document event.
+ */
+ virtual const ACEXML_Char *getSystemId (void) const = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_LOCATOR_H_ */
diff --git a/ACE/ACEXML/common/LocatorImpl.cpp b/ACE/ACEXML/common/LocatorImpl.cpp
new file mode 100644
index 00000000000..7b98f9178e1
--- /dev/null
+++ b/ACE/ACEXML/common/LocatorImpl.cpp
@@ -0,0 +1,49 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/LocatorImpl.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/LocatorImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_LocatorImpl::ACEXML_LocatorImpl (void)
+ : publicId_ (0),
+ systemId_ (0),
+ lineNumber_ (1),
+ columnNumber_ (0)
+{
+}
+
+ACEXML_LocatorImpl::ACEXML_LocatorImpl (const ACEXML_Char* systemId,
+ const ACEXML_Char* publicId)
+ : publicId_ (publicId ? ACE::strnew (publicId) : 0),
+ systemId_ (systemId ? ACE::strnew (systemId) : 0),
+ lineNumber_ (1),
+ columnNumber_ (0)
+{
+}
+
+
+ACEXML_LocatorImpl::ACEXML_LocatorImpl (const ACEXML_Locator& locator)
+ : publicId_ (locator.getPublicId() ? ACE::strnew(locator.getPublicId ()): 0),
+ systemId_ (locator.getSystemId() ? ACE::strnew(locator.getSystemId ()): 0),
+ lineNumber_ (locator.getLineNumber ()),
+ columnNumber_ (locator.getColumnNumber ())
+{
+}
+
+ACEXML_LocatorImpl::~ACEXML_LocatorImpl (void)
+{
+ this->reset();
+}
+
+void
+ACEXML_LocatorImpl::reset (void)
+{
+ delete[] this->publicId_;
+ this->publicId_ = 0;
+ delete[] this->systemId_;
+ this->systemId_ = 0;
+ this->columnNumber_ = 0;
+ this->lineNumber_ = 1;
+}
diff --git a/ACE/ACEXML/common/LocatorImpl.h b/ACE/ACEXML/common/LocatorImpl.h
new file mode 100644
index 00000000000..e5209e13b8d
--- /dev/null
+++ b/ACE/ACEXML/common/LocatorImpl.h
@@ -0,0 +1,159 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file LocatorImpl.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ * @author Krishnakumar Balasubramanian <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_LOCALTORIMPL_H
+#define ACEXML_LOCALTORIMPL_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Locator.h"
+
+/**
+ * @class ACEXML_LocatorImpl LocatorImpl.h "ACEXML/common/LocatorImpl.h"
+ *
+ * @brief ACEXML_LocatorImpl is an implementation of ACEXML_Locator.
+ *
+ * This class is available mainly for application writers, who can
+ * use it to make a persistent snapshot of a locator at any point
+ * during a document parse:
+ *
+ * @code
+ * ACEXML_Locator locator;
+ * ACEXML_Locator startloc;
+ *
+ * public void setLocator (ACEXML_Locator locator)
+ * {
+ * // note the locator
+ * this.locator = locator;
+ * }
+ *
+ * public void startDocument ()
+ * {
+ * // save the location of the start of the document
+ * // for future use.
+ * ACEXML_Locator startloc = new ACEXML_LocatorImpl(locator);
+ * }
+ * @endcode
+ *
+ * Normally, parser writers will not use this class, since it is more
+ * efficient to provide location information only when requested,
+ * rather than constantly updating a Locator object.
+ *
+ * @todo ACEXML parser doesn't support the use of Locator yet.
+ *
+ * @sa ACEXML_Locator
+ */
+class ACEXML_Export ACEXML_LocatorImpl : public ACEXML_Locator
+{
+public:
+ /*
+ * Default constructor.
+ */
+ ACEXML_LocatorImpl (void);
+
+ /**
+ * Construct a locator with systemId and publicId
+ *
+ */
+ ACEXML_LocatorImpl (const ACEXML_Char* systemId,
+ const ACEXML_Char* publicId);
+ /**
+ * Copy constructor. Create a persistent copy of the current state
+ * of a locator. When the original locator changes, this copy will
+ * still keep the original values (and it can be used outside the
+ * scope of DocumentHandler methods).
+ */
+ ACEXML_LocatorImpl (const ACEXML_Locator& locator);
+
+ /*
+ * Destructor.
+ */
+ virtual ~ACEXML_LocatorImpl (void);
+
+ /*
+ * Return the column number where the current document event ends.
+ */
+ virtual int getColumnNumber (void) const;
+
+ /*
+ * Return the line number where the current document event ends.
+ */
+ virtual int getLineNumber (void) const;
+
+ /*
+ * Return the public identifier for the current document event.
+ */
+ virtual const ACEXML_Char *getPublicId (void) const;
+
+ /*
+ * Return the system identifier for the current document event.
+ */
+ virtual const ACEXML_Char *getSystemId (void) const;
+
+ /*
+ * Set the column number of this locator.
+ */
+ void setColumnNumber (int cn);
+
+ /*
+ * Set the line number of this locator.
+ */
+ void setLineNumber (int ln);
+
+ /*
+ * Set the public identifier of this locator.
+ */
+ void setPublicId (const ACEXML_Char *id);
+
+ /*
+ * Set the system identifier of this locator.
+ */
+ void setSystemId (const ACEXML_Char *id);
+
+ /*
+ * Increment the line number.
+ */
+ void incrLineNumber ();
+
+ /*
+ * Increment the column number.
+ */
+ void incrColumnNumber ();
+
+ /*
+ * Reset the Locator information. This is necessary because one might
+ * want to use the same parser to parse multiple files. In that case,
+ * tying the life of the Locator with the parser is not appropriate. The
+ * parser calls this method as soon as issuing an endDocument() call.
+ */
+ void reset (void);
+
+private:
+ ACEXML_Char *publicId_;
+ ACEXML_Char *systemId_;
+ int lineNumber_;
+ int columnNumber_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/LocatorImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_LOCALTORIMPL_H */
diff --git a/ACE/ACEXML/common/LocatorImpl.i b/ACE/ACEXML/common/LocatorImpl.i
new file mode 100644
index 00000000000..808a8bd4ac4
--- /dev/null
+++ b/ACE/ACEXML/common/LocatorImpl.i
@@ -0,0 +1,65 @@
+// -*- C++ -*- $Id$
+
+#include "ace/ACE.h"
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::setColumnNumber (int cn)
+{
+ this->columnNumber_ = cn;
+}
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::setLineNumber (int ln)
+{
+ this->lineNumber_ = ln;
+}
+
+ACEXML_INLINE int
+ACEXML_LocatorImpl::getColumnNumber (void) const
+{
+ return this->columnNumber_;
+}
+
+ACEXML_INLINE int
+ACEXML_LocatorImpl::getLineNumber (void) const
+{
+ return this->lineNumber_;
+}
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::setPublicId (const ACEXML_Char *id)
+{
+ delete[] this->publicId_;
+ this->publicId_ = ACE::strnew (id);
+}
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::setSystemId (const ACEXML_Char *id)
+{
+ delete[] this->systemId_;
+ this->systemId_ = ACE::strnew (id);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_LocatorImpl::getPublicId (void) const
+{
+ return this->publicId_;
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_LocatorImpl::getSystemId (void) const
+{
+ return this->systemId_;
+}
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::incrLineNumber ()
+{
+ ++this->lineNumber_;
+}
+
+ACEXML_INLINE void
+ACEXML_LocatorImpl::incrColumnNumber ()
+{
+ ++this->columnNumber_;
+}
diff --git a/ACE/ACEXML/common/Makefile.am b/ACE/ACEXML/common/Makefile.am
new file mode 100644
index 00000000000..125d6f63d96
--- /dev/null
+++ b/ACE/ACEXML/common/Makefile.am
@@ -0,0 +1,135 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu
+
+includedir = @includedir@/ACEXML/common
+pkgconfigdir = @libdir@/pkgconfig
+
+ACE_BUILDDIR = $(top_builddir)
+ACE_ROOT = $(top_srcdir)
+
+
+## Makefile.ACEXML.am
+
+if !BUILD_ACE_FOR_TAO
+
+lib_LTLIBRARIES = libACEXML.la
+
+libACEXML_la_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -DACEXML_BUILD_DLL
+
+libACEXML_la_SOURCES = \
+ Attributes.cpp \
+ AttributesImpl.cpp \
+ Attributes_Def_Builder.cpp \
+ CharStream.cpp \
+ ContentHandler.cpp \
+ DTDHandler.cpp \
+ DTD_Manager.cpp \
+ DefaultHandler.cpp \
+ Element_Def_Builder.cpp \
+ Encoding.cpp \
+ EntityResolver.cpp \
+ Env.cpp \
+ ErrorHandler.cpp \
+ Exception.cpp \
+ FileCharStream.cpp \
+ HttpCharStream.cpp \
+ InputSource.cpp \
+ Locator.cpp \
+ LocatorImpl.cpp \
+ Mem_Map_Stream.cpp \
+ NamespaceSupport.cpp \
+ SAXExceptions.cpp \
+ StrCharStream.cpp \
+ StreamFactory.cpp \
+ Transcode.cpp \
+ URL_Addr.cpp \
+ Validator.cpp \
+ XMLFilterImpl.cpp \
+ XMLReader.cpp \
+ XML_Codecs.cpp \
+ XML_Util.cpp \
+ ZipCharStream.cpp
+
+libACEXML_la_LDFLAGS = \
+ -release @ACE_VERSION_NAME@
+
+libACEXML_la_LIBADD = \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+nobase_include_HEADERS = \
+ ACEXML_Export.h \
+ Attributes.h \
+ AttributesImpl.h \
+ AttributesImpl.i \
+ Attributes_Def_Builder.h \
+ CharStream.h \
+ ContentHandler.h \
+ DTDHandler.h \
+ DTD_Manager.h \
+ DefaultHandler.h \
+ Element_Def_Builder.h \
+ Encoding.h \
+ EntityResolver.h \
+ Env.h \
+ Env.i \
+ ErrorHandler.h \
+ Exception.h \
+ Exception.i \
+ FileCharStream.h \
+ HttpCharStream.h \
+ InputSource.h \
+ Locator.h \
+ LocatorImpl.h \
+ LocatorImpl.i \
+ Mem_Map_Stream.h \
+ NamespaceSupport.h \
+ SAXExceptions.h \
+ SAXExceptions.i \
+ StrCharStream.h \
+ StreamFactory.h \
+ Transcode.h \
+ URL_Addr.h \
+ URL_Addr.inl \
+ Validator.h \
+ XMLFilter.h \
+ XMLFilterImpl.h \
+ XMLFilterImpl.i \
+ XMLReader.h \
+ XML_Codecs.h \
+ XML_Macros.h \
+ XML_Types.h \
+ XML_Util.h \
+ ZipCharStream.h
+
+pkgconfig_DATA = \
+ ACEXML.pc
+
+CLEANFILES = \
+ ACEXML.pc
+
+ACEXML.pc: ${top_builddir}/config.status ${srcdir}/ACEXML.pc.in
+ ${top_builddir}/config.status --file "$@":${srcdir}/ACEXML.pc.in
+
+endif !BUILD_ACE_FOR_TAO
+
+EXTRA_DIST = \
+ ACEXML.pc.in
+
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/ACEXML/common/Mem_Map_Stream.cpp b/ACE/ACEXML/common/Mem_Map_Stream.cpp
new file mode 100644
index 00000000000..306641cb177
--- /dev/null
+++ b/ACE/ACEXML/common/Mem_Map_Stream.cpp
@@ -0,0 +1,264 @@
+// $Id$
+
+#include "ace/FILE_Addr.h"
+#include "ace/OS_NS_unistd.h"
+#include "ACEXML/common/Mem_Map_Stream.h"
+
+ACE_RCSID(common, Mem_Map_Stream, "$Id$")
+
+ACEXML_Mem_Map_Stream::ACEXML_Mem_Map_Stream (void)
+ : svc_handler_ (0)
+{
+
+}
+
+ACE_SOCK_Stream &
+ACEXML_Mem_Map_Stream::stream (void)
+{
+ return svc_handler_->peer ();
+}
+
+ssize_t
+ACEXML_Mem_Map_Stream::send_n (const void *buf, size_t size,
+ ACE_Time_Value *tv)
+{
+ return svc_handler_->peer ().send_n (buf, size, 0, tv);
+}
+
+int
+ACEXML_Mem_Map_Stream::eof (void) const
+{
+ return this->get_pos_ >= this->end_of_mapping_plus1_;
+}
+
+int
+ACEXML_Mem_Map_Stream::get_char (void)
+{
+ if (this->eof () && this->grow_file_and_remap () == -1)
+ return EOF;
+ return *this->get_pos_++;
+}
+
+void
+ACEXML_Mem_Map_Stream::rewind (void)
+{
+ this->recv_pos_ = reinterpret_cast<char *> (this->mem_map_.addr ());
+ this->get_pos_ = this->recv_pos_;
+ this->end_of_mapping_plus1_ = this->recv_pos_ + this->mem_map_.size ();
+}
+
+int
+ACEXML_Mem_Map_Stream::peek_char (size_t offset)
+{
+ // We may need to iterate if the size of <n> is large.
+ while (this->get_pos_ + offset >= this->end_of_mapping_plus1_)
+ if (this->grow_file_and_remap () == -1)
+ return EOF;
+
+ return this->get_pos_[offset];
+}
+
+const char *
+ACEXML_Mem_Map_Stream::recv (void) const
+{
+ return this->recv_pos_;
+}
+
+const char *
+ACEXML_Mem_Map_Stream::recv (size_t &len)
+{
+ if (this->eof () && this->grow_file_and_remap () == -1)
+ {
+ len = 0;
+ return 0;
+ }
+ const char *s = this->recv_pos_;
+ this->seek (static_cast<off_t> (len), SEEK_CUR);
+ len = this->get_pos_ - s;
+ return s;
+}
+
+size_t
+ACEXML_Mem_Map_Stream::recv_len (void) const
+{
+ return this->get_pos_ - this->recv_pos_;
+}
+
+const char *
+ACEXML_Mem_Map_Stream::peek_str (size_t offset,
+ size_t size)
+{
+ // We will iterate if the size of <offset> is large.
+ while (this->get_pos_ + (offset + size) > this->end_of_mapping_plus1_)
+ if (this->grow_file_and_remap () == -1)
+ return 0;
+
+ return &this->get_pos_[offset];
+}
+
+off_t
+ACEXML_Mem_Map_Stream::seek (off_t offset, int whence)
+{
+ switch (whence)
+ {
+ case SEEK_SET:
+ this->get_pos_ =
+ reinterpret_cast<char *> (this->mem_map_.addr ())
+ + offset;
+ break;
+
+ case SEEK_CUR:
+ this->get_pos_ += offset;
+ break;
+
+ case SEEK_END:
+ this->get_pos_ =
+ this->end_of_mapping_plus1_ + offset;
+ // @@ Not sure how to implement this (yet).
+ ACE_NOTSUP_RETURN (-1);
+ break;
+ }
+
+ // Make sure that the backing store will cover this.
+ while (this->get_pos_ > this->end_of_mapping_plus1_)
+ if (this->grow_file_and_remap () == -1)
+ this->get_pos_ = this->end_of_mapping_plus1_;
+
+ this->recv_pos_ = this->get_pos_;
+ return this->recv_pos_ - reinterpret_cast<char *> (this->mem_map_.addr ());
+}
+
+Svc_Handler *
+ACEXML_Mem_Map_Stream::svc_handler (void)
+{
+ return this->svc_handler_;
+}
+
+size_t
+ACEXML_Mem_Map_Stream::available (void) const
+{
+ return this->end_of_mapping_plus1_ - this->get_pos_;
+}
+
+int
+ACEXML_Mem_Map_Stream::open (Connector *connector,
+ const ACE_INET_Addr &addr)
+{
+ svc_handler_ = 0;
+
+ // Connect to the server at <addr>. If the handler has to be
+ // connected to the server again, the Caching strategy takes care
+ // and uses the same connection.
+ if (connector->connect (svc_handler_,
+ addr) == -1)
+ {
+
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p %s %d\n",
+ "Connect failed",
+ addr.get_host_name (),
+ addr.get_port_number ()),
+ -1);
+ }
+ // Create a temporary filename.
+ ACE_FILE_Addr file (ACE_sap_any_cast (ACE_FILE_Addr &));
+
+ // Create the temporary file via the <ACE_Mem_Map> class API.
+ if (this->mem_map_.open (file.get_path_name (),
+ O_RDWR | O_CREAT | O_APPEND,
+ ACE_DEFAULT_FILE_PERMS) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "open"),
+ -1);
+ // Make sure to unlink this right away so that if this process
+ // crashes these files will be removed automatically.
+ else if (ACE_OS::unlink (file.get_path_name ()) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "unlink"),
+ -1);
+ else
+ // Initialize all the position pointers to 0.
+ this->rewind ();
+
+ return 0;
+}
+
+int
+ACEXML_Mem_Map_Stream::grow_file_and_remap (void)
+{
+ char buf[8192];
+
+ // Copy the next chunk of bytes from the socket into the temporary
+ // file.
+ ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT);
+ ssize_t bytes = 0;
+ ssize_t n = 0;
+ while (1)
+ {
+ n = this->svc_handler_->peer ().recv (buf, sizeof buf, 0, &tv);
+ if (n == -1)
+ {
+ if (errno != EWOULDBLOCK)
+ {
+ ACE_ERROR ((LM_ERROR, "%p\n", "recv"));
+ return -1;
+ }
+ }
+ bytes += n;
+ if (n == 0 && !bytes)
+ return -1;
+ else if (n == 0)
+ break;
+ else if (ACE::write_n (this->mem_map_.handle (), buf, n) != n)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "write_n"),
+ -1);
+ }
+
+// ssize_t n = this->svc_handler_->peer ().recv (buf, sizeof buf, 0, &tv);
+// if (n == -1)
+// {
+// ACE_ERROR ((LM_ERROR, "%p\n", "recv"));
+// return -1;
+// }
+// else if (n == 0)
+// return -1;
+// else if (ACE::write_n (this->mem_map_.handle (), buf, n) != n)
+// ACE_ERROR_RETURN ((LM_ERROR,
+// "%p\n",
+// "write_n"),
+// -1);
+
+ // Grow the memory-mapping to encompass the entire temporary file.
+ if (this->mem_map_.map (-1,
+ PROT_RDWR,
+ ACE_MAP_PRIVATE,
+ (void*)0) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "map"),
+ -1);
+ // MAP_FAILED is used as a "first time in" flag.
+ if (this->recv_pos_ == MAP_FAILED)
+ {
+ this->recv_pos_ = reinterpret_cast<char *> (this->mem_map_.addr ());
+ this->get_pos_ = this->recv_pos_;
+ }
+
+ this->end_of_mapping_plus1_ =
+ reinterpret_cast<char *> (this->mem_map_.addr ())
+ + this->mem_map_.size ();
+
+ return 0;
+}
+
+ACEXML_Mem_Map_Stream::~ACEXML_Mem_Map_Stream (void)
+{
+ // Remove the mapping and the file.
+ this->mem_map_.remove ();
+ delete this->svc_handler_;
+}
+
diff --git a/ACE/ACEXML/common/Mem_Map_Stream.h b/ACE/ACEXML/common/Mem_Map_Stream.h
new file mode 100644
index 00000000000..2c193aed80a
--- /dev/null
+++ b/ACE/ACEXML/common/Mem_Map_Stream.h
@@ -0,0 +1,191 @@
+/* -*- C++ -*- */
+
+/** @file Mem_Map_Stream.h
+ *
+ * $Id$
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ *
+ */
+
+#ifndef _ACEXML_MEM_MAP_STREAM_H
+#define _ACEXML_MEM_MAP_STREAM_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/SOCK_Stream.h"
+#include "ace/Mem_Map.h"
+#include "ace/SOCK_Connector.h"
+#include "ace/Connector.h"
+#include "ace/Svc_Handler.h"
+#include "ACEXML/common/XML_Types.h"
+
+typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> Svc_Handler;
+typedef ACE_Connector<Svc_Handler, ACE_SOCK_CONNECTOR> Connector;
+
+/**
+ * @class ACEXML_Mem_Map_Stream Mem_Map_Stream.h "ACEXML/common/Mem_Map_Stream.h"
+ *
+ * @brief Provides a memory-mapped stream abstraction to simplify parsing
+ * of tokens.
+ *
+ * This class makes it possible to treat an connection as a stream of
+ * bytes, similar to the C library stdio streams. The contents of the
+ * connection are buffered incrementally in a memory-mapped file. This
+ * class maintains pointers to two positions in the stream:
+ *
+ * 1. The <recv> position, which keeps track of the beginning of a
+ * token that is in the stream.
+ *
+ * 2. The <get> position, which moves along character-by-character
+ * until the end of the token is reached.
+ *
+ * Once a token has been located, it can be extracted from the stream by
+ * calling the <recv>. The length of the token, i.e., the <recv_len>, is
+ * the length in bytes between the <get> position and the <recv> position.
+ * Once the token has been extracted, the <recv> and <get> positions can be
+ * updated by the <seek> method.
+ */
+class ACEXML_Export ACEXML_Mem_Map_Stream
+{
+public:
+ /// Default constructor
+ ACEXML_Mem_Map_Stream (void);
+
+ /// Initialize this object.
+ virtual int open (Connector *connector,
+ const ACE_INET_Addr &);
+
+ /// Destructor.
+ virtual ~ACEXML_Mem_Map_Stream (void);
+
+ /// Returns the underlying <ACE_SOCK_Stream>.
+ ACE_SOCK_Stream &stream (void);
+
+ /**
+ * Send <size> bytes in <buf> to the connected peer. This is a
+ * completely unbuffered call.
+ */
+ virtual ssize_t send_n (const void *buf,
+ size_t size,
+ ACE_Time_Value *tv = 0);
+
+ /**
+ * Return the next character in the stream and advance the <get>
+ * position. Returns EOF when the <get> position reaches the end of the
+ * HTTP stream.
+ */
+ virtual int get_char (void);
+
+ /**
+ * Returns a pointer to array of at most <len> characters starting at
+ * the <recv> position. If the <recv> position + <len> extends past the
+ * EOF then <len> is set to the number of characters between the <recv>
+ * position and the EOF and both the <get> and <recv> positions are
+ * advanced by <len>. Returns 0 if the <recv> position is at the EOF.
+ */
+ virtual const char *recv (size_t &len);
+
+ /**
+ * Returns a pointer to array of characters starting at the <recv>
+ * position.
+ */
+ virtual const char *recv (void) const;
+
+ /**
+ * Returns the length in bytes between the <get> position and the <recv>
+ * position.
+ */
+ virtual size_t recv_len (void) const;
+
+ /**
+ * Returns the no. of bytes available in the stream.
+ */
+ virtual size_t available (void) const;
+
+ /**
+ * Resets the <get> and <recv> positions to the beginning of the stream.
+ * This works since all the data has been cached in the memory-mapped
+ * backing store.
+ */
+ virtual void rewind (void);
+
+ /**
+ * Returns the nth character <offset> from the <get> position in the
+ * stream without advancing the <get> position. Automatically extends
+ * the backing store if necessary. Returns EOF if <offset> is past the
+ * end of the stream.
+ */
+ virtual int peek_char (size_t offset);
+
+ /**
+ * Return a pointer to an array of <size> characters starting at
+ * <offset> characters from the <get> position in the stream without
+ * advancing the <get> position. Automatically extends the backing store
+ * if necessary. Returns 0 if <offset> or <offset + size> is past the
+ * end of the stream.
+ */
+ virtual const char *peek_str (size_t offset, size_t size);
+
+ /**
+ * Sets the <get> and <recv> positions as follows:
+ * o If <whence> is <SEEK_SET>, the positions are set to <offset>
+ * bytes from the start of the stream.
+ * o If <whence> is <SEEK_CUR>, the positions are set to the
+ * current <get> position plus <offset>.
+ * o If <whence> is <SEEK_END>, the positions are set to the size
+ * of the stream plus <offset>.
+ *
+ * If offset is greater than EOF, both <get> and <recv> are set to EOF.
+ * Note special return value is returned to indicate this condition.
+ */
+ virtual off_t seek (off_t offset, int whence = SEEK_CUR);
+
+ /// Returns 1 if we're at the end of the HTTP stream, else 0.
+ virtual int eof (void) const;
+
+ /// Returns the underlying service handler.
+ Svc_Handler *svc_handler (void);
+
+private:
+ /**
+ * Grow the file by reading another chunk from the HTTP socket and
+ * extend the mapping to cover this chunk. Returns -1 on failure or
+ * EOF, else 0.
+ */
+ int grow_file_and_remap (void);
+
+ /**
+ * Connection to peer. The granularity is at the Svc_Handler level.
+ * The Svc_Handler has an SOCK_Stream.
+ */
+ Svc_Handler *svc_handler_;
+
+ /// Memory-mapped file that we're iterating over.
+ ACE_Mem_Map mem_map_;
+
+ /// Pointer to the address where the next <recv> method will start.
+ char *recv_pos_;
+
+ /**
+ * Pointer to the address where the next <get_char> method will
+ * start.
+ */
+ char *get_pos_;
+
+ /// Address at the end of the file mapping.
+ char *end_of_mapping_plus1_;
+
+};
+
+
+#include /**/ "ace/post.h"
+
+
+#endif /* _ACEXML_MEM_MAP_STREAM_H */
diff --git a/ACE/ACEXML/common/NamespaceSupport.cpp b/ACE/ACEXML/common/NamespaceSupport.cpp
new file mode 100644
index 00000000000..5f337eca2ba
--- /dev/null
+++ b/ACE/ACEXML/common/NamespaceSupport.cpp
@@ -0,0 +1,247 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/NamespaceSupport.h"
+#include "ace/OS_NS_string.h"
+
+static const ACEXML_Char ACEXML_XMLNS_PREFIX_name[] = ACE_TEXT ("xmlns");
+
+const ACEXML_Char *ACEXML_NamespaceSupport::XMLNS_PREFIX = ACEXML_XMLNS_PREFIX_name;
+
+static const ACEXML_Char ACEXML_DEFAULT_NS_PREFIX[] = {0};
+
+static const ACEXML_Char ACEXML_TABOO_NS_PREFIX[] = ACE_TEXT ("xml");
+
+static const ACEXML_Char ACEXML_XMLNS_URI_name[] = ACE_TEXT ("http://www.w3.org/XML/1998/namespace");
+const ACEXML_Char *ACEXML_NamespaceSupport::XMLNS = ACEXML_XMLNS_URI_name;
+
+ACEXML_Namespace_Context_Stack::ACEXML_Namespace_Context_Stack (void)
+{
+}
+
+ACEXML_Namespace_Context_Stack::~ACEXML_Namespace_Context_Stack (void)
+{
+ // Clean up stuff.
+}
+
+int
+ACEXML_Namespace_Context_Stack::push (ACEXML_NS_CONTEXT *nsc)
+{
+ return (this->stack_.push (nsc) < 0);
+}
+
+ACEXML_NS_CONTEXT *
+ACEXML_Namespace_Context_Stack::pop (void)
+{
+ if (this->stack_.size() <= 0)
+ return 0;
+
+ ACEXML_NS_CONTEXT* temp = 0;
+ int retval = this->stack_.pop (temp);
+ if (retval != 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Unable to pop Namespace context from stack\n"));
+ return 0;
+ }
+ return temp;
+}
+
+int
+ACEXML_NamespaceSupport::popContext (void)
+{
+ delete this->effective_context_;
+
+ if ((this->effective_context_ = this->ns_stack_.pop ()) == 0)
+ return -1;
+ return 0;
+}
+
+int
+ACEXML_NamespaceSupport::pushContext (void)
+{
+ ACEXML_NS_CONTEXT *temp = this->effective_context_;
+ ACE_NEW_RETURN (this->effective_context_,
+ ACEXML_NS_CONTEXT (),
+ -1);
+
+ // @@ Copy everything from the old context to the new one.
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ for (ACEXML_NS_CONTEXT_ITER iter (*temp);
+ iter.next (entry) != 0;
+ iter.advance ())
+ this->effective_context_->bind (entry->ext_id_,
+ entry->int_id_);
+ this->ns_stack_.push (temp);
+ return 0;
+}
+
+ACEXML_NamespaceSupport::ACEXML_NamespaceSupport (void)
+ : ns_stack_ (),
+ effective_context_ (0)
+{}
+
+int
+ACEXML_NamespaceSupport::init (void)
+{
+ // @@ No way to tell if the new fails.
+ ACE_NEW_RETURN (effective_context_, ACEXML_NS_CONTEXT(), -1);
+
+ ACEXML_String prefix (ACEXML_TABOO_NS_PREFIX, 0, 0);
+ ACEXML_String uri (ACEXML_XMLNS_URI_name, 0, 0);
+ return this->effective_context_->bind (prefix, uri);
+}
+
+ACEXML_NamespaceSupport::~ACEXML_NamespaceSupport (void)
+{
+ while (this->popContext () == 0)
+ ;
+}
+
+int
+ACEXML_NamespaceSupport::declarePrefix (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri)
+{
+ if (!prefix || !uri)
+ return -1;
+
+ // Unless predefined by w3.org(?) NS prefix can never start with
+ // "xml".
+ if (ACE_OS::strcmp (ACEXML_TABOO_NS_PREFIX, prefix) == 0)
+ return -1;
+
+ ACEXML_String ns_prefix (prefix, 0, 0);
+ ACEXML_String ns_uri (uri, 0, 0);
+
+ return this->effective_context_->rebind (ns_prefix, ns_uri);
+}
+
+int
+ACEXML_NamespaceSupport::getDeclaredPrefixes (ACEXML_STR_LIST &prefixes) const
+{
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ // The prefix for default namespace (empty string) is included in
+ // the return list.
+ for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_);
+ iter.next (entry) != 0;
+ iter.advance ())
+ prefixes.enqueue_tail (entry->ext_id_.c_str ());
+
+ return 0;
+}
+
+const ACEXML_Char *
+ACEXML_NamespaceSupport::getPrefix (const ACEXML_Char *uri) const
+{
+ if (!uri || *uri == 0)
+ return 0;
+
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_);
+ iter.next (entry) != 0;
+ iter.advance ())
+ if (entry->int_id_ == ACEXML_String (uri, 0, 0))
+ return entry->ext_id_.c_str ();
+
+ return 0; // Nothing found.
+}
+
+int
+ACEXML_NamespaceSupport::getPrefixes (ACEXML_STR_LIST &prefixes) const
+{
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ // The prefix for default namespace (empty string) is not included
+ // in the return list.
+ for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_);
+ iter.next (entry) != 0;
+ iter.advance ())
+ prefixes.enqueue_tail (entry->ext_id_.c_str ());
+ return 0;
+}
+
+int
+ACEXML_NamespaceSupport::getPrefixes (const ACEXML_Char *uri,
+ ACEXML_STR_LIST &prefixes) const
+{
+ if (!uri)
+ return -1;
+
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ for (ACEXML_NS_CONTEXT_ITER iter (*this->effective_context_);
+ iter.next (entry) != 0;
+ iter.advance ())
+ if (entry->int_id_ == ACEXML_String (uri, 0, 0) &&
+ entry->ext_id_ != ACEXML_String (ACEXML_DEFAULT_NS_PREFIX, 0, 0))
+ prefixes.enqueue_tail (entry->ext_id_.c_str ());
+ else
+ continue;
+
+ return 0; // Nothing found.
+}
+
+const ACEXML_Char *
+ACEXML_NamespaceSupport::getURI (const ACEXML_Char *prefix) const
+{
+ if (!prefix)
+ return 0;
+
+ ACEXML_NS_CONTEXT_ENTRY *entry = 0;
+
+ if (this->effective_context_->find (ACEXML_String (prefix, 0, 0),
+ entry) == 0)
+ return entry->int_id_.c_str ();
+ return 0;
+}
+
+int
+ACEXML_NamespaceSupport::processName (const ACEXML_Char *qName,
+ const ACEXML_Char *&uri,
+ const ACEXML_Char *&name,
+ int is_attribute) const
+{
+ int qlen = static_cast<int> (ACE_OS::strlen (qName));
+ int len = -1;
+ for (int i = 0; i < qlen; ++i)
+ if (qName [i] == ':')
+ {
+ len = i;
+ break;
+ }
+
+ ACEXML_String prefix (ACE_TEXT(""),0,0);
+ if (len == -1)
+ name = qName;
+ else
+ {
+ prefix.set (qName, len, 1);
+ name = qName + len + 1;
+ }
+
+ if (is_attribute && len == -1) {
+ uri = ACEXML_DEFAULT_NS_PREFIX;
+ return 0;
+ }
+
+ ACEXML_NS_CONTEXT_ENTRY *entry;
+
+ if (this->effective_context_->find (prefix, entry) == 0)
+ uri = entry->int_id_.c_str ();
+ else
+ {
+ uri = ACEXML_DEFAULT_NS_PREFIX;
+ return -1;
+ }
+ return 0;
+}
+
+int
+ACEXML_NamespaceSupport::reset (void)
+{
+ while (this->popContext() != -1)
+ ;
+ return 0;
+}
+
diff --git a/ACE/ACEXML/common/NamespaceSupport.h b/ACE/ACEXML/common/NamespaceSupport.h
new file mode 100644
index 00000000000..d81f9303d70
--- /dev/null
+++ b/ACE/ACEXML/common/NamespaceSupport.h
@@ -0,0 +1,235 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file NamespaceSupport.h
+ *
+ * $Id$
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef ACEXML_NAMESPACESUPPORT_H
+#define ACEXML_NAMESPACESUPPORT_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+#include "ace/Functor.h"
+#include "ace/Hash_Map_Manager.h"
+#include "ace/Containers_T.h"
+#include "ace/Null_Mutex.h"
+
+
+typedef ACE_Hash_Map_Entry<ACEXML_String,
+ ACEXML_String> ACEXML_NS_CONTEXT_ENTRY;
+
+typedef ACE_Hash_Map_Manager_Ex<ACEXML_String,
+ ACEXML_String,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_NS_CONTEXT;
+
+typedef ACE_Hash_Map_Iterator_Ex<ACEXML_String,
+ ACEXML_String,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_NS_CONTEXT_ITER;
+
+typedef ACE_Hash_Map_Reverse_Iterator_Ex<ACEXML_String,
+ ACEXML_String,
+ ACE_Hash<ACEXML_String>,
+ ACE_Equal_To<ACEXML_String>,
+ ACE_Null_Mutex> ACEXML_NS_CONTEXT_REVERSE_ITER;
+
+typedef ACE_Unbounded_Queue<const ACEXML_Char *> ACEXML_STR_LIST;
+
+/**
+ * @class ACEXML_Namespace_Context_Stack NamespaceSupport.h "ACEXML/common/NamespaceSupport.h"
+ *
+ * @brief ACEXML_Namespace_Context_Stack implements a simple stack
+ * that ACEXML_NamespaceSupport uses to keep track of namespace scopes.
+ *
+ * @sa ACEXML_NamespaceSupport
+ */
+class ACEXML_Export ACEXML_Namespace_Context_Stack
+{
+public:
+ /// Default constructor.
+ ACEXML_Namespace_Context_Stack (void);
+
+ /// Destructor.
+ ~ACEXML_Namespace_Context_Stack (void);
+
+ /// Push the old namespace before entering into a new namespace scope.
+ int push (ACEXML_NS_CONTEXT * old);
+
+ /// Pop the old namespace when exiting a namespace scope.
+ ACEXML_NS_CONTEXT *pop (void);
+
+private:
+ /// Internal stack structure to hold namespace context.
+ ACE_Unbounded_Stack<ACEXML_NS_CONTEXT*> stack_;
+};
+
+/**
+ * @class ACEXML_NamespaceSupport NamespaceSupport.h "ACEXML/common/NamespaceSupport.h"
+ *
+ * @brief ACEXML_NamespaceSupport provides namespace management
+ * operation for an XML parser.
+ *
+ * This class encapsulates the logic of Namespace processing: it
+ * tracks the declarations currently in force for each context and
+ * automatically processes qualified XML 1.0 names into their
+ * Namespace parts; it can also be used in reverse for generating XML
+ * 1.0 from Namespaces.
+ *
+ * Namespace support objects are reusable, but the reset method must
+ * be invoked between each session.
+ *
+ * Here is a simple session (in Java :-p):
+ * @code
+ * String parts[] = new String[3];
+ * NamespaceSupport support = new NamespaceSupport();
+ *
+ * support.pushContext();
+ * support.declarePrefix("", "http://www.w3.org/1999/xhtml");
+ * support.declarePrefix("dc", "http://www.purl.org/dc#");
+ *
+ * String parts[] = support.processName("p", parts, false);
+ * System.out.println("Namespace URI: " + parts[0]);
+ * System.out.println("Local name: " + parts[1]);
+ * System.out.println("Raw name: " + parts[2]);
+ *
+ * String parts[] = support.processName("dc:title", parts, false);
+ * System.out.println("Namespace URI: " + parts[0]);
+ * System.out.println("Local name: " + parts[1]);
+ * System.out.println("Raw name: " + parts[2]);
+ *
+ * support.popContext();
+ * @endcode
+ *
+ * Note that this class is optimized for the use case where most
+ * elements do not contain Namespace declarations: if the same
+ * prefix/URI mapping is repeated for each context (for example), this
+ * class will be somewhat less efficient.
+ *
+ * @sa ACEXML_Exception
+ */
+class ACEXML_Export ACEXML_NamespaceSupport
+{
+public:
+ /**
+ * Default constructor.
+ */
+ ACEXML_NamespaceSupport (void);
+
+ /**
+ * Default destructor.
+ */
+ ~ACEXML_NamespaceSupport (void);
+
+ /**
+ * Initialize the namespace support object
+ */
+ int init(void);
+
+ /**
+ * XMLNS default prefix and URI strings.
+ */
+ static const ACEXML_Char *XMLNS_PREFIX;
+ static const ACEXML_Char *XMLNS;
+
+ /**
+ * Declare a Namespace prefix. Return -1 if the prefix was illegal
+ * or an internal error occured. Return 0 if the prefix gets declared
+ * successfully, 1 if the prefix replaces an existing prefix definition.
+ */
+ int declarePrefix (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri);
+
+ /**
+ * Return all prefixes declared in current context in
+ * the user-supplied list @a prefixes. It is user's reponsibility
+ * to ensure the list was empty originally.
+ */
+ int getDeclaredPrefixes (ACEXML_STR_LIST &prefixes) const;
+
+ /**
+ * Return one of the prefixes mapped to a Namespace URI.
+ */
+ const ACEXML_Char *getPrefix (const ACEXML_Char *uri) const;
+
+ /**
+ * Return all prefixes currently declared in the user-supplied list.
+ * @@ Known bug: This function should only return user-defined prefixes.
+ */
+ int getPrefixes (ACEXML_STR_LIST &prefixes) const;
+
+ /**
+ * Return all prefixes currently declared for a URI in the
+ * user-supplied list.
+ */
+ int getPrefixes (const ACEXML_Char *uri,
+ ACEXML_STR_LIST &prefixes) const;
+
+ /**
+ * Look up a prefix and get the currently-mapped Namespace URI.
+ */
+ const ACEXML_Char *getURI (const ACEXML_Char *prefix) const;
+
+ /**
+ * Revert to the previous namespace context.
+ */
+ int popContext (void);
+
+ /**
+ * Process a raw XML 1.0 name.
+ * @a qName is the raw XML name we want to parse,
+ * @a uri contains the URI string of the raw name. It points to a null
+ * string if the namespace is not valid or there's no namespace defined.
+ * @a name contains the original name without the prefix.
+ * @a is_attribute specifies whether the name is an attribute or not.
+ * Attributes have different scoping rules from elements.
+ */
+ int processName (const ACEXML_Char *qName,
+ const ACEXML_Char *&uri,
+ const ACEXML_Char *&name,
+ int is_attribute) const;
+
+ /**
+ * Start a new Namespace context. Prefixes defined in previous
+ * context are copied over to the new context.
+ */
+ int pushContext (void);
+
+ /**
+ * Reset this Namespace support object for reuse.
+ *
+ */
+ int reset (void);
+
+private:
+ /**
+ * Namespace Context stack. When we entering a new namespace
+ * context, the old context is duplicated and pushed into
+ * this stack.
+ */
+ ACEXML_Namespace_Context_Stack ns_stack_;
+
+ /**
+ * The effective namespace context.
+ */
+ ACEXML_NS_CONTEXT *effective_context_;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_NAMESPACESUPPORT_H */
diff --git a/ACE/ACEXML/common/SAXExceptions.cpp b/ACE/ACEXML/common/SAXExceptions.cpp
new file mode 100644
index 00000000000..0e1cbd2a827
--- /dev/null
+++ b/ACE/ACEXML/common/SAXExceptions.cpp
@@ -0,0 +1,261 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/SAXExceptions.h"
+#include "ace/Log_Msg.h"
+#include "ace/ACE.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+
+const ACEXML_Char *ACEXML_SAXException::exception_name_ = ACE_TEXT ("ACEXML_SAXException");
+
+const ACEXML_Char *ACEXML_SAXNotSupportedException::exception_name_ = ACE_TEXT ("ACEXML_SAXNotSupportedException");
+
+const ACEXML_Char *ACEXML_SAXNotRecognizedException::exception_name_ = ACE_TEXT ("ACEXML_SAXNotRecognizedException");
+
+const ACEXML_Char *ACEXML_SAXParseException::exception_name_ = ACE_TEXT ("ACEXML_SAXParseException");
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/SAXExceptions.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_SAXException::ACEXML_SAXException (void)
+ : message_ (0)
+{
+}
+
+ACEXML_SAXException::ACEXML_SAXException (const ACEXML_Char *msg)
+ : message_ (ACE::strnew (msg))
+{
+}
+
+ACEXML_SAXException::ACEXML_SAXException (const ACEXML_SAXException &ex)
+ : ACEXML_Exception (ex),
+ message_ (ACE::strnew (ex.message_))
+
+{
+}
+
+ACEXML_SAXException&
+ACEXML_SAXException::operator= (const ACEXML_SAXException& src)
+{
+ ACEXML_SAXException temp (src);
+ ACEXML_Char* message = this->message_;
+ this->exception_name_ = temp.exception_name_;
+ this->message_ = temp.message_;
+ temp.message_ = message;
+ return *this;
+}
+
+
+ACEXML_SAXException*
+ACEXML_SAXException::_downcast (ACEXML_Exception* ex)
+{
+ if (ex->is_a (ACE_TEXT ("ACEXML_SAXException")))
+ return dynamic_cast<ACEXML_SAXException*> (ex);
+ return 0;
+}
+
+ACEXML_SAXException::~ACEXML_SAXException (void)
+{
+ delete[] this->message_;
+}
+
+
+
+ACEXML_Exception *
+ACEXML_SAXException::duplicate (void) const
+{
+ ACEXML_Exception *tmp;
+ ACE_NEW_RETURN (tmp, ACEXML_SAXException (*this), 0);
+ return tmp;
+}
+
+int
+ACEXML_SAXException::is_a (const ACEXML_Char *name)
+{
+ return ACE_OS::strcmp (ACEXML_SAXException::exception_name_, name) == 0
+ || this->ACEXML_Exception::is_a (name);
+}
+
+void
+ACEXML_SAXException::print (void)
+{
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"),
+ this->exception_name_, this->message()));
+}
+
+ACEXML_SAXNotSupportedException::ACEXML_SAXNotSupportedException (void)
+{
+}
+
+ACEXML_SAXNotSupportedException::ACEXML_SAXNotSupportedException (const ACEXML_SAXNotSupportedException &ex)
+ : ACEXML_SAXException (ex)
+{
+}
+
+ACEXML_SAXNotSupportedException&
+ACEXML_SAXNotSupportedException::operator= (const
+ ACEXML_SAXNotSupportedException &ex)
+{
+ this->ACEXML_SAXException::operator= (ex);
+ return *this;
+}
+
+ACEXML_SAXNotSupportedException*
+ACEXML_SAXNotSupportedException::_downcast (ACEXML_Exception* ex)
+{
+ if (ex->is_a (ACE_TEXT ("ACEXML_SAXNotSupportedException")))
+ return dynamic_cast<ACEXML_SAXNotSupportedException*> (ex);
+ return 0;
+}
+
+ACEXML_SAXNotSupportedException::ACEXML_SAXNotSupportedException (const ACEXML_Char* msg)
+ : ACEXML_SAXException (msg)
+{
+}
+
+ACEXML_SAXNotSupportedException::~ACEXML_SAXNotSupportedException (void)
+{
+ delete[] this->message_;
+}
+
+
+ACEXML_Exception *
+ACEXML_SAXNotSupportedException::duplicate (void) const
+{
+ ACEXML_Exception *tmp;
+ ACE_NEW_RETURN (tmp, ACEXML_SAXNotSupportedException (*this), 0);
+ return tmp;
+}
+
+int
+ACEXML_SAXNotSupportedException::is_a (const ACEXML_Char *name)
+{
+ return ACE_OS::strcmp (ACEXML_SAXNotSupportedException::exception_name_,
+ name) == 0
+ || this->ACEXML_SAXException::is_a (name);
+}
+
+void
+ACEXML_SAXNotSupportedException::print (void)
+{
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"),
+ this->exception_name_, this->message()));
+}
+
+ACEXML_SAXNotRecognizedException::ACEXML_SAXNotRecognizedException (void)
+{
+}
+
+ACEXML_SAXNotRecognizedException::ACEXML_SAXNotRecognizedException (const ACEXML_Char *msg)
+ : ACEXML_SAXException (msg)
+{
+}
+
+ACEXML_SAXNotRecognizedException::ACEXML_SAXNotRecognizedException (const ACEXML_SAXNotRecognizedException &ex)
+ : ACEXML_SAXException (ex)
+{
+}
+
+ACEXML_SAXNotRecognizedException&
+ACEXML_SAXNotRecognizedException::operator= (const ACEXML_SAXNotRecognizedException &ex)
+{
+ this->ACEXML_SAXException::operator= (ex);
+ return *this;
+}
+
+ACEXML_SAXNotRecognizedException*
+ACEXML_SAXNotRecognizedException::_downcast (ACEXML_Exception* ex)
+{
+ if (ex->is_a (ACE_TEXT ("ACEXML_SAXNotRecognizedException")))
+ return dynamic_cast<ACEXML_SAXNotRecognizedException*> (ex);
+ return 0;
+}
+
+ACEXML_SAXNotRecognizedException::~ACEXML_SAXNotRecognizedException (void)
+{
+ delete[] this->message_;
+}
+
+ACEXML_Exception *
+ACEXML_SAXNotRecognizedException::duplicate (void) const
+{
+ ACEXML_Exception *tmp;
+ ACE_NEW_RETURN (tmp, ACEXML_SAXNotRecognizedException (*this), 0);
+ return tmp;
+}
+
+int
+ACEXML_SAXNotRecognizedException::is_a (const ACEXML_Char *name)
+{
+ return ACE_OS::strcmp (ACEXML_SAXNotRecognizedException::exception_name_,
+ name) == 0
+ || this->ACEXML_SAXException::is_a (name);
+}
+
+void
+ACEXML_SAXNotRecognizedException::print (void)
+{
+ ACE_DEBUG ((LM_ERROR,
+ ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"),
+ this->exception_name_, this->message()));
+}
+
+ACEXML_SAXParseException::ACEXML_SAXParseException (void)
+{
+}
+
+ACEXML_SAXParseException::ACEXML_SAXParseException (const ACEXML_Char *msg)
+ : ACEXML_SAXException (msg)
+{
+}
+
+ACEXML_SAXParseException::ACEXML_SAXParseException (const ACEXML_SAXParseException &ex)
+ : ACEXML_SAXException (ex)
+{
+}
+
+ACEXML_SAXParseException&
+ACEXML_SAXParseException::operator= (const ACEXML_SAXParseException &ex)
+{
+ this->ACEXML_SAXException::operator= (ex);
+ return *this;
+}
+
+ACEXML_SAXParseException*
+ACEXML_SAXParseException::_downcast (ACEXML_Exception* ex)
+{
+ if (ex->is_a (ACE_TEXT ("ACEXML_SAXParseException")))
+ return dynamic_cast<ACEXML_SAXParseException*> (ex);
+ return 0;
+}
+
+ACEXML_SAXParseException::~ACEXML_SAXParseException (void)
+{
+}
+
+ACEXML_Exception *
+ACEXML_SAXParseException::duplicate (void) const
+{
+ ACEXML_Exception *tmp;
+ ACE_NEW_RETURN (tmp, ACEXML_SAXParseException (*this), 0);
+ return tmp;
+}
+
+int
+ACEXML_SAXParseException::is_a (const ACEXML_Char *name)
+{
+ return ACE_OS::strcmp (ACEXML_SAXParseException::exception_name_,
+ name) == 0
+ || this->ACEXML_SAXException::is_a (name);
+}
+
+void
+ACEXML_SAXParseException::print (void)
+{
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ACEXML: (%P|%t) %s: %s\n"),
+ this->exception_name_, this->message()));
+}
diff --git a/ACE/ACEXML/common/SAXExceptions.h b/ACE/ACEXML/common/SAXExceptions.h
new file mode 100644
index 00000000000..d4965c93ee6
--- /dev/null
+++ b/ACE/ACEXML/common/SAXExceptions.h
@@ -0,0 +1,208 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file SAXExceptions.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_SAXEXCEPTIONS_H_
+#define _ACEXML_SAXEXCEPTIONS_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Exception.h"
+
+/**
+ * @class ACEXML_SAXException SAXExceptions.h "ACEXML/common/SAXExceptions.h"
+ *
+ * @brief ACEXML_SAXException
+ *
+ * ACEXML_SAXException is the mother of all SAX related exceptions.
+ */
+class ACEXML_Export ACEXML_SAXException : public ACEXML_Exception
+{
+public:
+ /// Default constructor.
+ ACEXML_SAXException (void);
+
+ /// Constructor initializing the exception message.
+ ACEXML_SAXException (const ACEXML_Char *msg);
+
+ /// Assignment operator
+ ACEXML_SAXException& operator= (const ACEXML_SAXException& src);
+
+ /// Copy constructor.
+ ACEXML_SAXException (const ACEXML_SAXException &ex);
+
+ /// Destructor.
+ virtual ~ACEXML_SAXException (void);
+
+ /// Throw the exception.
+ virtual void _raise (void);
+
+ /// Static narrow operation.
+ static ACEXML_SAXException* _downcast (ACEXML_Exception* ex);
+
+ /// Return the name of the exception.
+ virtual const ACEXML_Char *id (void) const;
+
+ /// Return the extra message accompanying the exception.
+ const ACEXML_Char *message (void);
+
+ virtual ACEXML_Exception *duplicate (void) const;
+
+ virtual int is_a (const ACEXML_Char *name);
+
+ virtual void print (void);
+
+protected:
+ static const ACEXML_Char *exception_name_;
+
+ /// A message providing more information about the exception being thrown.
+ ACEXML_Char *message_;
+};
+
+/**
+ * @class ACEXML_SAXNotSupportedException SAXExceptions.h "ACEXML/common/SAXExceptions.h"
+ *
+ * @brief ACEXML_SAXNotSupportedException
+ */
+class ACEXML_Export ACEXML_SAXNotSupportedException
+ : public ACEXML_SAXException
+{
+public:
+ /// Default constructor.
+ ACEXML_SAXNotSupportedException (void);
+
+ /// Copy constructor.
+ ACEXML_SAXNotSupportedException (const ACEXML_SAXNotSupportedException &ex);
+
+ /// Assignment operator
+ ACEXML_SAXNotSupportedException& operator= (const ACEXML_SAXNotSupportedException &ex);
+
+ /// Constructor which accepts an informational message
+ ACEXML_SAXNotSupportedException (const ACEXML_Char* msg);
+
+ /// Destructor.
+ virtual ~ACEXML_SAXNotSupportedException (void);
+
+ /// Throw the exception.
+ virtual void _raise (void);
+
+ /// Static narrow operation.
+ static ACEXML_SAXNotSupportedException* _downcast (ACEXML_Exception* ex);
+
+ virtual const ACEXML_Char *id (void) const;
+
+ virtual ACEXML_Exception *duplicate (void) const;
+
+ virtual int is_a (const ACEXML_Char *name);
+
+ virtual void print (void);
+
+protected:
+ static const ACEXML_Char *exception_name_;
+};
+
+/**
+ * @class ACEXML_SAXNotRecognizedException SAXExceptions.h "ACEXML/common/SAXExceptions.h"
+ *
+ * @brief ACEXML_SAXNotRecognizedException
+ */
+class ACEXML_Export ACEXML_SAXNotRecognizedException
+ : public ACEXML_SAXException
+{
+public:
+ /// Default constructor.
+ ACEXML_SAXNotRecognizedException (void);
+
+ /// Constructor with an initializing exception message.
+ ACEXML_SAXNotRecognizedException (const ACEXML_Char *msg);
+
+ /// Copy constructor.
+ ACEXML_SAXNotRecognizedException (const ACEXML_SAXNotRecognizedException &ex);
+
+ /// Assignment operator.
+ ACEXML_SAXNotRecognizedException& operator= (const ACEXML_SAXNotRecognizedException &ex);
+
+ /// Destructor.
+ virtual ~ACEXML_SAXNotRecognizedException (void);
+
+ /// Throw the exception.
+ virtual void _raise (void);
+
+ /// Static narrow operation.
+ static ACEXML_SAXNotRecognizedException* _downcast (ACEXML_Exception* ex);
+
+ virtual const ACEXML_Char *id (void) const;
+
+ virtual ACEXML_Exception *duplicate (void) const;
+
+ virtual int is_a (const ACEXML_Char *name);
+
+ virtual void print (void);
+
+protected:
+ static const ACEXML_Char *exception_name_;
+};
+
+/**
+ * @class ACEXML_SAXParseException SAXExceptions.h "ACEXML/common/SAXExceptions.h"
+ *
+ * @brief ACEXML_SAXParseException
+ *
+ */
+class ACEXML_Export ACEXML_SAXParseException
+ : public ACEXML_SAXException
+{
+public:
+ /// Default constructor.
+ ACEXML_SAXParseException (void);
+
+ /// Constructor with an initializing exception message.
+ ACEXML_SAXParseException (const ACEXML_Char *msg);
+
+ /// Copy constructor.
+ ACEXML_SAXParseException (const ACEXML_SAXParseException &ex);
+
+ /// Assignment operator.
+ ACEXML_SAXParseException& operator= (const ACEXML_SAXParseException &ex);
+
+ /// Destructor.
+ virtual ~ACEXML_SAXParseException (void);
+
+ /// Throw the exception.
+ virtual void _raise (void);
+
+ /// Static narrow operation.
+ static ACEXML_SAXParseException* _downcast (ACEXML_Exception* ex);
+
+ virtual const ACEXML_Char *id (void) const;
+
+ virtual ACEXML_Exception *duplicate (void) const;
+
+ virtual int is_a (const ACEXML_Char *name);
+
+ virtual void print (void);
+
+protected:
+ static const ACEXML_Char *exception_name_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/SAXExceptions.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_SAXEXCEPTIONS_H_ */
diff --git a/ACE/ACEXML/common/SAXExceptions.i b/ACE/ACEXML/common/SAXExceptions.i
new file mode 100644
index 00000000000..3aee40632b5
--- /dev/null
+++ b/ACE/ACEXML/common/SAXExceptions.i
@@ -0,0 +1,57 @@
+// -*- C++ -*- $Id$
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_SAXException::message (void)
+{
+ return (this->message_ == 0 ?
+ ACEXML_Exception::null_ :
+ this->message_);
+}
+
+ACEXML_INLINE void
+ACEXML_SAXException::_raise (void)
+{
+ ACEXML_RAISE (*this);
+}
+
+ACEXML_INLINE void
+ACEXML_SAXNotSupportedException::_raise (void)
+{
+ ACEXML_RAISE (*this);
+}
+
+ACEXML_INLINE void
+ACEXML_SAXNotRecognizedException::_raise (void)
+{
+ ACEXML_RAISE (*this);
+}
+
+ACEXML_INLINE void
+ACEXML_SAXParseException::_raise (void)
+{
+ ACEXML_RAISE (*this);
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_SAXException::id (void) const
+{
+ return ACEXML_SAXException::exception_name_;
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_SAXNotSupportedException::id (void) const
+{
+ return ACEXML_SAXNotSupportedException::exception_name_;
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_SAXNotRecognizedException::id (void) const
+{
+ return ACEXML_SAXNotRecognizedException::exception_name_;
+}
+
+ACEXML_INLINE const ACEXML_Char *
+ACEXML_SAXParseException::id (void) const
+{
+ return ACEXML_SAXParseException::exception_name_;
+}
diff --git a/ACE/ACEXML/common/StrCharStream.cpp b/ACE/ACEXML/common/StrCharStream.cpp
new file mode 100644
index 00000000000..aec2f83d945
--- /dev/null
+++ b/ACE/ACEXML/common/StrCharStream.cpp
@@ -0,0 +1,129 @@
+// $Id$
+
+#include "ACEXML/common/StrCharStream.h"
+#include "ACEXML/common/Encoding.h"
+#include "ace/ACE.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+
+ACEXML_StrCharStream::ACEXML_StrCharStream (void)
+ : start_ (0), ptr_ (0), end_ (0), encoding_ (0), name_ (0)
+{
+}
+
+
+ACEXML_StrCharStream::~ACEXML_StrCharStream (void)
+{
+ this->close();
+}
+
+int
+ACEXML_StrCharStream::open (const ACEXML_Char *str, const ACEXML_Char* name)
+{
+
+ if (str != 0 && name != 0
+ && (this->start_ = ACE::strnew (str)) != 0
+ && (this->name_ = ACE::strnew (name)) != 0)
+ {
+ this->ptr_ = this->start_;
+ this->end_ = this->start_ + ACE_OS::strlen (this->start_);
+ return this->determine_encoding();
+ }
+ return -1; // Invalid string passed.
+}
+
+int
+ACEXML_StrCharStream::available (void)
+{
+ if (this->start_ != 0)
+ return (this->end_ - this->start_); // @@ Will this work on all platforms?
+ return -1;
+}
+
+int
+ACEXML_StrCharStream::close (void)
+{
+ delete[] this->start_;
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+ delete[] this->name_;
+ this->name_ = 0;
+ this->start_ = this->ptr_ = this->end_ = 0;
+ return 0;
+}
+
+int
+ACEXML_StrCharStream::determine_encoding (void)
+{
+ if (this->start_ == 0)
+ return -1;
+ char input[4] = {0,0,0,0};
+ char* sptr = (char*)this->start_;
+ int i = 0;
+ for ( ; i < 4 && sptr != (char*)this->end_; ++sptr, ++i)
+ input[i] = *sptr;
+ const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input);
+ if (!temp)
+ return -1;
+ else
+ {
+ if (this->encoding_)
+ delete [] this->encoding_;
+ this->encoding_ = ACE::strnew (temp);
+ // ACE_DEBUG ((LM_DEBUG, "String's encoding is %s\n", this->encoding_));
+ }
+ return 0;
+}
+
+void
+ACEXML_StrCharStream::rewind (void)
+{
+ this->ptr_ = this->start_;
+ this->determine_encoding();
+}
+
+int
+ACEXML_StrCharStream::get (ACEXML_Char& ch)
+{
+ if (this->start_ != 0 && this->ptr_ != this->end_)
+ {
+ ch = *this->ptr_++;
+ return 0;
+ }
+ return -1;
+}
+
+int
+ACEXML_StrCharStream::read (ACEXML_Char *str, size_t len)
+{
+ if (this->start_ != 0 &&
+ this->ptr_ != this->end_)
+ {
+ if (len * sizeof (ACEXML_Char) > (size_t) (this->end_ - this->ptr_))
+ len = this->end_ - this->ptr_;
+ ACE_OS::strncpy (str, this->ptr_, len);
+ this->ptr_ += len;
+ return static_cast<int> (len);
+ }
+ return 0;
+}
+
+int
+ACEXML_StrCharStream::peek (void)
+{
+ if (this->start_ != 0 && this->ptr_ != this->end_)
+ return *this->ptr_;
+ return -1;
+}
+
+const ACEXML_Char*
+ACEXML_StrCharStream::getEncoding (void)
+{
+ return this->encoding_;
+}
+
+const ACEXML_Char*
+ACEXML_StrCharStream::getSystemId(void)
+{
+ return this->name_;
+}
diff --git a/ACE/ACEXML/common/StrCharStream.h b/ACE/ACEXML/common/StrCharStream.h
new file mode 100644
index 00000000000..21de6ecaea4
--- /dev/null
+++ b/ACE/ACEXML/common/StrCharStream.h
@@ -0,0 +1,102 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file StrCharStream.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_STRCHARSTREAM_H_
+#define _ACEXML_STRCHARSTREAM_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/CharStream.h"
+
+/**
+ * @class ACEXML_StrCharStream StrCharStream.h "common/StrCharStream.h"
+ *
+ * An implementation of ACEXML_CharStream for reading
+ * input from a null-terminated ACEXML_Char string.
+ */
+class ACEXML_Export ACEXML_StrCharStream : public ACEXML_CharStream
+{
+public:
+ /// Default constructor.
+ ACEXML_StrCharStream (void);
+
+ /// Destructor
+ virtual ~ACEXML_StrCharStream (void);
+
+ /// Initializing StrCharStream with @a str and @a name
+ int open (const ACEXML_Char *str, const ACEXML_Char* name);
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void);
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void);
+
+ /**
+ * Determine the encoding of the file.
+ */
+ virtual int determine_encoding (void);
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if EOS is reached, or 1 if succeed.
+ */
+ virtual int get (ACEXML_Char& ch);
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str, size_t len);
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if succeess, -1 if EOS is reached.
+ */
+ virtual int peek (void);
+
+ /*
+ * Get the character encoding for a byte stream or URI.
+ */
+ virtual const ACEXML_Char *getEncoding (void);
+
+ /*
+ * Get the systemId for the underlying CharStream
+ */
+ virtual const ACEXML_Char* getSystemId (void);
+
+ /**
+ * Resets the pointer to the beginning of the stream.
+ */
+ virtual void rewind (void);
+
+private:
+ ACEXML_Char *start_;
+ ACEXML_Char *ptr_;
+ ACEXML_Char *end_;
+ ACEXML_Char* encoding_;
+ ACEXML_Char* name_;
+
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_STRCHARSTREAM_H_ */
diff --git a/ACE/ACEXML/common/StreamFactory.cpp b/ACE/ACEXML/common/StreamFactory.cpp
new file mode 100644
index 00000000000..7cee4c1a65f
--- /dev/null
+++ b/ACE/ACEXML/common/StreamFactory.cpp
@@ -0,0 +1,56 @@
+// $Id$
+
+#include "ace/OS_NS_string.h"
+
+#include "ACEXML/common/StreamFactory.h"
+#include "ACEXML/common/FileCharStream.h"
+#include "ACEXML/common/HttpCharStream.h"
+
+#ifdef USE_ZZIP
+#include "ACEXML/common/ZipCharStream.h"
+#endif /* USE_ZZIP */
+
+ACE_RCSID (common, StreamFactory, "$Id$")
+
+ACEXML_CharStream*
+ACEXML_StreamFactory::create_stream (const ACEXML_Char* uri)
+{
+ if (uri == 0)
+ return 0;
+ ACEXML_FileCharStream* fstream = 0;
+ ACEXML_HttpCharStream* hstream = 0;
+
+ if (ACE_OS::strstr (uri, ACE_TEXT("ftp://")) != 0)
+ {
+ return 0;
+ }
+ else if (ACE_OS::strstr (uri, ACE_TEXT ("http://")) != 0)
+ {
+ ACE_NEW_RETURN (hstream, ACEXML_HttpCharStream, 0);
+ if (hstream->open (uri) != -1)
+ return hstream;
+ }
+ else
+ {
+ if (ACE_OS::strstr (uri, ACE_TEXT ("file://")) != 0)
+ uri += 7; // Skip over file://
+ ACE_NEW_RETURN (fstream, ACEXML_FileCharStream, 0);
+ if (fstream->open (uri) != -1)
+ return fstream;
+#ifdef USE_ZZIP
+ else
+ {
+ ACEXML_ZipCharStream* zstream = 0;
+ ACE_NEW_RETURN (zstream, ACEXML_ZipCharStream, 0);
+ if (zstream->open (uri) != -1)
+ return zstream;
+ }
+#endif /* USE_ZZIP */
+ }
+ return 0;
+}
+
+ACEXML_StreamFactory::~ACEXML_StreamFactory ()
+{
+ // No op
+}
diff --git a/ACE/ACEXML/common/StreamFactory.h b/ACE/ACEXML/common/StreamFactory.h
new file mode 100644
index 00000000000..9391eb6a299
--- /dev/null
+++ b/ACE/ACEXML/common/StreamFactory.h
@@ -0,0 +1,58 @@
+/**
+ * @file StreamFactory.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+
+#ifndef _ACEXML_STREAM_FACTORY_H
+#define _ACEXML_STREAM_FACTORY_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+// Forward declarations
+
+class ACEXML_CharStream;
+
+/**
+ * @class ACEXML_StreamFactory StreamFactory.h "ACEXML/common/ACEXML_StreamFactory.h"
+ *
+ * @brief A generic factory used to create an appropriate @sa
+ * ACEXML_CharStream from a SYSTEM id. This class creates a @sa
+ * ACEXML_FileCharStream or a @sa ACEXML_HttpCharStream depending on the
+ * URI supplied.
+ *
+ * @todo Write a stream abstraction for handling ftp:// type URIs and add
+ * a function to create and return such streams. That is the only chunk
+ * missing in the armour.
+ */
+
+class ACEXML_Export ACEXML_StreamFactory
+{
+public:
+
+ // Destructor
+ virtual ~ACEXML_StreamFactory (void);
+
+ /**
+ * Create the appropriate stream from the @a uri passed and return the
+ * stream. The caller is responsible for deallocating the returned
+ * stream.
+ *
+ * @param uri SYSTEM id or a stream of characters (in the case of a
+ * StrCharStream).
+ */
+ virtual ACEXML_CharStream* create_stream (const ACEXML_Char* uri);
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_STREAM_FACTORY_H */
diff --git a/ACE/ACEXML/common/Transcode.cpp b/ACE/ACEXML/common/Transcode.cpp
new file mode 100644
index 00000000000..f94d93bba32
--- /dev/null
+++ b/ACE/ACEXML/common/Transcode.cpp
@@ -0,0 +1,311 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/Transcode.h"
+#include "ace/OS_NS_string.h"
+
+int
+ACEXML_Transcoder::utf162utf8 (ACEXML_UTF16 src,
+ ACEXML_UTF8 *dst,
+ size_t len)
+{
+ // Check for valid argument first...
+
+ if (dst == 0)
+ return ACEXML_INVALID_ARGS;
+
+ if (src < 0x80)
+ {
+ if (len < 1)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ *dst = static_cast<ACEXML_UTF8> (src);
+ return 1;
+ }
+ else if (src < 0x800)
+ {
+ if (len < 2)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ *dst = 0xc0 | (static_cast<ACEXML_UTF8> (src) / 0x40);
+ *(dst+1) = 0x80 | (static_cast<ACEXML_UTF8> (src) % 0x40);
+ return 2;
+ }
+ else
+ {
+ if (len < 3)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ // Surrogates (0xD800 - 0xDFFF) are not valid unicode values
+ if (src >= 0xD800 && src < 0xE000)
+ return ACEXML_IS_SURROGATE;
+
+ *dst = 0xe0 | (static_cast<ACEXML_UTF8> (src) / 0x1000);
+ *(dst+1) = 0x80 | ((static_cast<ACEXML_UTF8> (src) % 0x1000) / 0x40);
+ *(dst+2) = 0x80 | (static_cast<ACEXML_UTF8> (src) % 0x40);
+ return 3;
+ }
+}
+
+int
+ACEXML_Transcoder::ucs42utf8 (ACEXML_UCS4 src,
+ ACEXML_UTF8 *dst,
+ size_t len)
+{
+ if (src < 0x10000)
+ {
+ int retv = ACEXML_Transcoder::utf162utf8
+ (static_cast<ACEXML_UTF16> (src),
+ dst, len);
+ return (retv == ACEXML_IS_SURROGATE ? ACEXML_NON_UNICODE : retv);
+ }
+ else if (src >= 0x100000 && src < 0x110000)
+ {
+ if (len < 4)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ if (dst == 0)
+ return ACEXML_INVALID_ARGS;
+
+ *dst = 0xf0 | (static_cast<ACEXML_UTF8> (src / 0x40000));
+ *(dst+1) = 0x80 | ((static_cast<ACEXML_UTF8> (src % 0x40000)) / 0x1000);
+ *(dst+2) = 0x80 | ((static_cast<ACEXML_UTF8> (src % 0x1000)) / 0x40);
+ *(dst+3) = 0x80 | (static_cast<ACEXML_UTF8> (src % 0x40));
+ return 4;
+ }
+ return ACEXML_NON_UNICODE;
+}
+
+
+int
+ACEXML_Transcoder::ucs42utf16 (ACEXML_UCS4 src,
+ ACEXML_UTF16 *dst,
+ size_t len)
+{
+ if (dst == 0)
+ return ACEXML_INVALID_ARGS;
+
+ if (src < 0x10000)
+ {
+ if (len < 1)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ if (src >= 0xD800 && src < 0xE000)
+ return ACEXML_NON_UNICODE; // Surrogates are not valid unicode value
+
+ *dst = static_cast<ACEXML_UTF16> (src);
+ return 1;
+ }
+ else if (src >= 0x100000 && src < 0x110000)
+ // Scalar values are encoded into surrogates
+ {
+ if (len < 2)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ *dst = 0xD800 | (static_cast<ACEXML_UTF16> (src) / 0x400);
+ *(dst+1) = 0xDC00 | (static_cast<ACEXML_UTF16> (src) % 0x400);
+ return 2;
+ }
+
+ return ACEXML_NON_UNICODE;
+}
+
+int
+ACEXML_Transcoder::surrogate2utf8 (ACEXML_UTF16 high,
+ ACEXML_UTF16 low,
+ ACEXML_UTF8 *dst,
+ size_t len)
+{
+ if (len < 3)
+ return ACEXML_DESTINATION_TOO_SHORT;
+
+ if (dst == 0 ||
+ (high >= 0xD800 && high < 0xDC00) ||
+ (low >= 0xDC00 && low < 0xE000))
+ return ACEXML_INVALID_ARGS;
+
+ ACEXML_UCS4 src = (high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;
+ *dst = static_cast<ACEXML_UTF8> (0xD800 | (src / 0x400));
+ *(dst+1) = static_cast<ACEXML_UTF8> (0xDC00 | (src % 0x400));
+ return 2;
+}
+
+int
+ACEXML_Transcoder::surrogate2ucs4 (ACEXML_UTF16 high,
+ ACEXML_UTF16 low,
+ ACEXML_UCS4 &dst)
+{
+ if ((high >= 0xD800 && high < 0xDC00) ||
+ (low >= 0xDC00 && low < 0xE000))
+ return ACEXML_INVALID_ARGS;
+
+ dst = (high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000;
+ return ACEXML_SUCCESS;
+}
+
+int
+ACEXML_Transcoder::utf82ucs4 (const ACEXML_UTF8 *the_src,
+ size_t len,
+ ACEXML_UCS4 &dst)
+{
+ if (the_src == 0)
+ return ACEXML_INVALID_ARGS;
+
+ const unsigned char *src = reinterpret_cast<const unsigned char *> (the_src);
+
+ size_t forward = 1;
+
+ if (forward > len)
+ return ACEXML_END_OF_SOURCE;
+
+ if (static_cast<unsigned char> (*src) < 0x80)
+ dst = *src;
+ else if ((*src & 0xE0) == 0xC0)
+ {
+ dst = (*(src++) & 0x1f) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE; // Error transcoding unicode scalar
+ dst += *src & 0x3f;
+ }
+ else if ((*src & 0xF0) == 0xE0)
+ {
+ dst = (*src++ & 0x0f) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE;
+ dst = (dst + (*src++ & 0x3f)) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE;
+ dst += *src & 0x3f;
+ }
+ else if ((*src & 0xF8) == 0xF0)
+ {
+ dst = (*src++ & 0x0f) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE;
+ dst = (dst + (*src++ & 0x3f)) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE;
+ dst = (dst + (*src++ & 0x3f)) * 0x40;
+ if (++forward > len)
+ return ACEXML_END_OF_SOURCE;
+ if ((*src & 0xC0) != 0x80)
+ return ACEXML_NON_UNICODE;
+ dst += *src & 0x3f;
+ }
+ else
+ return ACEXML_NON_UNICODE;
+
+ return forward;
+}
+
+int
+ACEXML_Transcoder::utf162ucs4 (const ACEXML_UTF16 *src,
+ size_t len,
+ ACEXML_UCS4 &dst)
+{
+ if (src == 0)
+ return ACEXML_INVALID_ARGS;
+
+ size_t forward = 1;
+ if (*src >= 0xDC00 && *src < 0xE000)
+ {
+ if (len < 2)
+ return ACEXML_END_OF_SOURCE;
+ return ACEXML_Transcoder::surrogate2ucs4 (*src,
+ *(src+1),
+ dst);
+ }
+ else
+ {
+ if (len < 1)
+ return ACEXML_END_OF_SOURCE;
+ dst = *src;
+ }
+
+ return forward;
+}
+
+int
+ACEXML_Transcoder::utf8s2utf16s (const ACEXML_UTF8 *src,
+ ACEXML_UTF16 *dst,
+ size_t len)
+{
+ if (src == 0 || dst == 0)
+ return ACEXML_INVALID_ARGS;
+
+ size_t src_len = ACE_OS::strlen (src) + 1;
+
+ size_t total_len = 0;
+ int forward;
+ ACEXML_UCS4 temp;
+
+ while (src_len > 0)
+ {
+ if ((forward = ACEXML_Transcoder::utf82ucs4 (src,
+ src_len,
+ temp)) <= 0)
+ return forward;
+
+ src += forward;
+ src_len -= forward;
+
+ if ((forward = ACEXML_Transcoder::ucs42utf16 (temp,
+ dst,
+ len)) <= 0)
+ return forward;
+
+ total_len += forward;
+ dst += forward;
+ len -= forward;
+ }
+
+ return static_cast<int> (total_len);
+}
+
+int
+ACEXML_Transcoder::utf16s2utf8s (const ACEXML_UTF16 *src,
+ ACEXML_UTF8 *dst,
+ size_t len)
+{
+ if (src == 0 || dst == 0)
+ return ACEXML_INVALID_ARGS;
+
+ size_t src_len = 1;
+ for (const ACEXML_UTF16 *p = src; *p++ != 0; ++src_len)
+ ;
+
+ size_t total_len = 0;
+ int forward;
+ ACEXML_UCS4 temp;
+
+ while (src_len > 0)
+ {
+ if ((forward = ACEXML_Transcoder::utf162ucs4 (src,
+ src_len,
+ temp)) <= 0)
+ return forward;
+
+ src += forward;
+ src_len -= forward;
+
+ if ((forward = ACEXML_Transcoder::ucs42utf8 (temp,
+ dst,
+ len)) <= 0)
+ return forward;
+
+ total_len += forward;
+ dst += forward;
+ len -= forward;
+ }
+
+ return static_cast<int> (total_len);
+}
diff --git a/ACE/ACEXML/common/Transcode.h b/ACE/ACEXML/common/Transcode.h
new file mode 100644
index 00000000000..1acf294c7aa
--- /dev/null
+++ b/ACE/ACEXML/common/Transcode.h
@@ -0,0 +1,172 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Transcode.h
+ *
+ * This file declares functions to convert char string among different
+ * unicode encoding (utf8, utf16, utf32)
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_TRANSCODE_H_
+#define _ACEXML_TRANSCODE_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+/**
+ * @class ACEXML_Transcoder Transcode.h "ACEXML/common/Transcode.h"
+ *
+ * @brief ACEXML_Transcoder
+ *
+ * Wrapper class for performing transcoding among different UNICODE
+ * encoding.
+ */
+class ACEXML_Export ACEXML_Transcoder
+{
+public:
+ /*
+ * Status of the conversion function.
+ */
+ enum
+ {
+ ACEXML_SUCCESS = 0,
+ ACEXML_DESTINATION_TOO_SHORT = -1,
+ ACEXML_END_OF_SOURCE = -2,
+ ACEXML_INVALID_ARGS = -3,
+ ACEXML_IS_SURROGATE = -4,
+ ACEXML_NON_UNICODE = -5
+ } ACEXML_STATUS;
+
+
+ // The following functions translate a unicode characters
+ // into different encoding. Return number of characters put into
+ // destination or consumed from src if success without
+ // error, otherwise, return corresponding error code.
+ /*
+ * Convert a UTF-16 character into a string in UTF-8 encoding.
+ *
+ * @return number of characters the function uses to store the
+ * converted string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int utf162utf8 (ACEXML_UTF16 src,
+ ACEXML_UTF8 *dst,
+ size_t len);
+
+ /*
+ * Convert a UCS-4 character into a string in UTF-8 encoding.
+ *
+ * @return number of characters the function uses to store the
+ * converted string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int ucs42utf8 (ACEXML_UCS4 src,
+ ACEXML_UTF8 *dst,
+ size_t len);
+
+ /*
+ * Convert a UCS-4 character into a string in UTF-16 encoding.
+ *
+ * @return number of characters the function uses to store the
+ * converted string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int ucs42utf16 (ACEXML_UCS4 src,
+ ACEXML_UTF16 *dst,
+ size_t len);
+
+ /*
+ * Convert a UTF-16 surrogate character pair into a string in UTF-8 encoding.
+ *
+ * @return number of characters the function uses to store the
+ * converted string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int surrogate2utf8 (ACEXML_UTF16 high,
+ ACEXML_UTF16 low,
+ ACEXML_UTF8 *dst,
+ size_t len);
+
+ /*
+ * Convert a UTF-16 surrogate character pair into a UCS-4 character.
+ *
+ * @return SUCCESS if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int surrogate2ucs4 (ACEXML_UTF16 high,
+ ACEXML_UTF16 low,
+ ACEXML_UCS4 &dst);
+
+ /*
+ * Convert the first UNICODE character in a UTF-8 character string
+ * into a UCS-4 character.
+ *
+ * @return number of characters the function consumed from the
+ * UTF-8 string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int utf82ucs4 (const ACEXML_UTF8 *src,
+ size_t len,
+ ACEXML_UCS4 &dst);
+
+ /*
+ * Convert the first UNICODE character in a UTF-16 character string
+ * into a UCS-4 character.
+ *
+ * @return number of characters the function consumed from the
+ * UTF-16 string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int utf162ucs4 (const ACEXML_UTF16 *src,
+ size_t len,
+ ACEXML_UCS4 &dst);
+
+// static int utf82utf16 (const ACEXML_UTF8 *src,
+// size_t len,
+// ACEXML_UTF16 &dst);
+ // This function does not handle surrogates.
+
+ // = The following functions are non-inlined:
+
+ /*
+ * Convert a UTF-8 string into a UTF-16 string.
+ *
+ * @param len The length of @a dst string.
+ *
+ * @return number of characters the function consumed from the
+ * UTF-8 string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int utf8s2utf16s (const ACEXML_UTF8 *src,
+ ACEXML_UTF16 *dst,
+ size_t len);
+
+ /*
+ * Convert a UTF-16 string into a UTF-8 string.
+ *
+ * @param len The length of @a dst string.
+ *
+ * @return number of characters the function uses in
+ * UTF-8 string if it succeeds or one of the error STATUS
+ * otherwise.
+ */
+ static int utf16s2utf8s (const ACEXML_UTF16 *src,
+ ACEXML_UTF8 *dst,
+ size_t len);
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_TRANSCODE_H_ */
diff --git a/ACE/ACEXML/common/URL_Addr.cpp b/ACE/ACEXML/common/URL_Addr.cpp
new file mode 100644
index 00000000000..b58c916c73f
--- /dev/null
+++ b/ACE/ACEXML/common/URL_Addr.cpp
@@ -0,0 +1,177 @@
+// $Id$
+
+#include "ACEXML/common/URL_Addr.h"
+
+ACE_RCSID(common, ACEXML_URL_Addr, "$Id$")
+
+#if !defined (__ACEXML_INLINE__)
+#include "ACEXML/common/URL_Addr.inl"
+#endif /* __ACEXML_INLINE__ */
+
+#include "ace/Log_Msg.h"
+#include "ace/Auto_Ptr.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_NS_string.h"
+
+ACEXML_URL_Addr::ACEXML_URL_Addr (void)
+ : path_name_ (0),
+ addr_string_ (0),
+ addr_string_len_ (0)
+{
+}
+
+int
+ACEXML_URL_Addr::addr_to_string (ACEXML_Char *s,
+ size_t size,
+ int ipaddr_format) const
+{
+ size_t total_len = this->calculate_length (ipaddr_format);
+ if (size < total_len)
+ return -1;
+ else
+ {
+ ACE_OS::sprintf (s, ACE_TEXT ("%s:%d/%s"),
+ ACE_TEXT_CHAR_TO_TCHAR (ipaddr_format == 0
+ ? this->get_host_name ()
+ : this->get_host_addr ()),
+ this->get_port_number (),
+ this->get_path_name ());
+ return 0;
+ }
+}
+
+const ACEXML_Char *
+ACEXML_URL_Addr::addr_to_string (int ipaddr_format)
+{
+ size_t size = this->calculate_length (ipaddr_format);
+ if (size > this->addr_string_len_)
+ {
+ ACE_ALLOCATOR_RETURN (this->addr_string_,
+ (ACEXML_Char *) ACE_OS::realloc(this->addr_string_,
+ size), 0);
+ this->addr_string_len_ = size;
+ }
+ ACE_OS::sprintf (this->addr_string_,
+ ACE_TEXT ("%s:%d/%s"),
+ ACE_TEXT_CHAR_TO_TCHAR (ipaddr_format == 0
+ ? this->get_host_name ()
+ : this->get_host_addr ()),
+ this->get_port_number (),
+ this->get_path_name ());
+ return this->addr_string_;
+}
+
+#if defined (ACE_USES_WCHAR)
+int
+ACEXML_URL_Addr::string_to_addr (const char* s)
+{
+ return this->string_to_addr (ACE_TEXT_CHAR_TO_TCHAR (s));
+}
+#endif /* ACE_USES_WCHAR */
+
+int
+ACEXML_URL_Addr::string_to_addr (const ACEXML_Char* s)
+{
+ if (s == 0)
+ return -1;
+
+ const ACEXML_Char* http = ACE_TEXT ("http://");
+ size_t http_len = ACE_OS::strlen (http);
+
+ // Check validity of URL
+ if (ACE_OS::strncmp (http, s, http_len) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Invalid URL %s\n"), s), -1);
+
+ const ACEXML_Char* url = 0;
+ // Get the host name
+ for (url = s + http_len; *url != '\0' && *url != ':' && *url != '/'; ++url)
+ ;
+
+ size_t host_len = url - s;
+ host_len -= http_len;
+
+ ACEXML_Char* host_name = 0;
+ ACE_NEW_RETURN (host_name, ACEXML_Char[host_len + 1], -1);
+ ACE_OS::strncpy (host_name, s + http_len, host_len);
+ host_name[host_len] = '\0';
+ ACE_Auto_Basic_Array_Ptr<ACEXML_Char> cleanup_host_name (host_name);
+
+ // Get the port number (if any)
+ unsigned short port = ACE_DEFAULT_HTTP_PORT;
+ if (*url == ':')
+ {
+ port = (unsigned short) ACE_OS::strtol (++url, 0, 10); // Skip over ':'
+ while ( *url != '\0' && *url != '/' )
+ ++url;
+ }
+
+ // Set the addr
+ int result = this->ACE_INET_Addr::set (port, host_name);
+
+ if (result == -1)
+ return -1;
+
+ // Get the path name
+ const ACEXML_Char* path_name = 0;
+ if (*url == '\0')
+ path_name = ACE_TEXT ("/");
+ else
+ path_name = url;
+
+ ACE_ALLOCATOR_RETURN (this->path_name_, ACE_OS::strdup (path_name), -1);
+ return result;
+}
+
+ACEXML_URL_Addr::ACEXML_URL_Addr (const ACEXML_URL_Addr &addr)
+ : ACE_INET_Addr (),
+ path_name_ (0),
+ addr_string_ (0),
+ addr_string_len_ (0)
+{
+ if (this->set (addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACEXML_URL_Addr::ACEXML_URL_Addr")));
+}
+
+int
+ACEXML_URL_Addr::set (const ACEXML_URL_Addr &addr)
+{
+ ACE_OS::free (this->path_name_);
+ ACE_OS::free (this->addr_string_);
+ if (this->ACE_INET_Addr::set (addr) == -1)
+ return -1;
+ else
+ {
+ if (addr.path_name_)
+ ACE_ALLOCATOR_RETURN (this->path_name_,
+ ACE_OS::strdup (addr.path_name_),
+ -1);
+ if (addr.addr_string_)
+ ACE_ALLOCATOR_RETURN (this->addr_string_,
+ ACE_OS::strdup (addr.addr_string_),
+ -1);
+ this->addr_string_len_ = addr.addr_string_len_;
+ return 0;
+ }
+}
+
+ACEXML_URL_Addr::ACEXML_URL_Addr (const ACEXML_Char *host_name,
+ const ACEXML_Char *path_name,
+ unsigned short port)
+ : ACE_INET_Addr (port, host_name),
+ path_name_ (ACE_OS::strdup (path_name)),
+ addr_string_ (0),
+ addr_string_len_ (0)
+{
+}
+
+ACEXML_URL_Addr::~ACEXML_URL_Addr (void)
+{
+ ACE_OS::free (this->path_name_);
+ ACE_OS::free (this->addr_string_);
+ this->path_name_ = 0;
+}
+
diff --git a/ACE/ACEXML/common/URL_Addr.h b/ACE/ACEXML/common/URL_Addr.h
new file mode 100644
index 00000000000..d7f7b4b6702
--- /dev/null
+++ b/ACE/ACEXML/common/URL_Addr.h
@@ -0,0 +1,135 @@
+/* -*- C++ -*- */
+
+/** @file URL_Addr.h
+ *
+ * $Id$
+ *
+ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ *
+ */
+
+#ifndef _ACEXML_URL_ADDR_H
+#define _ACEXML_URL_ADDR_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Default_Constants.h"
+#include "ace/INET_Addr.h"
+#include "ACEXML/common/XML_Types.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+/**
+ * @class ACEXML_URL_Addr URL_Addr.h "ACEXML/common/URL_Addr.h"
+ *
+ * Defines a URL address family address format.
+ */
+class ACEXML_Export ACEXML_URL_Addr : public ACE_INET_Addr
+{
+public:
+ /// Initialization and termination methods.
+ ACEXML_URL_Addr (void);
+
+ /// Constructor.
+ ACEXML_URL_Addr (const ACEXML_Char *host_name,
+ const ACEXML_Char *path_name,
+ unsigned short port = ACE_DEFAULT_HTTP_PORT);
+
+ /// Copy constructor.
+ ACEXML_URL_Addr (const ACEXML_URL_Addr &addr);
+
+ /// Essentially the copy constructor.
+ int set (const ACEXML_URL_Addr &addr);
+
+ /**
+ * Initializes an <ACEXML_URL_Addr> from the <address>, which can be
+ * "ip-number:port-number/path-name" (e.g.,
+ * "www.cs.wustl.edu:1234/~schmidt/" "ip-number:port-number/path-name"
+ * (e.g., "128.252.166.57:1234/~schmidt"). If there is no ':' in the
+ * <address> it is assumed to be an ip-number or ip-address number, with
+ * the port number <ACE_DEFAULT_HTTP_PORT>.
+ */
+ virtual int string_to_addr (const ACEXML_Char* address);
+
+ // Function to shut up Borland C++
+#if defined (ACE_USES_WCHAR)
+ virtual int string_to_addr (const char* address);
+#endif
+
+ /**
+ * Transform the current <ACE_INET_Addr> address into string format. If
+ * <ipaddr_format> is non-0 this produces
+ * "ip-number:port-number/path-name" (e.g.,
+ * "128.252.166.57:80/~schmidt/"), whereas if <ipaddr_format> is 0 this
+ * produces "ip-name:port-number" (e.g.,
+ * "www.cs.wustl.edu:80/~schmidt/"). Returns -1 if the <size> of the
+ * <buffer> is too small, else 0.
+ */
+ virtual int addr_to_string (ACEXML_Char *s,
+ size_t size,
+ int ipaddr_format = 1) const;
+
+ /**
+ * Transform the current <ACE_INET_Addr> address into string format. If
+ * <ipaddr_format> is non-0 this produces
+ * "ip-number:port-number/path-name" (e.g.,
+ * "128.252.166.57:80/~schmidt/"), whereas if <ipaddr_format> is 0 this
+ * produces "ip-name:port-number" (e.g.,
+ * "www.cs.wustl.edu:80/~schmidt/"). Uses dynamic memory, which is
+ * allocated on demand and deallocated when the object is destroyed.
+ * Returns -1 if dynamic memory fails, else 0.
+ */
+ virtual const ACEXML_Char *addr_to_string (int ipaddr_format = 1);
+
+ /// Assignment operator.
+ void operator= (const ACEXML_URL_Addr &addr);
+
+ /// Destructor.
+ ~ACEXML_URL_Addr (void);
+
+ /**
+ * Compare two addresses for equality. The addresses are considered
+ * equal if they contain the same IP address, port number, and path name.
+ */
+ bool operator == (const ACEXML_URL_Addr &SAP) const;
+
+ /// Compare two addresses for inequality.
+ bool operator != (const ACEXML_URL_Addr &SAP) const;
+
+ /// Computes and returns hash value.
+ virtual u_long hash (void) const;
+
+ /// Return the path name.
+ const ACEXML_Char *get_path_name (void) const;
+
+ /// Commit suicide.
+ int destroy (void);
+
+private:
+
+ /// Calculate the maximum length of the address string
+ size_t calculate_length (int ipaddr_format) const;
+
+ /// Our path name.
+ ACEXML_Char *path_name_;
+
+ /// The dynamically created address string that's used for the
+ /// <addr_to_string> method.
+ ACEXML_Char *addr_string_;
+
+ /// Current length of the <addr_string_>
+ size_t addr_string_len_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/URL_Addr.inl"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_URL_ADDR_H */
diff --git a/ACE/ACEXML/common/URL_Addr.inl b/ACE/ACEXML/common/URL_Addr.inl
new file mode 100644
index 00000000000..b1ac1db8322
--- /dev/null
+++ b/ACE/ACEXML/common/URL_Addr.inl
@@ -0,0 +1,65 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#include "ace/ACE.h"
+#include "ace/INET_Addr.h"
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+
+ACE_INLINE size_t
+ACEXML_URL_Addr::calculate_length (int ipaddr_format) const
+{
+ return ACE_OS::strlen (ipaddr_format == 0 ?
+ this->get_host_name () : this->get_host_addr ())
+ + ACE_OS::strlen ("65536") // Assume the max port number.
+ + ACE_OS::strlen (this->get_path_name ())
+ + sizeof (':')
+ + sizeof ('/')
+ + sizeof ('\0'); // For trailing '\0'.
+}
+
+ACE_INLINE void
+ACEXML_URL_Addr::operator= (const ACEXML_URL_Addr &addr)
+{
+ if (this->set (addr) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACEXML_URL_Addr::ACEXML_URL_Addr")));
+}
+
+ACE_INLINE u_long
+ACEXML_URL_Addr::hash (void) const
+{
+ u_long result = this->ACE_INET_Addr::hash ()
+ + ACE::hash_pjw (this->get_path_name ());
+ return result;
+}
+
+ACE_INLINE bool
+ACEXML_URL_Addr::operator== (const ACEXML_URL_Addr &addr) const
+{
+ return ACE_OS::strcmp (addr.get_path_name (), this->get_path_name ()) == 0
+ && addr.get_port_number () == this->get_port_number ()
+ && addr.get_ip_address () == this->get_ip_address ();
+}
+
+ACE_INLINE bool
+ACEXML_URL_Addr::operator!= (const ACEXML_URL_Addr &addr) const
+{
+ return !(*this == addr);
+}
+
+ACE_INLINE const ACEXML_Char *
+ACEXML_URL_Addr::get_path_name (void) const
+{
+ return this->path_name_;
+}
+
+ACE_INLINE int
+ACEXML_URL_Addr::destroy (void)
+{
+ // Commit suicide.
+ delete this;
+ return 0;
+}
diff --git a/ACE/ACEXML/common/Validator.cpp b/ACE/ACEXML/common/Validator.cpp
new file mode 100644
index 00000000000..cf3ce502200
--- /dev/null
+++ b/ACE/ACEXML/common/Validator.cpp
@@ -0,0 +1,8 @@
+// $Id$
+
+#include "ACEXML/common/Validator.h"
+
+ACEXML_Validator::~ACEXML_Validator ()
+{
+
+}
diff --git a/ACE/ACEXML/common/Validator.h b/ACE/ACEXML/common/Validator.h
new file mode 100644
index 00000000000..0d006396498
--- /dev/null
+++ b/ACE/ACEXML/common/Validator.h
@@ -0,0 +1,64 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Validator.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_VALIDATOR_H_
+#define _ACEXML_VALIDATOR_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/Attributes.h"
+#include "ACEXML/common/Env.h"
+#include "ACEXML/common/SAXExceptions.h"
+
+/**
+ * @class ACEXML_Validator Validator.h "common/Validator.h"
+ *
+ * @brief An abstract virtual class defining validator interface.
+ *
+ * An validator provides validation service for one XML element.
+ * ACEXML_Validators are stateful object. Implementations should
+ * remember the current element encountered and determine if
+ * it's a valid sequence of child elements. A parser fishes
+ * out a validator of certain
+ */
+class ACEXML_Export ACEXML_Validator
+{
+public:
+ virtual ~ACEXML_Validator () = 0;
+
+ /**
+ * Validate attributes of an element.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int startElement (ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Validate the next child element.
+ *
+ * @retval 0 if valid, -1 otherwise.
+ */
+ virtual int nextElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_VALIDATOR_H_ */
diff --git a/ACE/ACEXML/common/XMLFilter.h b/ACE/ACEXML/common/XMLFilter.h
new file mode 100644
index 00000000000..c012ee706e2
--- /dev/null
+++ b/ACE/ACEXML/common/XMLFilter.h
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file XMLFilter.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_XMLFILTER_H_
+#define _ACEXML_XMLFILTER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XMLReader.h"
+
+/**
+ * @class ACEXML_XMLFilter XMLFilter.h "ACEXML/common/XMLFilter.h"
+ *
+ * @brief ACEXML_XMLFilter
+ *
+ * An XML filter is like an XML reader, except that it obtains its events
+ * from another XML reader rather than a primary source like an XML
+ * document or database. Filters can modify a stream of events as they pass
+ * on to the final application.
+ *
+ * The XMLFilterImpl helper class provides a convenient base for creating
+ * SAX2 filters, by passing on all ACEXML_EntityResolver,
+ * ACEXML_DTDHandler, ACEXML_ContentHandler and ACEXML_ErrorHandler events
+ * automatically.
+ */
+class ACEXML_Export ACEXML_XMLFilter : public ACEXML_XMLReader
+{
+public:
+ /**
+ * Get the parent reader.
+ */
+ virtual ACEXML_XMLReader *getParent (void) const = 0;
+
+ /**
+ * Set the parent reader.
+ */
+ virtual void setParent (ACEXML_XMLReader *parent) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_XMLFILTER_H_ */
diff --git a/ACE/ACEXML/common/XMLFilterImpl.cpp b/ACE/ACEXML/common/XMLFilterImpl.cpp
new file mode 100644
index 00000000000..300c6b7ea4b
--- /dev/null
+++ b/ACE/ACEXML/common/XMLFilterImpl.cpp
@@ -0,0 +1,339 @@
+// -*- C++ -*- $Id$
+
+#include "ACEXML/common/XMLFilterImpl.h"
+
+#if !defined (__ACEXML_INLINE__)
+# include "ACEXML/common/XMLFilterImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+ACEXML_XMLFilterImpl::ACEXML_XMLFilterImpl (void)
+ : parent_ (0),
+ locator_ (0),
+ entityResolver_ (0),
+ dtdHandler_ (0),
+ contentHandler_ (0),
+ errorHandler_ (0)
+{
+}
+
+ACEXML_XMLFilterImpl::ACEXML_XMLFilterImpl (ACEXML_XMLReader *parent)
+ : parent_ (parent),
+ locator_ (0),
+ entityResolver_ (0),
+ dtdHandler_ (0),
+ contentHandler_ (0),
+ errorHandler_ (0)
+{
+}
+
+ACEXML_XMLFilterImpl::~ACEXML_XMLFilterImpl (void)
+{
+ // @@ How are all the object lifecycles managed?
+}
+
+void
+ACEXML_XMLFilterImpl::parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->setupParser () < 0)
+ {
+ ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("No Parent available")));
+ }
+ this->parent_->parse (input ACEXML_ENV_ARG_PARAMETER);
+ return;
+}
+
+void
+ACEXML_XMLFilterImpl::parse (const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->setupParser () < 0)
+ {
+ ACEXML_THROW (ACEXML_SAXException (ACE_TEXT ("No Parent available")));
+ }
+
+ this->parent_->parse (new ACEXML_InputSource (systemId) ACEXML_ENV_ARG_PARAMETER);
+ return;
+}
+
+int
+ACEXML_XMLFilterImpl::getFeature (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ if (this->parent_ != 0)
+ return this->parent_->getFeature (name ACEXML_ENV_ARG_PARAMETER);
+
+ ACEXML_THROW_RETURN (ACEXML_SAXNotRecognizedException (name), 0);
+}
+
+void *
+ACEXML_XMLFilterImpl::getProperty (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ if (this->parent_ != 0)
+ return this->parent_->getProperty (name ACEXML_ENV_ARG_PARAMETER);
+
+ ACEXML_THROW_RETURN (ACEXML_SAXNotRecognizedException (name), 0);
+}
+
+void
+ACEXML_XMLFilterImpl::setFeature (const ACEXML_Char *name,
+ int boolean_value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ if (this->parent_ != 0)
+ {
+ this->parent_->setFeature (name,
+ boolean_value ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+
+ ACEXML_THROW (ACEXML_SAXNotRecognizedException (name));
+}
+
+void
+ACEXML_XMLFilterImpl::setProperty (const ACEXML_Char *name,
+ void *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException))
+{
+ if (this->parent_ != 0)
+ {
+ this->parent_->setProperty (name,
+ value ACEXML_ENV_ARG_PARAMETER);
+ return;
+ }
+
+ ACEXML_THROW (ACEXML_SAXNotRecognizedException (name));
+}
+
+ACEXML_XMLReader *
+ACEXML_XMLFilterImpl::getParent (void) const
+{
+ return this->parent_;
+}
+
+void
+ACEXML_XMLFilterImpl::setParent (ACEXML_XMLReader *parent)
+{
+ this->parent_ = parent;
+}
+
+void
+ACEXML_XMLFilterImpl::characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->characters (ch, start, length ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->endDocument (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->endElement (namespaceURI,
+ localName,
+ qName ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->endPrefixMapping (prefix ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->ignorableWhitespace (ch,
+ start,
+ length ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->processingInstruction (target,
+ data ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::setDocumentLocator (ACEXML_Locator *locator)
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->setDocumentLocator (locator);
+}
+
+void
+ACEXML_XMLFilterImpl::skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->skippedEntity (name ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->startDocument (ACEXML_ENV_SINGLE_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->startElement (namespaceURI,
+ localName,
+ qName,
+ atts ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->contentHandler_ != 0)
+ this->contentHandler_->startPrefixMapping (prefix,
+ uri ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->dtdHandler_ != 0)
+ this->dtdHandler_->notationDecl (name,
+ publicId,
+ systemId ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->dtdHandler_ != 0)
+ this->dtdHandler_->unparsedEntityDecl (name,
+ publicId,
+ systemId,
+ notationName ACEXML_ENV_ARG_PARAMETER);
+}
+
+ACEXML_InputSource *
+ACEXML_XMLFilterImpl::resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->entityResolver_ != 0)
+ return this->entityResolver_->resolveEntity (publicId,
+ systemId ACEXML_ENV_ARG_PARAMETER);
+ return 0;
+}
+
+void
+ACEXML_XMLFilterImpl::error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->errorHandler_ != 0)
+ this->errorHandler_->error (exception ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->errorHandler_ != 0)
+ this->errorHandler_->fatalError (exception ACEXML_ENV_ARG_PARAMETER);
+}
+
+void
+ACEXML_XMLFilterImpl::warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException))
+{
+ if (this->errorHandler_ != 0)
+ this->errorHandler_->warning (exception ACEXML_ENV_ARG_PARAMETER);
+}
+
+ACEXML_DTDHandler *
+ACEXML_XMLFilterImpl::getDTDHandler (void) const
+{
+ return this->dtdHandler_;
+}
+
+ACEXML_ContentHandler *
+ACEXML_XMLFilterImpl::getContentHandler (void) const
+{
+ return this->contentHandler_;
+}
+
+ACEXML_EntityResolver *
+ACEXML_XMLFilterImpl::getEntityResolver (void) const
+{
+ return this->entityResolver_;
+}
+
+ACEXML_ErrorHandler *
+ACEXML_XMLFilterImpl::getErrorHandler (void) const
+{
+ return this->errorHandler_;
+}
+
+void
+ACEXML_XMLFilterImpl::setDTDHandler (ACEXML_DTDHandler *handler)
+{
+ this->dtdHandler_ = handler;
+}
+
+void
+ACEXML_XMLFilterImpl::setContentHandler (ACEXML_ContentHandler *handler)
+{
+ this->contentHandler_ = handler;
+}
+
+void
+ACEXML_XMLFilterImpl::setEntityResolver (ACEXML_EntityResolver *handler)
+{
+ this->entityResolver_ = handler;
+}
+
+void
+ACEXML_XMLFilterImpl::setErrorHandler (ACEXML_ErrorHandler *handler)
+{
+ this->errorHandler_ = handler;
+}
diff --git a/ACE/ACEXML/common/XMLFilterImpl.h b/ACE/ACEXML/common/XMLFilterImpl.h
new file mode 100644
index 00000000000..52963580636
--- /dev/null
+++ b/ACE/ACEXML/common/XMLFilterImpl.h
@@ -0,0 +1,294 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file XMLFilterImpl.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef ACEXML_XMLFILTERIMPL_H
+#define ACEXML_XMLFILTERIMPL_H
+#include /**/ "ace/pre.h"
+
+#include "ACEXML/common/XMLFilter.h"
+#include "ACEXML/common/XMLReader.h"
+#include "ACEXML/common/Locator.h"
+#include "ACEXML/common/ContentHandler.h"
+#include "ACEXML/common/DTDHandler.h"
+#include "ACEXML/common/EntityResolver.h"
+#include "ACEXML/common/ErrorHandler.h"
+
+/**
+ * @class ACEXML_XMLFilterImpl XMLFilterImpl.h "ACEXML/common/XMLFilterImpl.h"
+ *
+ * @brief ACEXML_XMLFilterImpl
+ *
+ * This class is designed to sit between an XMLReader and the client
+ * application's event handlers. By default, it does nothing but pass
+ * requests up to the reader and events on to the handlers unmodified, but
+ * subclasses can override specific methods to modify the event stream or
+ * the configuration requests as they pass through.
+ */
+class ACEXML_Export ACEXML_XMLFilterImpl
+ : public ACEXML_XMLFilter,
+ public ACEXML_ContentHandler,
+ public ACEXML_DTDHandler,
+ public ACEXML_EntityResolver,
+ public ACEXML_ErrorHandler
+{
+public:
+ /**
+ * Default constructor. Create with no parent.
+ */
+ ACEXML_XMLFilterImpl (void);
+
+ /**
+ * Construct an XML filter with the specified parent.
+ */
+ ACEXML_XMLFilterImpl (ACEXML_XMLReader *parent);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ACEXML_XMLFilterImpl (void);
+
+ /*
+ * Look up the value of a feature.
+ */
+ virtual int getFeature (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Look up the value of a property.
+ */
+ virtual void * getProperty (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Parse an XML document.
+ */
+ virtual void parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Parse an XML document from a system identifier (URI).
+ */
+ virtual void parse (const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ // @@ throw IOException???
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Set the state of a feature.
+ */
+ virtual void setFeature (const ACEXML_Char *name,
+ int boolean_value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Set the value of a property.
+ */
+ virtual void setProperty (const ACEXML_Char *name,
+ void *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) ;
+
+ /*
+ * Get the parent reader.
+ */
+ virtual ACEXML_XMLReader *getParent (void) const;
+
+ /*
+ * Set the parent reader.
+ */
+ virtual void setParent (ACEXML_XMLReader *parent);
+
+ /*
+ * Get the current DTD event handler.
+ */
+ virtual ACEXML_DTDHandler *getDTDHandler (void) const;
+
+ /*
+ * Get the current content event handler.
+ */
+ virtual ACEXML_ContentHandler *getContentHandler (void) const;
+
+ /*
+ * Get the current entity resolver.
+ */
+ virtual ACEXML_EntityResolver *getEntityResolver (void) const;
+
+ /*
+ * Get the current error event handler.
+ */
+ virtual ACEXML_ErrorHandler *getErrorHandler (void) const;
+
+ /*
+ * Set the DTD event handler.
+ */
+ virtual void setDTDHandler (ACEXML_DTDHandler *handler);
+
+ /*
+ * Set the content event handler.
+ */
+ virtual void setContentHandler (ACEXML_ContentHandler *handler);
+
+ /*
+ * Set the entity resolver.
+ */
+ virtual void setEntityResolver (ACEXML_EntityResolver *handler);
+
+ /*
+ * Set the error event handler.
+ */
+ virtual void setErrorHandler (ACEXML_ErrorHandler *handler);
+
+ /*
+ * Receive notification of character data.
+ */
+ virtual void characters (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the end of a document.
+ */
+ virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the end of an element.
+ */
+ virtual void endElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * End the scope of a prefix-URI mapping.
+ */
+ virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of ignorable whitespace in element content.
+ */
+ virtual void ignorableWhitespace (const ACEXML_Char *ch,
+ int start,
+ int length ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of a processing instruction.
+ */
+ virtual void processingInstruction (const ACEXML_Char *target,
+ const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive an object for locating the origin of SAX document events.
+ */
+ virtual void setDocumentLocator (ACEXML_Locator *locator) ;
+
+ /*
+ * Receive notification of a skipped entity.
+ */
+ virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the beginning of a document.
+ */
+ virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of the beginning of an element.
+ */
+ virtual void startElement (const ACEXML_Char *namespaceURI,
+ const ACEXML_Char *localName,
+ const ACEXML_Char *qName,
+ ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Begin the scope of a prefix-URI Namespace mapping.
+ */
+ virtual void startPrefixMapping (const ACEXML_Char *prefix,
+ const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // *** Methods inherit from ACEXML_DTDHandler.
+
+ /*
+ * Receive notification of a notation declaration event.
+ */
+ virtual void notationDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ /*
+ * Receive notification of an unparsed entity declaration event.
+ */
+ virtual void unparsedEntityDecl (const ACEXML_Char *name,
+ const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId,
+ const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // Methods inherit from ACEXML_EnitityResolver.
+
+ /*
+ * Allow the application to resolve external entities.
+ */
+ virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
+ const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) ;
+
+ // Methods inherit from ACEXML_ErrorHandler.
+
+ /*
+ * Receive notification of a recoverable error.
+ */
+ virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /*
+ * Receive notification of a non-recoverable error.
+ */
+ virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+
+ /*
+ * Receive notification of a warning.
+ */
+ virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException));
+protected:
+ int setupParser (void);
+ // Set up the event handlers of parent parser to this.
+ // Returns -1 if no valid parent is set.
+
+private:
+ ACEXML_XMLReader *parent_;
+ ACEXML_Locator *locator_;
+ ACEXML_EntityResolver *entityResolver_;
+ ACEXML_DTDHandler *dtdHandler_;
+ ACEXML_ContentHandler *contentHandler_;
+ ACEXML_ErrorHandler *errorHandler_;
+};
+
+#if defined (__ACEXML_INLINE__)
+# include "ACEXML/common/XMLFilterImpl.i"
+#endif /* __ACEXML_INLINE__ */
+
+#include /**/ "ace/post.h"
+
+#endif /* ACEXML_XMLFILTERIMPL_H */
diff --git a/ACE/ACEXML/common/XMLFilterImpl.i b/ACE/ACEXML/common/XMLFilterImpl.i
new file mode 100644
index 00000000000..4be2ceeceea
--- /dev/null
+++ b/ACE/ACEXML/common/XMLFilterImpl.i
@@ -0,0 +1,14 @@
+// -*- C++ -*- $Id$
+
+ACEXML_INLINE int
+ACEXML_XMLFilterImpl::setupParser (void)
+{
+ if (this->parent_ == 0)
+ return -1;
+
+ this->parent_->setEntityResolver (this);
+ this->parent_->setDTDHandler (this);
+ this->parent_->setContentHandler (this);
+ this->parent_->setErrorHandler (this);
+ return 0;
+}
diff --git a/ACE/ACEXML/common/XMLReader.cpp b/ACE/ACEXML/common/XMLReader.cpp
new file mode 100644
index 00000000000..d762c79a3a2
--- /dev/null
+++ b/ACE/ACEXML/common/XMLReader.cpp
@@ -0,0 +1,11 @@
+#include "XMLReader.h"
+
+
+ACE_RCSID (common,
+ XMLReader,
+ "$Id$")
+
+
+ACEXML_XMLReader::~ACEXML_XMLReader (void)
+{
+}
diff --git a/ACE/ACEXML/common/XMLReader.h b/ACE/ACEXML/common/XMLReader.h
new file mode 100644
index 00000000000..c95024d3dd4
--- /dev/null
+++ b/ACE/ACEXML/common/XMLReader.h
@@ -0,0 +1,136 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file XMLReader.h
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+#ifndef _ACEXML_XMLREADER_H_
+#define _ACEXML_XMLREADER_H_
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/ContentHandler.h"
+#include "ACEXML/common/DTDHandler.h"
+#include "ACEXML/common/EntityResolver.h"
+#include "ACEXML/common/ErrorHandler.h"
+
+/**
+ * @class ACEXML_XMLReader XMLReader.h "ACEXML/common/XMLReader.h"
+ *
+ * @brief ACEXML_XMLReader
+ *
+ * XMLReader is the interface that an XML parser's SAX2 driver must
+ * implement. This interface allows an application to set and query
+ * features and properties in the parser, to register event handlers
+ * for document processing, and to initiate a document parse.
+ *
+ * All SAX interfaces are assumed to be synchronous: the parse methods
+ * must not return until parsing is complete, and readers must wait
+ * for an event-handler callback to return before reporting the next
+ * event.
+ */
+class ACEXML_Export ACEXML_XMLReader
+{
+public:
+
+ virtual ~ACEXML_XMLReader (void);
+
+ /**
+ * Return the current content handler.
+ */
+ virtual ACEXML_ContentHandler *getContentHandler (void) const = 0;
+
+ /**
+ * Return the current DTD handler.
+ */
+ virtual ACEXML_DTDHandler *getDTDHandler (void) const = 0;
+
+ /**
+ * Return the current entity resolver.
+ */
+ virtual ACEXML_EntityResolver *getEntityResolver (void) const = 0;
+
+ /**
+ * Return the current error handler.
+ */
+ virtual ACEXML_ErrorHandler *getErrorHandler (void) const = 0;
+
+ /**
+ * Look up the value of a feature. This method allows
+ * programmers to check whether a specific feature has been
+ * activated in the parser.
+ */
+ virtual int getFeature (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) = 0;
+
+ /**
+ * Look up the value of a property.
+ */
+ virtual void * getProperty (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) = 0;
+
+ /**
+ * Parse an XML document.
+ */
+ virtual void parse (ACEXML_InputSource *input ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Parse an XML document from a system identifier (URI).
+ */
+ virtual void parse (const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXException)) = 0;
+
+ /**
+ * Allow an application to register a content event handler.
+ */
+ virtual void setContentHandler (ACEXML_ContentHandler *handler) = 0;
+
+ /**
+ * Allow an application to register a DTD event handler.
+ */
+ virtual void setDTDHandler (ACEXML_DTDHandler *handler) = 0;
+
+ /**
+ * Allow an application to register an entity resolver.
+ */
+ virtual void setEntityResolver (ACEXML_EntityResolver *resolver) = 0;
+
+ /**
+ * Allow an application to register an error event handler.
+ */
+ virtual void setErrorHandler (ACEXML_ErrorHandler *handler) = 0;
+
+ /**
+ * Activating or deactivating a feature.
+ */
+ virtual void setFeature (const ACEXML_Char *name,
+ int boolean_value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) = 0;
+
+ /**
+ * Set the value of a property.
+ */
+ virtual void setProperty (const ACEXML_Char *name,
+ void *value ACEXML_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((ACEXML_SAXNotRecognizedException,
+ ACEXML_SAXNotSupportedException)) = 0;
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_XMLREADER_H_ */
diff --git a/ACE/ACEXML/common/XML_Codecs.cpp b/ACE/ACEXML/common/XML_Codecs.cpp
new file mode 100644
index 00000000000..9566158ddfd
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Codecs.cpp
@@ -0,0 +1,94 @@
+// -*- C++ -*- $Id$
+
+#include "ace/Auto_Ptr.h"
+#include "ace/OS_Memory.h"
+#include "ace/OS_NS_string.h"
+#include "ACEXML/common/XML_Codecs.h"
+
+ACE_RCSID (common, XML_Codecs, "$Id$")
+
+ACEXML_Char*
+ACEXML_Base64::encode (const ACEXML_Char* input,
+ size_t* output_len)
+{
+ if (!input)
+ return 0;
+ size_t len = ACE_OS::strlen (input);
+
+ ACE_Byte* buf = 0;
+ ACE_NEW_RETURN (buf,
+ ACE_Byte[len],
+ 0);
+ ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup_buf (buf);
+
+ for (size_t i = 0; i < len; ++i)
+ buf[i] = (ACE_Byte)input[i];
+ buf[len] = 0;
+
+ size_t encode_len = 0;
+ ACE_Byte* encodedBuf = ACE_Base64::encode (buf, len, &encode_len);
+
+ if (!encodedBuf)
+ return 0;
+
+ ACEXML_Char* result = 0;
+ ACE_NEW_RETURN (result,
+ ACEXML_Char[encode_len+1],
+ 0);
+
+ for (size_t j = 0; j < encode_len; ++j)
+ result[j] = (ACEXML_Char)encodedBuf[j];
+ result[encode_len] = 0;
+
+ *output_len = encode_len;
+ delete[] encodedBuf;
+ return result;
+}
+
+
+ACEXML_Char*
+ACEXML_Base64::decode (const ACEXML_Char* input,
+ size_t* output_len)
+{
+ if (!input)
+ return 0;
+
+ size_t len = ACE_OS::strlen (input);
+
+ ACE_Byte* buf = 0;
+
+ ACE_NEW_RETURN (buf,
+ ACE_Byte[len],
+ 0);
+
+ ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup (buf);
+
+ for (size_t i = 0; i < len; ++i)
+ buf[i] = (ACE_Byte)input[i];
+
+ buf[len] = 0;
+
+ size_t decode_len = 0;
+
+ ACE_Byte* decodedBuf = ACE_Base64::decode (buf, &decode_len);
+
+ if (!decodedBuf)
+ return 0;
+
+ ACEXML_Char* result = 0;
+
+ ACE_NEW_RETURN (result,
+ ACEXML_Char[decode_len+1],
+ 0);
+
+ for (size_t j = 0; j < decode_len; ++j)
+ result[j] = (ACEXML_Char)decodedBuf[j];
+
+ result[decode_len] = 0;
+
+ *output_len = decode_len;
+ delete[] decodedBuf;
+
+ return result;
+}
+
diff --git a/ACE/ACEXML/common/XML_Codecs.h b/ACE/ACEXML/common/XML_Codecs.h
new file mode 100644
index 00000000000..10101d4e5b4
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Codecs.h
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+
+/**
+ * @file XML_Codecs.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ *
+ * XML_Codecs is a generic wrapper for various encoding and decoding
+ * mechanisms used in ACEXML. Currently it includes support for handling
+ * Base64 content transfer-encoding of ACEXML_Chars.
+ *
+ */
+
+#ifndef _ACEXML_XML_CODECS_H
+#define _ACEXML_XML_CODECS_H
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+#include "ace/Codecs.h"
+
+/**
+ * @class ACEXML_Base64
+ *
+ * @brief Encode/Decode a stream of ACEXML_Chars according to Base64 encoding.
+ *
+ * This class provides methods to encode or decode a stream of ACEXML_Chars
+ * to/from Base64 encoding. It doesn't convert the input stream to a
+ * canonical form before encoding.
+ *
+ */
+class ACEXML_Export ACEXML_Base64 : public ACE_Base64
+{
+public:
+
+ //@{
+
+ /**
+ * Encodes a stream of octets to Base64 data
+ *
+ * @param input Binary data in ACEXML_Char stream.
+ * @param output_len Length of the encoded Base64 ACEXML_Char stream.
+ * @return Encoded Base64 data in ACEXML_Char stream or NULL if input data
+ * cannot be encoded.
+ */
+
+ static ACEXML_Char* encode (const ACEXML_Char* input,
+ size_t* output_len);
+ /**
+ * Decodes a stream of Base64 to octets data
+ *
+ * @param input Encoded Base64 data in ACEXML_Char stream.
+ * @param output_len Length of the binary ACEXML_Char stream.
+ * @return Binary data in ACEXML_Char stream or NULL if input data cannot
+ * be encoded.
+ */
+ static ACEXML_Char* decode (const ACEXML_Char* input,
+ size_t* output_len);
+
+ //@}
+};
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_XML_CODECS_H */
diff --git a/ACE/ACEXML/common/XML_Macros.h b/ACE/ACEXML/common/XML_Macros.h
new file mode 100644
index 00000000000..50ec6857b3a
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Macros.h
@@ -0,0 +1,443 @@
+// -*- C++ -*-
+
+// ============================================================================
+/**
+ * @file XML_Macros.h
+ *
+ * $Id$
+ *
+ * Writing code that is portable between platforms with or without
+ * native C++ exceptions is hard. The following macros offer some
+ * help on this task.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ * @author Aniruddha Gokhale <gokhale@sahyadri.research.bell-labs.com>
+ * @author Carlos O'Ryan <coryan@uci.edu>
+ * @author Krishnakumar B <kitty@cs.wustl.edu>, et al.
+ */
+// ============================================================================
+
+// Macros for handling exceptions.
+
+#ifndef _ACEXML_MACROS_H
+#define _ACEXML_MACROS_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/config-all.h"
+
+# if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+# endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Exception_Macros.h"
+
+// The following macros assume that an environment variable is passed
+// in/out of each function that can throw an exception. The type of the
+// environment variable is defined by ACEXML_ENV_TYPE.
+
+#if !defined (ACEXML_ENV_TYPE)
+# define ACEXML_ENV_TYPE ACEXML_Env
+#endif /* ACEXML_ENV_TYPE */
+
+// The name of the variable defined by ACEXML_TRY_ENV. Below is the name
+// that we use by default. If you wish to change it you can redefine
+// ACEXML_TRY_ENV to change the default name. Also ACEXML_ADOPT_ENV allows the
+// use of non-standard name within a scope.
+
+#if !defined (ACEXML_TRY_ENV)
+# define ACEXML_TRY_ENV _ACEXML_Env_variable
+#endif /* ACEXML_TRY_ENV */
+
+// The base type of Exception from which all the other exception types are
+// derived. By default, it is set to ACEXML_Exception.
+
+#if !defined (ACEXML_EXCEPTION_TYPE)
+# define ACEXML_EXCEPTION_TYPE ACEXML_Exception
+#endif /* ACEXML_EXCEPTION_TYPE */
+
+// This is the exception caught by ACEXML_CATCHANY.
+#if !defined (ACEXML_ANY_EXCEPTION)
+# define ACEXML_ANY_EXCEPTION ex
+#endif /* ACEXML_ANY_EXCEPTION */
+
+// Declare a new environment variable on the stack. The type of the
+// environment variable is determined by ACEXML_ENV_TYPE.
+#define ACEXML_DECLARE_NEW_ENV \
+ ACEXML_ENV_TYPE ACEXML_TRY_ENV
+
+#if defined (ACE_USES_NATIVE_EXCEPTIONS)
+// -----------------------------------------------------------------
+
+#define ACEXML_ADOPT_ENV (ENV)
+
+// No need to check. Native exceptions handle the control flow
+// automatically when an exception occurs.
+# define ACEXML_CHECK
+
+// Used when the function requires a return value.
+# define ACEXML_CHECK_RETURN(RETV)
+
+// ACEXML_THROW_R_INT should not be used by the user.
+# define ACEXML_THROW_R_INT(EXCEPTION) \
+ throw EXCEPTION
+
+// Throwing an exception is easy. These two macros should _NOT_ be
+// used within try blocks.
+# define ACEXML_THROW(EXCEPTION) \
+ throw EXCEPTION
+
+// Throwing an exception when the function reqires a return value.
+# if defined (__HP_aCC)
+# define ACEXML_THROW_RETURN(EXCEPTION, RETV) \
+ do \
+ { \
+ throw EXCEPTION; \
+ return RETV; \
+ } while (0)
+# else /* WIN32 */
+# define ACEXML_THROW_RETURN(EXCEPTION,RETV) \
+ throw EXCEPTION
+# endif /* WIN32 */
+
+// For compilers with native exceptions, we can simply use try to try. ;-)
+// do {} while (0) is required to avoid compilation warnings.
+# define ACEXML_TRY \
+ do \
+ { \
+ try \
+ {
+# define ACEXML_TRY_NEW_ENV \
+ do \
+ { \
+ ACEXML_ENV_TYPE ACEXML_TRY_ENV; \
+ try \
+ {
+# define ACEXML_TRY_EX(LABEL) \
+ do \
+ { \
+ try \
+ {
+
+// No need to check for exceptions within try block for compilers with
+// native exceptions.
+# define ACEXML_TRY_CHECK
+# define ACEXML_TRY_CHECK_EX(LABEL)
+
+// Likewise, throwing exceptions within try blocks is easy.
+# define ACEXML_TRY_THROW(EXCEPTION) throw EXCEPTION
+# define ACEXML_TRY_THROW_EX(EXCEPTION,LABEL) throw EXCEPTION
+
+// Same thing for catch.
+# define ACEXML_CATCH(EXCEPTION,VAR) \
+ } \
+ catch (EXCEPTION & VAR) \
+ { \
+ ACE_UNUSED_ARG (VAR);
+
+# define ACEXML_CATCHANY \
+ ACEXML_CATCH(ACEXML_EXCEPTION_TYPE, ACEXML_ANY_EXCEPTION)
+
+# define ACEXML_CATCHALL \
+ } \
+ catch (...) \
+ {
+
+// Rethrowing the exception from catch blocks.
+# define ACEXML_RE_THROW throw
+# define ACEXML_RE_THROW_EX(LABEL) throw
+
+// Close the catch block.
+# define ACEXML_ENDTRY \
+ } \
+ } while (0)
+
+#else /* ! ACEXML_USES_NATIVE_EXCEPTIONS */
+// -----------------------------------------------------------------
+
+// When handling compilers without native exceptions, things get a bit
+// hairy. Exceptions are simulated using ACEXML_ENV_TYPE. The trick here is to
+// make sure the flow-of-control can simulate the case when native
+// exceptions occur...
+
+# define ACEXML_ADOPT_ENV(ENV) ACEXML_ENV_TYPE &ACEXML_TRY_ENV = ENV
+
+// Follow every statement that could throw exceptions with ACEXML_CHECK or
+// ACEXML_CHECK_RETURN. These two macros should _NOT_ be used within try
+// blocks. Use ACEXML_TRY_CHECK or ACEXML_TRY_CHECK_EX instead.
+# define ACEXML_CHECK \
+ if (ACEXML_TRY_ENV . exception () != 0) \
+ return
+// When function requires a return value
+# define ACEXML_CHECK_RETURN(RETV) \
+ if (ACEXML_TRY_ENV . exception () != 0) \
+ return RETV
+
+// ACEXML_THROW_R_INT should not be used by the user.
+# define ACEXML_THROW_R_INT(EXCEPTION) ACEXML_TRY_ENV.exception (new EXCEPTION)
+
+// Throwing exceptions will inevitably cause a return from the current
+// function. These two macros should _NOT_ be used within try blocks. Use
+// ACEXML_TRY_THROW or ACEXML_TRY_THROW_EX instead.
+# define ACEXML_THROW(EXCEPTION) \
+ do \
+ { \
+ ACEXML_TRY_ENV.exception (new EXCEPTION); \
+ return; \
+ } while (0)
+
+# define ACEXML_THROW_RETURN(EXCEPTION,RETV) \
+ do \
+ { \
+ ACEXML_TRY_ENV.exception (new EXCEPTION); \
+ return RETV; \
+ } while (0)
+
+// ACEXML_TRY sets up flags to control program flow. ACEXML_TRY_FLAG acts
+// like a one-shot flip-flop. When an exception occurs (detected using
+// ACEXML_TRY_CHECK,) ACEXML_TRY_FLAG will be reset and the control goes
+// back into ACEXML_TRY_LABEL. Since ACEXML_TRY_FLAG is reset, the try
+// block won't get executed again and the control proceeds to the following
+// catch blocks. ACEXML_EXCEPTION_NOT_CAUGHT flag is used to prevent
+// catching an exception twice. This macro assumes there's already an
+// ACEXML_ENV_TYPE variable ACEXML_TRY_ENV defined (which should be the
+// case normally)
+# define ACEXML_TRY \
+ do { \
+ int ACEXML_TRY_FLAG = 1; \
+ int ACEXML_EXCEPTION_NOT_CAUGHT = 1; \
+ ACEXML_TRY_LABEL: \
+ if (ACEXML_TRY_FLAG) \
+ do {
+
+// ACEXML_TRY_NEW_ENV functions like the macro ACEXML_TRY but defines a new
+// ACEXML_ENV_TYPE variable ACEXML_TRY_ENV. It is most often used in the outer
+// most function where no ACEXML_TRY_ENV is available.
+# define ACEXML_TRY_NEW_ENV \
+ do { \
+ ACEXML_ENV_TYPE ACEXML_TRY_ENV;\
+ int ACEXML_TRY_FLAG = 1; \
+ int ACEXML_EXCEPTION_NOT_CAUGHT = 1; \
+ ACEXML_TRY_LABEL: \
+ if (ACEXML_TRY_FLAG) \
+ do {
+
+// ACEXML_TRY_EX works exactly like ACEXML_TRY macro except the label used
+// in the try block is customizable to avoid name clashing. It should be
+// used when nested try blocks or multiple try blocks are required, in the
+// same function.
+# define ACEXML_TRY_EX(LABEL) \
+ do { \
+ int ACEXML_TRY_FLAG = 1; \
+ int ACEXML_EXCEPTION_NOT_CAUGHT = 1; \
+ ACEXML_TRY_LABEL ## LABEL: \
+ if (ACEXML_TRY_FLAG) \
+ do {
+
+// Check for exceptions within try blocks.
+# define ACEXML_TRY_CHECK \
+ { \
+ if (ACEXML_TRY_ENV.exception () != 0) \
+ { \
+ ACEXML_TRY_FLAG = 0; \
+ goto ACEXML_TRY_LABEL; \
+ } \
+ }
+
+// Checking exception within EX try blocks.
+# define ACEXML_TRY_CHECK_EX(LABEL) \
+ { \
+ if (ACEXML_TRY_ENV.exception () != 0) \
+ { \
+ ACEXML_TRY_FLAG = 0; \
+ goto ACEXML_TRY_LABEL ## LABEL; \
+ } \
+ }
+
+// Throwing exception within TRY blocks.
+# define ACEXML_TRY_THROW(EXCEPTION) \
+ { \
+ ACEXML_TRY_ENV.exception (new EXCEPTION); \
+ ACEXML_TRY_FLAG = 0; \
+ goto ACEXML_TRY_LABEL; \
+ }
+
+# define ACEXML_TRY_THROW_EX(EXCEPTION,LABEL) \
+ { \
+ ACEXML_TRY_ENV.exception (new EXCEPTION); \
+ ACEXML_TRY_FLAG = 0; \
+ goto ACEXML_TRY_LABEL ## LABEL; \
+ }
+
+// When exceptions occur or try block finishes execution without exception,
+// control will continue in the catch block. This macro first checks if
+// there's any uncaught exception left. If all the conditions are met, we
+// have caught an exception. It then resets ACEXML_EXCEPTION_NOT_CAUGHT to
+// prevent subsequent catch blocks from catching the same exception again,
+// and extracts out the underlying exception in ACEXML_TRY_ENV. We also make a
+// copy of ACEXML_TRY_ENV in ACEXML_CAUGHT_ENV, in case we want to rethrow the
+// exception. ACEXML_TRY_ENV is cleared out after the exception is caught so
+// you should not use ACEXML_TRY_ENV within the catch block(You should use the
+// exception directly).
+# define ACEXML_CATCH(TYPE,VAR) \
+ } while (0); \
+ do \
+ if (ACEXML_TRY_ENV.exception () != 0 && ACEXML_EXCEPTION_NOT_CAUGHT && \
+ TYPE::_downcast(ACEXML_TRY_ENV.exception ()) != 0) \
+ { \
+ ACEXML_ENV_TYPE ACEXML_CAUGHT_ENV = ACEXML_TRY_ENV;\
+ ACEXML_EXCEPTION_NOT_CAUGHT = 0; \
+ TYPE &VAR = *TYPE::_downcast (ACEXML_CAUGHT_ENV.exception ()); \
+ ACE_UNUSED_ARG (VAR); \
+ ACEXML_TRY_ENV.clear ();
+
+// ACEXML_CATCHANY uses ACEXML_CATCH to catch all exceptions derived from
+// ACEXML_EXCEPTION_TYPE
+# define ACEXML_CATCHANY ACEXML_CATCH (ACEXML_EXCEPTION_TYPE, ACEXML_ANY_EXCEPTION)
+
+// Since there's no other exception for compilers without exception
+// support, we simply catch all ACEXML_EXCEPTION_TYPE exceptions for
+// ACEXML_CATCHALL.
+# define ACEXML_CATCHALL ACEXML_CATCHANY
+
+// Rethrowing exception within catch blocks. Notice that we depend on the
+// ACEXML_CHECK/ACEXML_CHECK_RETURN following the ACEXML_ENDTRY, or
+// ACEXML_TRY_CHECK/ ACEXML_TRY_CHECK_EX following the ACEXML_ENDTRY when
+// the catch block is within another try block, to do the "Right
+// Thing[TM]."
+# define ACEXML_RE_THROW \
+ do {\
+ ACEXML_TRY_ENV = ACEXML_CAUGHT_ENV; \
+ goto ACEXML_TRY_LABEL; \
+ } while (0)
+# define ACEXML_RE_THROW_EX(LABEL) \
+ do {\
+ ACEXML_TRY_ENV = ACEXML_CAUGHT_ENV; \
+ goto ACEXML_TRY_LABEL ## LABEL; \
+ } while (0)
+
+// Close the try block. Since exceptions may not get caught, and exceptions
+// can also be rethrown from the catch block, it's always a good idea to
+// follow ACEXML_ENDTRY with ACEXML_CHECK or ACEXML_TRY_CHECK (depending on
+// the context.)
+# define ACEXML_ENDTRY \
+ } while (0); \
+ } while (0)
+
+#endif /* ! ACE_USES_NATIVE_EXCEPTIONS */
+
+// ACE_HAS_EXCEPTIONS is not the same as ACE_NEW_THROWS_EXCEPTIONS.
+#if defined(ACE_NEW_THROWS_EXCEPTIONS)
+
+# define ACEXML_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \
+ do { try { POINTER = new CONSTRUCTOR; } \
+ catch (ACE_bad_alloc) { errno = ENOMEM; ACEXML_THROW_R_INT (EXCEPTION); } \
+ } while (0)
+
+#else /* ! ACE_NEW_THROWS_EXCEPTIONS */
+
+# define ACEXML_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \
+ do { POINTER = new CONSTRUCTOR; \
+ if (POINTER == 0) { errno = ENOMEM; ACEXML_THROW_R_INT (EXCEPTION); } \
+ } while (0)
+
+#endif /* ACE_NEW_THROWS_EXCEPTIONS */
+
+# define ACEXML_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \
+ ACE_Guard< MUTEX > OBJ (LOCK); \
+ if (OBJ.locked () == 0) ACEXML_THROW_R_INT (EXCEPTION);
+
+# define ACEXML_READ_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \
+ ACE_Read_Guard< MUTEX > OBJ (LOCK); \
+ if (OBJ.locked () == 0) ACEXML_THROW_R_INT (EXCEPTION);
+
+# define ACEXML_WRITE_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \
+ ACE_Write_Guard< MUTEX > OBJ (LOCK); \
+ if (OBJ.locked () == 0) ACEXML_THROW_R_INT (EXCEPTION);
+
+//@{
+/**
+ * @name Native C++ exceptions portability macros.
+ *
+ * The following macros are used to write code portable between platforms
+ * with and without native C++ exception support. Their main goal is to
+ * hide the presence of the ACEXML_ENV_TYPE argument, but they collaborate
+ * with the ACEXML_TRY_* macros to emulate the try/catch blocks.
+ */
+
+/// Define a macro to emit code only when ACEXML_ENV_TYPE is used
+#if !defined (ACE_USES_NATIVE_EXCEPTIONS) || defined (ACEXML_ENV_BKWD_COMPAT)
+# define ACEXML_ENV_EMIT_CODE(X) X
+#else
+# define ACEXML_ENV_EMIT_CODE(X)
+#endif /* ACE_USES_NATIVE_EXCEPTIONS && ! ACEXML_ENV_BKWD_COMPAT */
+
+/// Another macro to emit code only when ACEXML_ENV_TYPE is used
+#if !defined (ACE_USES_NATIVE_EXCEPTIONS) || defined (ACEXML_ENV_BKWD_COMPAT)
+# define ACEXML_ENV_EMIT_CODE2(X,Y) X,Y
+#else
+# define ACEXML_ENV_EMIT_CODE2(X,Y)
+#endif /* ACE_USES_NATIVE_EXCEPTIONS && ! ACEXML_ENV_BKWD_COMPAT */
+
+/// Helper macro
+#define ACEXML_ENV_EMIT_DUMMY
+
+/// Declare a ACEXML_ENV_TYPE argument as the last argument of a
+/// function
+/**
+ * Normally this macro is used as follows:
+ *
+ * <CODE>void my_funct (int x, int y ACEXML_ENV_ARG_DECL);</CODE>
+ *
+ * Its purpose is to provide developers (and users) with a mechanism to
+ * write code that is portable to platforms with and without native C++
+ * exceptions.
+ */
+#define ACEXML_ENV_ARG_DECL \
+ ACEXML_ENV_EMIT_CODE2(ACEXML_ENV_EMIT_DUMMY, \
+ ACEXML_ENV_TYPE &ACEXML_TRY_ENV)
+
+/// Declare a ACEXML_ENV_TYPE argument that is not used by the
+/// function definition.
+/**
+ * Similar to ACEXML_ENV_ARG_DECL, but the formal parameter name is dropped to
+ * avoid warnings about unused parameters
+ */
+#define ACEXML_ENV_ARG_DECL_NOT_USED \
+ ACEXML_ENV_EMIT_CODE2(ACEXML_ENV_EMIT_DUMMY, \
+ ACEXML_ENV_TYPE &)
+
+/// Declare a ACEXML_ENV_TYPE argument for methods that do not take any other
+/// parameters
+#define ACEXML_ENV_SINGLE_ARG_DECL \
+ ACEXML_ENV_EMIT_CODE(ACEXML_ENV_TYPE &ACEXML_TRY_ENV)
+
+/// Declare a ACEXML_ENV_TYPE argument for methods which don't use it.
+#define ACEXML_ENV_SINGLE_ARG_DECL_NOT_USED \
+ ACEXML_ENV_EMIT_CODE(ACEXML_ENV_TYPE &)
+
+/// Use the ACEXML_ENV_TYPE argument in a nested call
+#define ACEXML_ENV_ARG_PARAMETER \
+ ACEXML_ENV_EMIT_CODE2(ACEXML_ENV_EMIT_DUMMY, \
+ ACEXML_TRY_ENV)
+
+/// Use the ACEXML_ENV_TYPE argument in a nested call, assuming that the
+/// called function takes only the ACEXML_TRY_ENV argument.
+#define ACEXML_ENV_SINGLE_ARG_PARAMETER \
+ ACEXML_ENV_EMIT_CODE(ACEXML_TRY_ENV)
+
+/// Eliminate unused argument warnings about ACEXML_TRY_ENV
+#define ACEXML_ENV_ARG_NOT_USED \
+ ACEXML_ENV_EMIT_CODE(ACE_UNUSED_ARG(ACEXML_TRY_ENV))
+//@}
+
+#if !defined (ACE_USES_NATIVE_EXCEPTIONS)
+// This thing can be moved above when we drop ACEXML_ENV_BKWD_COMPAT.
+# define ACEXML_ENV_RAISE(ex) ACEXML_TRY_ENV.exception (ex)
+#else
+# define ACEXML_ENV_RAISE(ex) (ex)->_raise ()
+#endif /* ACEXML_CORBA_HAS_EXCEPTIONS */
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_MACROS_H */
diff --git a/ACE/ACEXML/common/XML_Types.h b/ACE/ACEXML/common/XML_Types.h
new file mode 100644
index 00000000000..5a55d6b7754
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Types.h
@@ -0,0 +1,83 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file XML_Types.h
+ *
+ * This file collects the type definitions for data types
+ * used in ACE XML parser.
+ *
+ * $Id$
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_XML_TYPES_H_
+#define _ACEXML_XML_TYPES_H_
+
+#include /**/ "ace/pre.h"
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Basic_Types.h"
+#include "ace/SString.h"
+#include "ace/Functor_String.h"
+
+# if defined (ACE_HAS_WCHAR) && (ACE_SIZEOF_WCHAR == 2)
+typedef wchar_t ACEXML_UTF16;
+# else
+typedef ACE_USHORT16 ACEXML_UTF16;
+# endif /* ACE_HAS_WCHAR && ACE_SIZEOF_WCHAR == 2 */
+
+# if defined (ACE_HAS_WCHAR) && (ACE_SIZEOF_WCHAR == 4)
+typedef wchar_t ACEXML_UCS4;
+# else
+typedef ACE_UINT32 ACEXML_UCS4;
+# endif /* ACE_HAS_WCHAR && ACE_SIZEOF_WCHAR == 4 */
+
+typedef char ACEXML_UTF8;
+
+/**
+ * @typedef ACEXML_Char
+ * ACEXML_Char only maps to ACEXML_UTF16 when ACE_USES_WCHAR is defined.
+ * Here we assume sizeof (wchar_t) is always 2 bytes.
+ *
+ * Default XML strings will use UTF-8 encoding. We would like to use
+ * the string classes in standard C++ Library here. But they are not
+ * very portable yet (as far as I know,) and I'll just use ACE_CString
+ * for now, unless UNICODE support is turned on. Notice that you
+ * should never convert strings between ACE_CString and ACE_WString
+ * using the built-in conversion functions as they only perform simple
+ * copy without any encoding conversion.
+ */
+typedef ACE_TCHAR ACEXML_Char;
+# if defined (ACE_USES_WCHAR)
+//typedef ACEXML_UTF16 ACEXML_Char;
+typedef ACE_WString ACEXML_String;
+# else
+//typedef ACEXML_UTF8 ACEXML_Char;
+typedef ACE_CString ACEXML_String;
+# endif /* ACE_USES_WCHAR */
+
+# if (!defined (ACEXML_HAS_INLINE) && defined (__ACE_INLINE__)) || (ACEXML_HAS_INLINE == 1)
+# define __ACEXML_INLINE__ inline
+# else
+# if defined (__ACEXML_INLINE__)
+# undef __ACEXML_INLINE__
+# endif /* __ACEXML_INLINE__ */
+# endif /* (!ACEXML_HAS_INLINE) && (__ACE_INLINE__) || (ACEXML_HAS_INLINE == 1) */
+
+# if defined (__ACEXML_INLINE__)
+# define ACEXML_INLINE inline
+# else
+# define ACEXML_INLINE
+# endif /* __ACEXML_INLINE */
+
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_XML_TYPE_H_ */
diff --git a/ACE/ACEXML/common/XML_Util.cpp b/ACE/ACEXML/common/XML_Util.cpp
new file mode 100644
index 00000000000..7b9b9fb00fe
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Util.cpp
@@ -0,0 +1,46 @@
+// $Id$
+
+#include "ACEXML/common/XML_Util.h"
+
+static const ACEXML_Char ESCAPED_AMP[] = ACE_TEXT("&amp;");
+static const ACEXML_Char ESCAPED_LESS[] = ACE_TEXT("&lt;");
+static const ACEXML_Char ESCAPED_GREATER[] = ACE_TEXT("&gt;");
+static const ACEXML_Char ESCAPED_APOS[] = ACE_TEXT("&apos;");
+static const ACEXML_Char ESCAPED_QUOTE[] = ACE_TEXT("&quot;");
+
+#define CSTRLEN(x) ((sizeof(x) / sizeof(ACEXML_Char)) - 1)
+
+ACEXML_String ACEXML_escape_string(const ACEXML_String& str)
+{
+ ACEXML_String ret(str.length ());
+ ACEXML_escape_string(str, ret);
+ return ret;
+}
+
+void ACEXML_escape_string(const ACEXML_String& in, ACEXML_String& out)
+{
+ size_t len = in.length ();
+ out.clear();
+ for (size_t stridx = 0; stridx < len; ++stridx)
+ {
+ switch (in[stridx]) {
+ case '&':
+ out.append(ESCAPED_AMP, CSTRLEN(ESCAPED_AMP));
+ break;
+ case '<':
+ out.append(ESCAPED_LESS, CSTRLEN(ESCAPED_LESS));
+ break;
+ case '>':
+ out.append(ESCAPED_GREATER, CSTRLEN(ESCAPED_GREATER));
+ break;
+ case '\'':
+ out.append(ESCAPED_APOS, CSTRLEN(ESCAPED_APOS));
+ break;
+ case '\"':
+ out.append(ESCAPED_QUOTE, CSTRLEN(ESCAPED_QUOTE));
+ break;
+ default:
+ out += in[stridx];
+ }
+ }
+}
diff --git a/ACE/ACEXML/common/XML_Util.h b/ACE/ACEXML/common/XML_Util.h
new file mode 100644
index 00000000000..2844c33f397
--- /dev/null
+++ b/ACE/ACEXML/common/XML_Util.h
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file XML_Util.h
+ *
+ * Initially contains a function to escape strings for use in XML files.
+ *
+ * $Id$
+ *
+ * @author Justin Michel <michel_j@ociweb.com>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_XML_UTIL_H_
+#define _ACEXML_XML_UTIL_H_
+
+#include /**/ "ace/pre.h"
+
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/XML_Types.h"
+
+ACEXML_Export ACEXML_String ACEXML_escape_string(const ACEXML_String& str);
+ACEXML_Export void ACEXML_escape_string(const ACEXML_String& in, ACEXML_String& out);
+
+#include /**/ "ace/post.h"
+
+#endif /* _ACEXML_XML_UTIL_H_ */
diff --git a/ACE/ACEXML/common/ZipCharStream.cpp b/ACE/ACEXML/common/ZipCharStream.cpp
new file mode 100644
index 00000000000..bea182781ad
--- /dev/null
+++ b/ACE/ACEXML/common/ZipCharStream.cpp
@@ -0,0 +1,255 @@
+// $Id$
+
+#ifdef USE_ZZIP
+
+#include "ACEXML/common/ZipCharStream.h"
+#include "ace/ACE.h"
+
+
+ACEXML_ZipCharStream::ACEXML_ZipCharStream (void)
+ : filename_ (0), encoding_ (0), size_ (0), infile_ (0), pos_ (0),
+ limit_ (0)
+{
+}
+
+ACEXML_ZipCharStream::~ACEXML_ZipCharStream (void)
+{
+ this->close();
+}
+
+int
+ACEXML_ZipCharStream::open (const ACEXML_Char *name)
+{
+ delete[] this->filename_;
+ this->filename_ = 0;
+
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+
+ this->infile_ = zzip_fopen (name, ACE_TEXT ("r"));
+ if (this->infile_ == 0)
+ return -1;
+
+ this->filename_ = ACE::strnew (ACE::basename (name));
+ return this->determine_encoding();
+}
+
+int
+ACEXML_ZipCharStream::determine_encoding (void)
+{
+ if (this->infile_ == 0)
+ return -1;
+ char input[4];
+ int i = 0;
+ for (; i < 4 && (input[i] = this->peekchar_i(i)) > 0; ++i)
+ ;
+ if (i < 4)
+ return -1;
+ const ACEXML_Char* temp = ACEXML_Encoding::get_encoding (input);
+ if (!temp)
+ return -1;
+ else
+ {
+ if (this->encoding_)
+ delete [] this->encoding_;
+ this->encoding_ = ACE::strnew (temp);
+ // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("File's encoding is %s\n"),
+// this->encoding_));
+ }
+ // Move over the byte-order-mark if present.
+ char ch;
+ for (int j = 0; j < 3; ++j)
+ {
+ if ((ch = this->peekchar_i()) < 0)
+ return -1;
+ if (ch == '\xFF' || ch == '\xFE' || ch == '\xEF' || ch == '\xBB' ||
+ ch == '\xBF')
+ this->get(ch);
+ else
+ break;
+ }
+ return 0;
+}
+
+void
+ACEXML_ZipCharStream::rewind()
+{
+ if (this->infile_ == 0)
+ return;
+ zzip_rewind (this->infile_);
+ this->determine_encoding();
+}
+
+int
+ACEXML_ZipCharStream::available (void)
+{
+ if (this->infile_ == 0)
+ return -1;
+ long curr;
+ if ((curr = zzip_tell (this->infile_)) < 0)
+ return -1;
+ return (this->size_ - curr);
+}
+
+int
+ACEXML_ZipCharStream::close (void)
+{
+ if (this->infile_ != 0)
+ {
+ zzip_close (this->infile_);
+ this->infile_ = 0;
+ }
+ delete[] this->filename_;
+ this->filename_ = 0;
+ delete[] this->encoding_;
+ this->encoding_ = 0;
+ this->size_ = 0;
+ this->pos_ = 0;
+ this->limit_ = 0;
+ return 0;
+}
+
+
+int
+ACEXML_ZipCharStream::getchar_i (char& ch)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ if (this->pos_ < this->limit_)
+ {
+ ch = this->buf_[this->pos_++];
+ return 0;
+ }
+ this->limit_ = zzip_read (this->infile_, this->buf_, sizeof (this->buf_));
+ if (this->limit_ == 0)
+ return -1;
+ this->pos_ = 0;
+ ch = this->buf_[this->pos_++];
+ return 0;
+}
+
+int
+ACEXML_ZipCharStream::peekchar_i (off_t offset)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ if (offset > (off_t) sizeof (this->buf_))
+ return -1;
+ if (this->pos_ + offset < this->limit_)
+ return this->buf_[this->pos_ + offset];
+ int i = 0;
+ for (; this->pos_ < this->limit_; ++this->pos_, ++i)
+ this->buf_[i] = this->buf_[this->pos_];
+ this->limit_ = zzip_read (this->infile_, this->buf_ + i,
+ sizeof (this->buf_) - i);
+ this->limit_ += i;
+ if (this->limit_ == 0)
+ return -1;
+ this->pos_ = 0;
+ return this->buf_[this->pos_ + offset];
+}
+
+int
+ACEXML_ZipCharStream::read (ACEXML_Char *str, size_t len)
+{
+ if (this->infile_ == 0)
+ return -1;
+
+ size_t i = 0;
+ for (; i < len && this->pos_ < this->limit_; ++i)
+ str[i] = this->buf_[this->pos_++];
+ if (i == len)
+ return len;
+ len = len - i;
+ this->pos_ = 0;
+ this->limit_ = 0;
+ int bytes = zzip_fread (str + i, sizeof (ACEXML_Char), len, this->infile_);
+ return (bytes + i);
+}
+
+int
+ACEXML_ZipCharStream::get (ACEXML_Char& ch)
+{
+#if defined (ACE_USES_WCHAR)
+ return this->get_i (ch);
+#else
+ return this->getchar_i (ch);
+#endif /* ACE_USES_WCHAR */
+}
+
+
+int
+ACEXML_ZipCharStream::peek (void)
+{
+#if defined (ACE_USES_WCHAR)
+ return this->peek_i();
+#else
+ return this->peekchar_i();
+#endif /* ACE_USES_WCHAR */
+}
+
+const ACEXML_Char*
+ACEXML_ZipCharStream::getEncoding (void)
+{
+ return this->encoding_;
+}
+
+const ACEXML_Char*
+ACEXML_ZipCharStream::getSystemId (void)
+{
+ return this->filename_;
+}
+
+#if defined (ACE_USES_WCHAR)
+int
+ACEXML_ZipCharStream::get_i (ACEXML_Char& ch)
+{
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ return this->getchar_i (ch);
+
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+ ACEXML_Char input[2];
+ int i = 0;
+ for (; i < 2 && (this->getchar_i (input[i]) == 0); ++i)
+ ;
+ if (i < 2)
+ {
+ ch = 0;
+ return -1;
+ }
+ ch = BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0];
+ return 0;
+}
+
+int
+ACEXML_ZipCharStream::peek_i (void)
+{
+
+ // If we are reading a UTF-8 encoded file, just use the plain unget.
+ if (ACE_OS::strcmp (this->encoding_, ACE_TEXT ("UTF-8")) == 0)
+ return this->peekchar_i();
+
+ // Peek into the stream. This reads two characters off the stream, keeps
+ // it in peek_.
+ int BE = (ACE_OS::strcmp (this->encoding_,
+ ACE_TEXT ("UTF-16BE")) == 0) ? 1 : 0;
+
+ ACEXML_Char input[2];
+ int i = 0;
+ for (; i < 2 && (input[i] = this->peekchar_i (i)) > 0; ++i)
+ ;
+ if (i < 2)
+ return -1;
+ return (BE ? input[0] << 8 | input[1] : input[1] << 8 | input[0]);
+}
+#endif /* ACE_USES_WCHAR */
+
+#else
+#if defined (__HP_aCC)
+static int shut_up_aCC = 0;
+#endif /* __HP_aCC */
+
+#endif /* USE_ZZIP */
diff --git a/ACE/ACEXML/common/ZipCharStream.h b/ACE/ACEXML/common/ZipCharStream.h
new file mode 100644
index 00000000000..2c3ee5fb775
--- /dev/null
+++ b/ACE/ACEXML/common/ZipCharStream.h
@@ -0,0 +1,144 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ZipCharStream.h
+ *
+ * $Id$
+ *
+ * @author Krishnakumar B <kitty@cs.wustl.edu>
+ */
+//=============================================================================
+
+#ifndef _ACEXML_ZIPCHARSTREAM_H_
+#define _ACEXML_ZIPCHARSTREAM_H_
+
+#ifdef USE_ZZIP
+
+#include /**/ "ace/pre.h"
+#include "ACEXML/common/ACEXML_Export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ACEXML/common/CharStream.h"
+#include "ACEXML/common/Encoding.h"
+#include "zzip/zzip.h"
+
+// Ugly wart to get aroung a macro version of read defined in zzip.h. Evil...
+#ifdef read
+#undef read
+#endif
+
+/**
+ * @class ACEXML_ZipCharStream
+ *
+ * An implementation of ACEXML_CharStream for reading input from a ZIP archive.
+ */
+class ACEXML_Export ACEXML_ZipCharStream : public ACEXML_CharStream
+{
+public:
+ /// Default constructor.
+ ACEXML_ZipCharStream (void);
+
+ /// Destructor
+ virtual ~ACEXML_ZipCharStream (void);
+
+ /// Open a file.
+ int open (const ACEXML_Char *name);
+
+ /**
+ * Returns the available ACEXML_Char in the buffer. -1
+ * if the object is not initialized properly.
+ */
+ virtual int available (void);
+
+ /**
+ * Close this stream and release all resources used by it.
+ */
+ virtual int close (void);
+
+ /**
+ * Read the next ACEXML_Char. Return -1 if we are not able to
+ * return an ACEXML_Char, 0 if EOF is reached, or 1 if succeed.
+ */
+ virtual int get (ACEXML_Char& ch);
+
+ /**
+ * Read the next batch of ACEXML_Char strings
+ */
+ virtual int read (ACEXML_Char *str, size_t len);
+
+ /**
+ * Determine the encoding of the file.
+ */
+ virtual int determine_encoding (void);
+
+
+ /**
+ * Peek the next ACEXML_Char in the CharStream. Return the
+ * character if success, -1 if EOF is reached.
+ */
+ virtual int peek (void);
+
+ /**
+ * Resets the file pointer to the beginning of the stream.
+ */
+ virtual void rewind (void);
+
+ /*
+ * Get the character encoding for a byte stream or URI.
+ */
+ virtual const ACEXML_Char *getEncoding (void);
+
+ /*
+ * Get the systemId for the underlying CharStream
+ */
+ virtual const ACEXML_Char* getSystemId (void);
+
+protected:
+
+ /** Read the next character as a normal character. Return -1 if EOF is
+ * reached, else return 0.
+ */
+ virtual int getchar_i (char& ch);
+
+ /**
+ * Peek @c offset bytes into the stream and return the character at @c
+ * offset. If EOF is reached, return -1.
+ */
+ virtual int peekchar_i (off_t offset = 0);
+
+private:
+
+#if defined (ACE_USES_WCHAR)
+ /**
+ * Read the next character from the stream taking into account the
+ * encoding of the file.
+ */
+ int get_i (ACEXML_Char& ch);
+
+ /**
+ * Return the next character from the stream taking into account the
+ * encoding of the file. Subsequent call to get() returns this
+ * character.
+ */
+ int peek_i (void);
+
+#endif /* ACE_USES_WCHAR */
+
+ ACEXML_Char* filename_;
+ ACEXML_Char* encoding_;
+ off_t size_;
+ ZZIP_FILE* infile_;
+ char buf_[80];
+ int pos_;
+ int limit_;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* USE_ZZIP */
+
+#endif /* _ACEXML_ZIPCHARSTREAM_H_ */
diff --git a/ACE/ACEXML/common/codecs.mpb b/ACE/ACEXML/common/codecs.mpb
new file mode 100644
index 00000000000..134e0815539
--- /dev/null
+++ b/ACE/ACEXML/common/codecs.mpb
@@ -0,0 +1,8 @@
+// -*- MPC -*-
+// $Id$
+
+feature(ace_codecs) {
+ Source_Files {
+ XML_Codecs.cpp
+ }
+}
diff --git a/ACE/ACEXML/common/common.mpc b/ACE/ACEXML/common/common.mpc
new file mode 100644
index 00000000000..bd496a82123
--- /dev/null
+++ b/ACE/ACEXML/common/common.mpc
@@ -0,0 +1,33 @@
+// -*- MPC -*-
+// $Id$
+
+project(ACEXML): acelib, codecs, core {
+ avoids += ace_for_tao
+ sharedname = ACEXML
+ dynamicflags += ACEXML_BUILD_DLL
+
+ Source_Files {
+ // This file will only be added if the ace_codecs feature is enabled.
+ // See codecs.mpb for more information.
+ !XML_Codecs.cpp
+ }
+
+ Header_Files {
+ ACEXML_Export.h
+ Attributes.h
+ ContentHandler.h
+ DTDHandler.h
+ EntityResolver.h
+ ErrorHandler.h
+ Locator.h
+ XMLFilter.h
+ XMLReader.h
+ XML_Macros.h
+ XML_Types.h
+ XML_Util.h
+ }
+
+ Pkgconfig_Files {
+ ACEXML.pc.in
+ }
+}