You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2008/01/16 14:42:37 UTC
svn commit: r612452 - in /xerces/c/trunk: ./ lib/ samples/ src/
src/xercesc/util/MsgLoaders/ICU/resources/
src/xercesc/util/MsgLoaders/MsgCatalog/ swig/ tests/
tests/src/MemHandlerTest/
Author: amassari
Date: Wed Jan 16 05:42:36 2008
New Revision: 612452
URL: http://svn.apache.org/viewvc?rev=612452&view=rev
Log:
'make dist' packages all the sources needed to compile Xerces
Removed:
xerces/c/trunk/src/xercesc/util/MsgLoaders/ICU/resources/res-file-list.txt
xerces/c/trunk/swig/Makefile.am
xerces/c/trunk/tests/src/MemHandlerTest/SimpleValueHashTableOf.c
Modified:
xerces/c/trunk/Makefile.am
xerces/c/trunk/configure.ac
xerces/c/trunk/lib/Makefile.am
xerces/c/trunk/samples/Makefile.am
xerces/c/trunk/src/Makefile.am
xerces/c/trunk/src/xercesc/util/MsgLoaders/ICU/resources/Makefile.in (contents, props changed)
xerces/c/trunk/src/xercesc/util/MsgLoaders/MsgCatalog/Makefile.in
xerces/c/trunk/tests/Makefile.am
xerces/c/trunk/tests/src/MemHandlerTest/SimpleValueHashTableOf.hpp
Modified: xerces/c/trunk/Makefile.am
URL: http://svn.apache.org/viewvc/xerces/c/trunk/Makefile.am?rev=612452&r1=612451&r2=612452&view=diff
==============================================================================
--- xerces/c/trunk/Makefile.am (original)
+++ xerces/c/trunk/Makefile.am Wed Jan 16 05:42:36 2008
@@ -1,5 +1,13 @@
SUBDIRS = lib src obj tests samples
+EXTRA_DIST = config/pretty-make \
+ scripts/createBindingsFormatFromHPP.pl \
+ scripts/makeStringDefinition.pl \
+ scripts/packageBinaries.pl \
+ scripts/packageSources.pl \
+ scripts/sanityTest.pl \
+ scripts/sanityTest_ExpectedResult.log
+
ACLOCAL_AMFLAGS = -I m4
check:
Modified: xerces/c/trunk/configure.ac
URL: http://svn.apache.org/viewvc/xerces/c/trunk/configure.ac?rev=612452&r1=612451&r2=612452&view=diff
==============================================================================
--- xerces/c/trunk/configure.ac (original)
+++ xerces/c/trunk/configure.ac Wed Jan 16 05:42:36 2008
@@ -30,7 +30,14 @@
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h src/xercesc/util/Xerces_autoconf_config.hpp])
-AC_CONFIG_FILES([Makefile lib/Makefile src/Makefile src/xercesc/util/MsgLoaders/ICU/resources/Makefile src/xercesc/util/MsgLoaders/MsgCatalog/Makefile obj/Makefile tests/Makefile samples/Makefile swig/Makefile])
+AC_CONFIG_FILES([Makefile \
+ lib/Makefile \
+ src/Makefile \
+ src/xercesc/util/MsgLoaders/ICU/resources/Makefile \
+ src/xercesc/util/MsgLoaders/MsgCatalog/Makefile \
+ obj/Makefile \
+ tests/Makefile \
+ samples/Makefile])
# Check the target system
AC_CANONICAL_HOST
Modified: xerces/c/trunk/lib/Makefile.am
URL: http://svn.apache.org/viewvc/xerces/c/trunk/lib/Makefile.am?rev=612452&r1=612451&r2=612452&view=diff
==============================================================================
--- xerces/c/trunk/lib/Makefile.am (original)
+++ xerces/c/trunk/lib/Makefile.am Wed Jan 16 05:42:36 2008
@@ -29,9 +29,9 @@
#
# Build convenience libraries for the various xerces components
#
-#noinst_libcompat_la_HEADERS =
-libcompat_la_SOURCES = xerces_compat.c
-libcompat_la_LIBADD = ${LTLIBOBJS}
+EXTRA_DIST = stricmp.h strnicmp.h towlower.h towupper.h
+libcompat_la_SOURCES = xerces_compat.c
+libcompat_la_LIBADD = ${LTLIBOBJS}
#
# Override generated rules to provide prettier make rules
Modified: xerces/c/trunk/samples/Makefile.am
URL: http://svn.apache.org/viewvc/xerces/c/trunk/samples/Makefile.am?rev=612452&r1=612451&r2=612452&view=diff
==============================================================================
--- xerces/c/trunk/samples/Makefile.am (original)
+++ xerces/c/trunk/samples/Makefile.am Wed Jan 16 05:42:36 2008
@@ -19,75 +19,105 @@
# $Id$
#
-bin_PROGRAMS = ${sampleprogs}
+bin_PROGRAMS = ${sampleprogs}
-LDADD = ${top_builddir}/obj/libxerces-c.la
+LDADD = ${top_builddir}/obj/libxerces-c.la
# the -I${top_builddir}/src is needed to pick the xercesc/util/Xerces_autoconf_config.hpp
# header file when doing out-of-tree builds
-AM_CPPFLAGS = -I${top_builddir}/src -I${top_srcdir}/src
+AM_CPPFLAGS = -I${top_builddir}/src -I${top_srcdir}/src
-sampleprogs =
+EXTRA_DIST = data/personal.dtd \
+ data/personal.xml \
+ data/personal.xsd \
+ data/personal-schema.xml \
+ data/redirect.dtd
-sampleprogs += CreateDOMDocument
-CreateDOMDocument_SOURCES = src/CreateDOMDocument/CreateDOMDocument.cpp
+sampleprogs =
-sampleprogs += DOMCount
-DOMCount_SOURCES = src/DOMCount/DOMCount.cpp
+sampleprogs += CreateDOMDocument
+CreateDOMDocument_SOURCES = src/CreateDOMDocument/CreateDOMDocument.cpp
-sampleprogs += DOMPrint
-DOMPrint_SOURCES = src/DOMPrint/DOMPrint.cpp \
- src/DOMPrint/DOMPrintErrorHandler.cpp \
- src/DOMPrint/DOMPrintFilter.cpp \
- src/DOMPrint/DOMTreeErrorReporter.cpp
-
-sampleprogs += EnumVal
-EnumVal_SOURCES = src/EnumVal/EnumVal.cpp
-
-sampleprogs += MemParse
-MemParse_SOURCES = src/MemParse/MemParse.cpp \
- src/MemParse/MemParseHandlers.cpp
-
-sampleprogs += PParse
-PParse_SOURCES = src/PParse/PParse.cpp \
- src/PParse/PParseHandlers.cpp
-
-sampleprogs += PSVIWriter
-PSVIWriter_SOURCES = src/PSVIWriter/PSVIWriter.cpp \
- src/PSVIWriter/PSVIWriterHandlers.cpp
-
-sampleprogs += Redirect
-Redirect_SOURCES = src/Redirect/Redirect.cpp \
- src/Redirect/RedirectHandlers.cpp
-
-sampleprogs += SAX2Count
-SAX2Count_SOURCES = src/SAX2Count/SAX2Count.cpp \
- src/SAX2Count/SAX2CountHandlers.cpp
-
-sampleprogs += SAX2Print
-SAX2Print_SOURCES = src/SAX2Print/SAX2FilterHandlers.cpp \
- src/SAX2Print/SAX2Print.cpp \
- src/SAX2Print/SAX2PrintHandlers.cpp
-
-sampleprogs += SAXCount
-SAXCount_SOURCES = src/SAXCount/SAXCount.cpp \
- src/SAXCount/SAXCountHandlers.cpp
-
-sampleprogs += SAXPrint
-SAXPrint_SOURCES = src/SAXPrint/SAXPrint.cpp \
- src/SAXPrint/SAXPrintHandlers.cpp
-
-sampleprogs += SCMPrint
-SCMPrint_SOURCES = src/SCMPrint/SCMPrint.cpp
-
-sampleprogs += SEnumVal
-SEnumVal_SOURCES = src/SEnumVal/SEnumVal.cpp
-
-sampleprogs += StdInParse
-StdInParse_SOURCES = src/StdInParse/StdInParse.cpp \
- src/StdInParse/StdInParseHandlers.cpp
+sampleprogs += DOMCount
+DOMCount_SOURCES = src/DOMCount/DOMCount.cpp \
+ src/DOMCount/DOMCount.hpp
+
+sampleprogs += DOMPrint
+DOMPrint_SOURCES = src/DOMPrint/DOMPrint.cpp \
+ src/DOMPrint/DOMPrintErrorHandler.cpp \
+ src/DOMPrint/DOMPrintErrorHandler.hpp \
+ src/DOMPrint/DOMPrintFilter.cpp \
+ src/DOMPrint/DOMPrintFilter.hpp \
+ src/DOMPrint/DOMTreeErrorReporter.cpp \
+ src/DOMPrint/DOMTreeErrorReporter.hpp
+
+sampleprogs += EnumVal
+EnumVal_SOURCES = src/EnumVal/EnumVal.cpp
+
+sampleprogs += MemParse
+MemParse_SOURCES = src/MemParse/MemParse.cpp \
+ src/MemParse/MemParse.hpp \
+ src/MemParse/MemParseHandlers.cpp \
+ src/MemParse/MemParseHandlers.hpp
+
+sampleprogs += PParse
+PParse_SOURCES = src/PParse/PParse.cpp \
+ src/PParse/PParse.hpp \
+ src/PParse/PParseHandlers.cpp \
+ src/PParse/PParseHandlers.hpp
+
+sampleprogs += PSVIWriter
+PSVIWriter_SOURCES = src/PSVIWriter/PSVIWriter.cpp \
+ src/PSVIWriter/PSVIWriter.hpp \
+ src/PSVIWriter/PSVIWriterHandlers.cpp \
+ src/PSVIWriter/PSVIWriterHandlers.hpp
+
+sampleprogs += Redirect
+Redirect_SOURCES = src/Redirect/Redirect.cpp \
+ src/Redirect/Redirect.hpp \
+ src/Redirect/RedirectHandlers.cpp \
+ src/Redirect/RedirectHandlers.hpp
+
+sampleprogs += SAX2Count
+SAX2Count_SOURCES = src/SAX2Count/SAX2Count.cpp \
+ src/SAX2Count/SAX2Count.hpp \
+ src/SAX2Count/SAX2CountHandlers.cpp \
+ src/SAX2Count/SAX2CountHandlers.hpp
+
+sampleprogs += SAX2Print
+SAX2Print_SOURCES = src/SAX2Print/SAX2FilterHandlers.cpp \
+ src/SAX2Print/SAX2FilterHandlers.hpp \
+ src/SAX2Print/SAX2Print.cpp \
+ src/SAX2Print/SAX2Print.hpp \
+ src/SAX2Print/SAX2PrintHandlers.cpp \
+ src/SAX2Print/SAX2PrintHandlers.hpp
+
+sampleprogs += SAXCount
+SAXCount_SOURCES = src/SAXCount/SAXCount.cpp \
+ src/SAXCount/SAXCount.hpp \
+ src/SAXCount/SAXCountHandlers.cpp \
+ src/SAXCount/SAXCountHandlers.hpp
+
+sampleprogs += SAXPrint
+SAXPrint_SOURCES = src/SAXPrint/SAXPrint.cpp \
+ src/SAXPrint/SAXPrint.hpp \
+ src/SAXPrint/SAXPrintHandlers.cpp \
+ src/SAXPrint/SAXPrintHandlers.hpp
+
+sampleprogs += SCMPrint
+SCMPrint_SOURCES = src/SCMPrint/SCMPrint.cpp
+
+sampleprogs += SEnumVal
+SEnumVal_SOURCES = src/SEnumVal/SEnumVal.cpp
+
+sampleprogs += StdInParse
+StdInParse_SOURCES = src/StdInParse/StdInParse.cpp \
+ src/StdInParse/StdInParse.hpp \
+ src/StdInParse/StdInParseHandlers.cpp \
+ src/StdInParse/StdInParseHandlers.hpp
-sampleprogs += XInclude
-XInclude_SOURCES = src/XInclude/XInclude.cpp
+sampleprogs += XInclude
+XInclude_SOURCES = src/XInclude/XInclude.cpp \
+ src/XInclude/XInclude.hpp
#
# Override generated rules to provide prettier make rules
Modified: xerces/c/trunk/src/Makefile.am
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/Makefile.am?rev=612452&r1=612451&r2=612452&view=diff
==============================================================================
--- xerces/c/trunk/src/Makefile.am (original)
+++ xerces/c/trunk/src/Makefile.am Wed Jan 16 05:42:36 2008
@@ -52,6 +52,7 @@
src_libraries += libutil.la
libutil_ladir = ${includedir}
nobase_libutil_la_HEADERS = ${util_headers}
+nobase_nodist_libutil_la_HEADERS = ${builddir}/xercesc/util/Xerces_autoconf_config.hpp
libutil_la_SOURCES = ${util_sources}
src_libraries += libdom.la
@@ -671,7 +672,6 @@
sax2_sources = \
xercesc/sax2/sax2Dummy.cpp
-
util_headers = \
xercesc/util/ArrayIndexOutOfBoundsException.hpp \
xercesc/util/Base64.hpp \
@@ -782,7 +782,6 @@
xercesc/util/ValueVectorOf.c \
xercesc/util/XercesDefs.hpp \
xercesc/util/XercesVersion.hpp \
- xercesc/util/Xerces_autoconf_config.hpp \
xercesc/util/XMemory.hpp \
xercesc/util/XML256TableTranscoder.hpp \
xercesc/util/XML88591Transcoder.hpp \
Modified: xerces/c/trunk/src/xercesc/util/MsgLoaders/ICU/resources/Makefile.in
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/MsgLoaders/ICU/resources/Makefile.in?rev=612452&r1=612451&r2=612452&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/MsgLoaders/ICU/resources/Makefile.in (original)
+++ xerces/c/trunk/src/xercesc/util/MsgLoaders/ICU/resources/Makefile.in Wed Jan 16 05:42:36 2008
@@ -20,15 +20,16 @@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-prefix = @prefix@
+prefix = @prefix@
exec_prefix = @exec_prefix@
-libdir = @libdir@
+libdir = @libdir@
ICU_PREFIX = @ICU_PREFIX@
SHREXT = @SHREXT@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
mkdir_p = @mkdir_p@
+# Special build rules
include $(top_srcdir)/version.incl
GENRB=$(ICU_PREFIX)/bin/genrb
@@ -39,7 +40,7 @@
# No conventional target - this dir is resources only.
TARGET=
-CLEANFILES += *.mak *.[co] *.lst *.a *.$(SO) $(RESFILES) *.ao README*resources.txt
+CLEANFILES += *.[co] *.lst *.a *.$(SO) $(RESFILES) *.ao README*resources.txt
# Resource shortname
PKGNAME=XercesMessages$(VER)
@@ -86,10 +87,38 @@
@echo "generating $@"
$(GENRB) $(GENRBOPT) $^
-# for installing the library
+# Needed to support "make install" and "make uninstall"
install: $(RESTARGET)
$(mkdir_p) $(libdir)
$(INSTALL_PROGRAM) $(RESTARGET) $(libdir)
uninstall:
-rm $(libdir)/$(PKGTARGET)
+
+# Needed to support "make dist"
+distdir:
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='res-file-list-unix.txt res-file-list-wins.txt en_US.txt Makefile.in resources.mak'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
Propchange: xerces/c/trunk/src/xercesc/util/MsgLoaders/ICU/resources/Makefile.in
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xerces/c/trunk/src/xercesc/util/MsgLoaders/MsgCatalog/Makefile.in
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/MsgLoaders/MsgCatalog/Makefile.in?rev=612452&r1=612451&r2=612452&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/MsgLoaders/MsgCatalog/Makefile.in (original)
+++ xerces/c/trunk/src/xercesc/util/MsgLoaders/MsgCatalog/Makefile.in Wed Jan 16 05:42:36 2008
@@ -53,3 +53,32 @@
uninstall:
-rm $(prefix)/msg/$(RESFILES)
+
+
+# Needed to support "make dist"
+distdir:
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='XercesMessages_en_US.Msg Makefile.in'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
Modified: xerces/c/trunk/tests/Makefile.am
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/Makefile.am?rev=612452&r1=612451&r2=612452&view=diff
==============================================================================
--- xerces/c/trunk/tests/Makefile.am (original)
+++ xerces/c/trunk/tests/Makefile.am Wed Jan 16 05:42:36 2008
@@ -112,6 +112,12 @@
src/XSerializerTest/XSerializerTest.cpp \
src/XSerializerTest/XSerializerTest.hpp
+testprogs += XSTSHarness
+XSTSHarness_SOURCES = src/XSTSHarness/XSTSHarness.cpp \
+ src/XSTSHarness/XSTSHarness.hpp \
+ src/XSTSHarness/XSTSHarnessHandlers.cpp \
+ src/XSTSHarness/XSTSHarnessHandlers.hpp
+
# Fails to compile under gcc4 (values too long for long type)
testprogs += XSValueTest
XSValueTest_SOURCES = src/XSValueTest/XSValueTest.cpp \
Modified: xerces/c/trunk/tests/src/MemHandlerTest/SimpleValueHashTableOf.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/MemHandlerTest/SimpleValueHashTableOf.hpp?rev=612452&r1=612451&r2=612452&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/MemHandlerTest/SimpleValueHashTableOf.hpp (original)
+++ xerces/c/trunk/tests/src/MemHandlerTest/SimpleValueHashTableOf.hpp Wed Jan 16 05:42:36 2008
@@ -25,6 +25,7 @@
#include "SimpleHashPtr.hpp"
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/NoSuchElementException.hpp>
+#include <xercesc/util/NullPointerException.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/XMLExceptMsgs.hpp>
#include <xercesc/util/XMLEnumerator.hpp>
@@ -182,10 +183,357 @@
bool fAdopted;
ValueHashTableBucketElem<TVal>* fCurElem;
unsigned int fCurHash;
- SimpleValueHashTableOf<TVal>* fToEnum;
+ SimpleValueHashTableOf<TVal>* fToEnum;
};
-#if !defined(XERCES_TMPLSINC)
-#include "SimpleValueHashTableOf.c"
-#endif
+// This is just an old version of the ValueHashTableOf implementation
+// from xercesc/util; we need a new one here because this
+// cannot use the pluggable memory management facilities.
+
+// forward declarations
+
+// ---------------------------------------------------------------------------
+// ValueHashTableOf: Constructors and Destructor
+// ---------------------------------------------------------------------------
+template <class TVal> SimpleValueHashTableOf<TVal>::SimpleValueHashTableOf(const unsigned int modulus
+ , SimpleHashPtr* hashBase)
+ : fBucketList(0), fHashModulus(modulus)
+{
+ initialize(modulus);
+ // set hasher
+ fHash = hashBase;
+}
+
+template <class TVal> SimpleValueHashTableOf<TVal>::SimpleValueHashTableOf(const unsigned int modulus)
+ : fBucketList(0), fHashModulus(modulus)
+{
+ initialize(modulus);
+
+ // create default hasher
+ fHash = new HashXMLCh();
+}
+
+template <class TVal> void SimpleValueHashTableOf<TVal>::initialize(const unsigned int modulus)
+{
+ if (modulus == 0)
+ ThrowXML(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus);
+
+ // Allocate the bucket list and zero them
+ fBucketList = new ValueHashTableBucketElem<TVal>*[fHashModulus];
+ for (unsigned int index = 0; index < fHashModulus; index++)
+ fBucketList[index] = 0;
+}
+
+template <class TVal> SimpleValueHashTableOf<TVal>::~SimpleValueHashTableOf()
+{
+ removeAll();
+
+ // Then delete the bucket list & hasher
+ delete [] fBucketList;
+ delete fHash;
+}
+
+
+// ---------------------------------------------------------------------------
+// SimpleValueHashTableOf: Element management
+// ---------------------------------------------------------------------------
+template <class TVal> bool SimpleValueHashTableOf<TVal>::isEmpty() const
+{
+ // Just check the bucket list for non-empty elements
+ for (unsigned int buckInd = 0; buckInd < fHashModulus; buckInd++)
+ {
+ if (fBucketList[buckInd] != 0)
+ return false;
+ }
+ return true;
+}
+
+template <class TVal> bool SimpleValueHashTableOf<TVal>::
+containsKey(const void* const key) const
+{
+ unsigned int hashVal;
+ const ValueHashTableBucketElem<TVal>* findIt = findBucketElem(key, hashVal);
+ return (findIt != 0);
+}
+
+template <class TVal> void SimpleValueHashTableOf<TVal>::
+removeKey(const void* const key)
+{
+ unsigned int hashVal;
+ removeBucketElem(key, hashVal);
+}
+
+template <class TVal> void SimpleValueHashTableOf<TVal>::removeAll()
+{
+ // Clean up the buckets first
+ for (unsigned int buckInd = 0; buckInd < fHashModulus; buckInd++)
+ {
+ // Get the bucket list head for this entry
+ ValueHashTableBucketElem<TVal>* curElem = fBucketList[buckInd];
+ ValueHashTableBucketElem<TVal>* nextElem;
+ while (curElem)
+ {
+ // Save the next element before we hose this one
+ nextElem = curElem->fNext;
+
+ // delete the current element and move forward
+ delete curElem;
+ curElem = nextElem;
+ }
+
+ // Clean out this entry
+ fBucketList[buckInd] = 0;
+ }
+}
+
+
+// ---------------------------------------------------------------------------
+// SimpleValueHashTableOf: Getters
+// ---------------------------------------------------------------------------
+template <class TVal> TVal& SimpleValueHashTableOf<TVal>::get(const void* const key)
+{
+ unsigned int hashVal;
+ ValueHashTableBucketElem<TVal>* findIt = findBucketElem(key, hashVal);
+ if (!findIt)
+ ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists);
+
+ return findIt->fData;
+}
+
+template <class TVal> const TVal& SimpleValueHashTableOf<TVal>::
+get(const void* const key) const
+{
+ unsigned int hashVal;
+ const ValueHashTableBucketElem<TVal>* findIt = findBucketElem(key, hashVal);
+ if (!findIt)
+ ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists);
+
+ return findIt->fData;
+}
+
+
+// ---------------------------------------------------------------------------
+// SimpleValueHashTableOf: Putters
+// ---------------------------------------------------------------------------
+template <class TVal> void SimpleValueHashTableOf<TVal>::put(void* key, const TVal& valueToAdopt)
+{
+ // First see if the key exists already
+ unsigned int hashVal;
+ ValueHashTableBucketElem<TVal>* newBucket = findBucketElem(key, hashVal);
+
+ //
+ // If so,then update its value. If not, then we need to add it to
+ // the right bucket
+ //
+ if (newBucket)
+ {
+ newBucket->fData = valueToAdopt;
+ newBucket->fKey = key;
+ }
+ else
+ {
+ newBucket = new ValueHashTableBucketElem<TVal>(key, valueToAdopt, fBucketList[hashVal]);
+ fBucketList[hashVal] = newBucket;
+ }
+}
+
+
+
+// ---------------------------------------------------------------------------
+// SimpleValueHashTableOf: Private methods
+// ---------------------------------------------------------------------------
+template <class TVal> ValueHashTableBucketElem<TVal>* SimpleValueHashTableOf<TVal>::
+findBucketElem(const void* const key, unsigned int& hashVal)
+{
+ // Hash the key
+ hashVal = fHash->getHashVal(key, fHashModulus);
+ if (hashVal > fHashModulus)
+ ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey);
+
+ // Search that bucket for the key
+ ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
+ while (curElem)
+ {
+ if (fHash->equals(key, curElem->fKey))
+ return curElem;
+
+ curElem = curElem->fNext;
+ }
+ return 0;
+}
+
+template <class TVal> const ValueHashTableBucketElem<TVal>* SimpleValueHashTableOf<TVal>::
+findBucketElem(const void* const key, unsigned int& hashVal) const
+{
+ // Hash the key
+ hashVal = fHash->getHashVal(key, fHashModulus);
+ if (hashVal > fHashModulus)
+ ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey);
+
+ // Search that bucket for the key
+ const ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
+ while (curElem)
+ {
+ if (fHash->equals(key, curElem->fKey))
+ return curElem;
+
+ curElem = curElem->fNext;
+ }
+ return 0;
+}
+
+
+template <class TVal> void SimpleValueHashTableOf<TVal>::
+removeBucketElem(const void* const key, unsigned int& hashVal)
+{
+ // Hash the key
+ hashVal = fHash->getHashVal(key, fHashModulus);
+ if (hashVal > fHashModulus)
+ ThrowXML(RuntimeException, XMLExcepts::HshTbl_BadHashFromKey);
+
+ //
+ // Search the given bucket for this key. Keep up with the previous
+ // element so we can patch around it.
+ //
+ ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
+ ValueHashTableBucketElem<TVal>* lastElem = 0;
+
+ while (curElem)
+ {
+ if (fHash->equals(key, curElem->fKey))
+ {
+ if (!lastElem)
+ {
+ // It was the first in the bucket
+ fBucketList[hashVal] = curElem->fNext;
+ }
+ else
+ {
+ // Patch around the current element
+ lastElem->fNext = curElem->fNext;
+ }
+
+ // Delete the current element
+ delete curElem;
+
+ return;
+ }
+
+ // Move both pointers upwards
+ lastElem = curElem;
+ curElem = curElem->fNext;
+ }
+
+ // We never found that key
+ ThrowXML(NoSuchElementException, XMLExcepts::HshTbl_NoSuchKeyExists);
+}
+
+
+
+
+// ---------------------------------------------------------------------------
+// ValueHashTableOfEnumerator: Constructors and Destructor
+// ---------------------------------------------------------------------------
+template <class TVal> ValueHashTableOfEnumerator<TVal>::
+ValueHashTableOfEnumerator(SimpleValueHashTableOf<TVal>* const toEnum, const bool adopt)
+ : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), fToEnum(toEnum)
+{
+ if (!toEnum)
+ ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero);
+
+ //
+ // Find the next available bucket element in the hash table. If it
+ // comes back zero, that just means the table is empty.
+ //
+ // Note that the -1 in the current hash tells it to start from the
+ // beginning.
+ //
+ findNext();
+}
+
+template <class TVal> ValueHashTableOfEnumerator<TVal>::~ValueHashTableOfEnumerator()
+{
+ if (fAdopted)
+ delete fToEnum;
+}
+
+
+// ---------------------------------------------------------------------------
+// ValueHashTableOfEnumerator: Enum interface
+// ---------------------------------------------------------------------------
+template <class TVal> bool ValueHashTableOfEnumerator<TVal>::hasMoreElements() const
+{
+ //
+ // If our current has is at the max and there are no more elements
+ // in the current bucket, then no more elements.
+ //
+ if (!fCurElem && (fCurHash == fToEnum->fHashModulus))
+ return false;
+ return true;
+}
+
+template <class TVal> TVal& ValueHashTableOfEnumerator<TVal>::nextElement()
+{
+ // Make sure we have an element to return
+ if (!hasMoreElements())
+ ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements);
+
+ //
+ // Save the current element, then move up to the next one for the
+ // next time around.
+ //
+ ValueHashTableBucketElem<TVal>* saveElem = fCurElem;
+ findNext();
+
+ return saveElem->fData;
+}
+
+
+template <class TVal> void ValueHashTableOfEnumerator<TVal>::Reset()
+{
+ fCurHash = (unsigned int)-1;
+ fCurElem = 0;
+ findNext();
+}
+
+
+
+// ---------------------------------------------------------------------------
+// ValueHashTableOfEnumerator: Private helper methods
+// ---------------------------------------------------------------------------
+template <class TVal> void ValueHashTableOfEnumerator<TVal>::findNext()
+{
+ //
+ // If there is a current element, move to its next element. If this
+ // hits the end of the bucket, the next block will handle the rest.
+ //
+ if (fCurElem)
+ fCurElem = fCurElem->fNext;
+
+ //
+ // If the current element is null, then we have to move up to the
+ // next hash value. If that is the hash modulus, then we cannot
+ // go further.
+ //
+ if (!fCurElem)
+ {
+ fCurHash++;
+ if (fCurHash == fToEnum->fHashModulus)
+ return;
+
+ // Else find the next non-empty bucket
+ while (true)
+ {
+ if (fToEnum->fBucketList[fCurHash])
+ break;
+
+ // Bump to the next hash value. If we max out return
+ fCurHash++;
+ if (fCurHash == fToEnum->fHashModulus)
+ return;
+ }
+ fCurElem = fToEnum->fBucketList[fCurHash];
+ }
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org