Greetings,
The attached patch makes the following small usability improvements:
- make a number of static helper methods in XMLUri.hpp public.
- adds methods to XMLString.hpp and XMLString.cpp to release strings using
a memory manager. In XMLString.hpp the comments/documentation are updated
as well.
The patch also fixes the compilation warning about comparison between
signed and unsigned in
src/xercesc/validators/schema/SchemaElementDecl.hpp. This problem was
mentioned before on the list, but the fix has not made it to svn yet.
For an improvement in samples/ I second the suggestion made by Neil Graham
on 10 december, 2003: "I'd also like to deprecate the SEnumVal and EnumVal
samples eventually; we certainly shouldn't be going out of our way to show
people how to use Xerces's internal interfaces!".
If a bug report is needed for any of the suggestions above, please let me
know.
Jeroen.
Index: src/xercesc/validators/schema/SchemaElementDecl.hpp
===================================================================
--- src/xercesc/validators/schema/SchemaElementDecl.hpp (revision 289713)
+++ src/xercesc/validators/schema/SchemaElementDecl.hpp (working copy)
@@ -378,7 +378,7 @@
PSVIDefs::Validity fValidity;
PSVIDefs::Validation fValidation;
- int fEnclosingScope;
+ unsigned int fEnclosingScope;
int fFinalSet;
int fBlockSet;
int fMiscFlags;
Index: src/xercesc/util/XMLString.hpp
===================================================================
--- src/xercesc/util/XMLString.hpp (revision 289713)
+++ src/xercesc/util/XMLString.hpp (working copy)
@@ -904,12 +904,14 @@
static char* replicate(const char* const toRep);
/** Replicates a string
- * NOTE: The returned buffer is allocated with the MemoryManager. It is the
+ * NOTE: The returned buffer is dynamically allocated and is the
* responsibility of the caller to delete it when not longer needed.
+ * You can call XMLString::release to release this returned buffer.
*
* @param toRep The string to replicate
* @param manager The MemoryManager to use to allocate the string
* @return Returns a pointer to the replicated string
+ * @see XMLString::release(char**,MemoryManager* const)
*/
static char* replicate(const char* const toRep,
MemoryManager* const manager);
@@ -926,12 +928,14 @@
static XMLCh* replicate(const XMLCh* const toRep);
/** Replicates a string
- * NOTE: The returned buffer is allocated with the MemoryManager. It is the
+ * NOTE: The returned buffer is dynamically allocated and is the
* responsibility of the caller to delete it when not longer needed.
+ * You can call XMLString::release to release this returned buffer.
*
* @param toRep The string to replicate
* @param manager The MemoryManager to use to allocate the string
* @return Returns a pointer to the replicated string
+ * @see XMLString::release(XMLCh**,MemoryManager* const)
*/
static XMLCh* replicate(const XMLCh* const toRep,
MemoryManager* const manager);
@@ -1589,6 +1593,36 @@
*/
static void fixURI(const XMLCh* const str, XMLCh* const target);
+ /**
+ * Release the parameter char string that was allocated by the implementation (i.e.the parser).
+ * The implementation will call manager->deallocate(buf) and then turn the string to a null pointer.
+ *
+ * @param buf The string to be deleted and become a null pointer.
+ * @param manager The MemoryManager to use to release the string.
+ */
+ static void release(char** buf,
+ MemoryManager* const manager);
+
+ /**
+ * Release the parameter XMLCh string that was allocated by the implementation (i.e.the parser).
+ * The implementation will call manager->deallocate(buf) and then turn the string to a null pointer.
+ *
+ * @param buf The string to be deleted and become a null pointer.
+ * @param manager The MemoryManager to use to release the string.
+ */
+ static void release(XMLCh** buf,
+ MemoryManager* const manager);
+
+ /**
+ * Release the parameter XMLByte string that was allocated by the implementation (i.e.the parser).
+ * The implementation will call manager->deallocate(buf) and then turn the string to a null pointer.
+ *
+ * @param buf The string to be deleted and become a null pointer.
+ * @param manager The MemoryManager to use to release the string.
+ */
+ static void release(XMLByte** buf,
+ MemoryManager* const manager);
+
//@}
/** @name String Memory Management functions */
//@{
Index: src/xercesc/util/XMLUri.hpp
===================================================================
--- src/xercesc/util/XMLUri.hpp (revision 289713)
+++ src/xercesc/util/XMLUri.hpp (working copy)
@@ -322,14 +322,16 @@
//helper method for getUriText
void buildFullText();
- // -----------------------------------------------------------------------
- // Private helper methods
- // -----------------------------------------------------------------------
+public:
+ // ---------------------------------------------------------------------------
+ // XMLUri: Public, static methods
+ // ---------------------------------------------------------------------------
+
/**
* Determine whether a character is a reserved character:
*
- * @return true if the string contains any reserved characters
+ * @return true if the character is reserved
*/
static bool isReservedCharacter(const XMLCh theChar);
@@ -467,7 +469,7 @@
* next character to scan in the address, or -1 if the string
* cannot match a valid IPv6 address.
*
- * @param address the string to be scanned
+ * @param addr the string to be scanned
* @param index the beginning index (inclusive)
* @param end the ending index (exclusive)
* @param counter a counter for the number of 16-bit sections read
@@ -478,6 +480,12 @@
*/
static int scanHexSequence (const XMLCh* const addr, int index, int end, int& counter);
+private:
+
+ // -----------------------------------------------------------------------
+ // Private helper methods
+ // -----------------------------------------------------------------------
+
/**
* Get the indicator as to whether this URI uses the "generic URI"
* syntax.
Index: src/xercesc/util/XMLString.cpp
===================================================================
--- src/xercesc/util/XMLString.cpp (revision 289713)
+++ src/xercesc/util/XMLString.cpp (working copy)
@@ -1944,6 +1944,27 @@
*buf = 0;
}
+void XMLString::release(char** buf,
+ MemoryManager* const manager)
+{
+ manager->deallocate(*buf);
+ *buf = 0;
+}
+
+void XMLString::release(XMLCh** buf,
+ MemoryManager* const manager)
+{
+ manager->deallocate(*buf);
+ *buf = 0;
+}
+
+void XMLString::release(XMLByte** buf,
+ MemoryManager* const manager)
+{
+ manager->deallocate(*buf);
+ *buf = 0;
+}
+
// ---------------------------------------------------------------------------
// XMLString: Private static methods
// ---------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]