[mapguide-commits] r5362 -
trunk/MgDev/Oem/dbxml/xerces-c-src/src/xercesc/framework
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Oct 29 15:47:27 EDT 2010
Author: brucedechant
Date: 2010-10-29 12:47:27 -0700 (Fri, 29 Oct 2010)
New Revision: 5362
Modified:
trunk/MgDev/Oem/dbxml/xerces-c-src/src/xercesc/framework/XMLBuffer.cpp
trunk/MgDev/Oem/dbxml/xerces-c-src/src/xercesc/framework/XMLBuffer.hpp
Log:
Fix for trac ticket 1398 - Upgrade to DbXml 2.5.16
Fix for trac ticket 1399 - Upgrade to Xerces 3.1.0
http://trac.osgeo.org/mapguide/ticket/1398
http://trac.osgeo.org/mapguide/ticket/1399
Implement RFC 101 - Xerces Upgrade
http://trac.osgeo.org/mapguide/wiki/MapGuideRfc101
Implement RFC 102 - DBXML and Xqilla Upgrade
http://trac.osgeo.org/mapguide/wiki/MapGuideRfc102
Notes:
- Fixed Linux build issue
Modified: trunk/MgDev/Oem/dbxml/xerces-c-src/src/xercesc/framework/XMLBuffer.cpp
===================================================================
--- trunk/MgDev/Oem/dbxml/xerces-c-src/src/xercesc/framework/XMLBuffer.cpp 2010-10-29 06:33:36 UTC (rev 5361)
+++ trunk/MgDev/Oem/dbxml/xerces-c-src/src/xercesc/framework/XMLBuffer.cpp 2010-10-29 19:47:27 UTC (rev 5362)
@@ -32,7 +32,7 @@
// ---------------------------------------------------------------------------
// XMLBuffer: Buffer management
// ---------------------------------------------------------------------------
-
+/* Note: Moved this to the header file to resolve a Linux linking issue.
void XMLBuffer::ensureCapacity(const XMLSize_t extraNeeded)
{
// If we can't handle it, try doubling the buffer size.
@@ -81,6 +81,6 @@
fCapacity = newCap;
}
}
-
+*/
XERCES_CPP_NAMESPACE_END
Modified: trunk/MgDev/Oem/dbxml/xerces-c-src/src/xercesc/framework/XMLBuffer.hpp
===================================================================
--- trunk/MgDev/Oem/dbxml/xerces-c-src/src/xercesc/framework/XMLBuffer.hpp 2010-10-29 06:33:36 UTC (rev 5361)
+++ trunk/MgDev/Oem/dbxml/xerces-c-src/src/xercesc/framework/XMLBuffer.hpp 2010-10-29 19:47:27 UTC (rev 5362)
@@ -25,13 +25,37 @@
#include <xercesc/util/XMemory.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/MemoryManager.hpp>
+#include <xercesc/util/RuntimeException.hpp>
#include <string.h>
XERCES_CPP_NAMESPACE_BEGIN
-class XMLBufferFullHandler;
+class XMLBuffer;
/**
+ * XMLBufferFullHandler is a callback interface for clients of
+ * XMLBuffers that impose a size restriction (e.g. XMLScanner).
+ * Note that this is intended solely as a mix-in for internal
+ * use, and therefore does not derive from XMemory (to avoid
+ * the ambiguous base class problem).
+ */
+class XMLPARSER_EXPORT XMLBufferFullHandler
+{
+public :
+
+ virtual ~XMLBufferFullHandler() {}
+
+ /**
+ * Callback method, intended to allow clients of an XMLBuffer which has
+ * become full to empty it appropriately.
+ * @return true if the handler was able to empty the buffer (either
+ * partially or completely), otherwise false to indicate an error.
+ */
+ virtual bool bufferFull(XMLBuffer&) = 0;
+
+};
+
+/**
* XMLBuffer is a lightweight, expandable Unicode text buffer. Since XML is
* inherently theoretically unbounded in terms of the sizes of things, we
* very often need to have expandable buffers. The primary concern here is
@@ -217,9 +241,55 @@
// -----------------------------------------------------------------------
// Private helpers
// -----------------------------------------------------------------------
- void ensureCapacity(const XMLSize_t extraNeeded);
+ void ensureCapacity(const XMLSize_t extraNeeded)
+ {
+ // If we can't handle it, try doubling the buffer size.
+ XMLSize_t newCap = (fIndex + extraNeeded) * 2;
+ // If a maximum size is set, and double the current buffer size exceeds that
+ // maximum, first check if the maximum size will accomodate the extra needed.
+ if (fFullHandler && (newCap > fFullSize))
+ {
+ // If the maximum buffer size accomodates the extra needed, resize to
+ // the maximum
+ if (fIndex + extraNeeded <= fFullSize)
+ {
+ newCap = fFullSize;
+ }
+ // Otherwise, allow the registered full-handler to try to empty the buffer.
+ // If it claims success, and we can accommodate the extra needed in the buffer
+ // to be expanded, resize to the maximum
+ // Note the order of evaluation: bufferFull() has the intentional side-effect
+ // of modifying fIndex.
+ else if (fFullHandler->bufferFull(*this) && (fIndex + extraNeeded <= fFullSize))
+ {
+ newCap = fFullSize;
+ }
+
+ // Finally, if the full-handler failed, or the buffer (of maximum size)
+ // still can't accomodate the extra needed, we must fail.
+ else
+ ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Array_BadNewSize, fMemoryManager);
+ }
+
+ // Note the previous if block can modify newCap, so we may not need to allocate
+ // at all.
+ if (newCap > fCapacity)
+ {
+ // Allocate new buffer
+ XMLCh* newBuf = (XMLCh*) fMemoryManager->allocate((newCap+1) * sizeof(XMLCh)); //new XMLCh[newCap+1];
+
+ // Copy over the old stuff
+ memcpy(newBuf, fBuffer, fIndex * sizeof(XMLCh));
+
+ // Clean up old buffer and store new stuff
+ fMemoryManager->deallocate(fBuffer); //delete [] fBuffer;
+ fBuffer = newBuf;
+ fCapacity = newCap;
+ }
+ }
+
// -----------------------------------------------------------------------
// Private data members
//
@@ -253,29 +323,6 @@
XMLCh* fBuffer;
};
-/**
- * XMLBufferFullHandler is a callback interface for clients of
- * XMLBuffers that impose a size restriction (e.g. XMLScanner).
- * Note that this is intended solely as a mix-in for internal
- * use, and therefore does not derive from XMemory (to avoid
- * the ambiguous base class problem).
- */
-class XMLPARSER_EXPORT XMLBufferFullHandler
-{
-public :
-
- virtual ~XMLBufferFullHandler() {}
-
- /**
- * Callback method, intended to allow clients of an XMLBuffer which has
- * become full to empty it appropriately.
- * @return true if the handler was able to empty the buffer (either
- * partially or completely), otherwise false to indicate an error.
- */
- virtual bool bufferFull(XMLBuffer&) = 0;
-
-};
-
XERCES_CPP_NAMESPACE_END
#endif
More information about the mapguide-commits
mailing list