tng         2003/02/05 10:50:56

  Modified:    c/src/xercesc/util Base64.hpp XMLString.cpp XMLString.hpp
  Log:
  [Bug 11915] Utility for freeing memory.
  
  Revision  Changes    Path
  1.5       +17 -2     xml-xerces/c/src/xercesc/util/Base64.hpp
  
  Index: Base64.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/Base64.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Base64.hpp        4 Nov 2002 15:22:03 -0000       1.4
  +++ Base64.hpp        5 Feb 2003 18:50:56 -0000       1.5
  @@ -84,11 +84,16 @@
       /**
        * Encodes octets into Base64 data
        *
  +     * 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 inputData Binary data in XMLByte stream.
        * @param inputLength Length of the XMLByte stream.
        * @param outputLength Length of the encoded Base64 byte stream.
        * @return Encoded Base64 data in XMLByte stream,
        *      or NULL if input data can not be encoded.
  +     * @see   XMLString::release(XMLByte**)
        */
       static XMLByte* encode(const XMLByte* const inputData,
                              const unsigned int   inputLength,
  @@ -97,10 +102,15 @@
       /**
        * Decodes Base64 data into octets
        *
  +     * 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 inputData Base64 data in XMLByte stream.
        * @param outputLength Length of decoded XMLByte stream.
        * @return Decoded binary data in XMLByte stream,
  -      *      or NULL if input data can not be decoded.
  +     *      or NULL if input data can not be decoded.
  +     * @see   XMLString::release(XMLByte**)
        */
       static XMLByte* decode(const XMLByte* const inputData,
                              unsigned int*        outputLength);
  @@ -108,10 +118,15 @@
       /**
        * Decodes Base64 data into XMLCh
        *
  +     * 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 inputData Base64 data in XMLCh stream.
        * @param outputLength Length of decoded XMLCh stream
        * @return Decoded binary data in XMLCh stream,
        *      or NULL if input data can not be decoded.
  +     * @see   XMLString::release(XMLCh**)
        */
       static XMLCh* decode(const XMLCh* const inputData,
                            unsigned int*      outputLength);
  
  
  
  1.21      +19 -2     xml-xerces/c/src/xercesc/util/XMLString.cpp
  
  Index: XMLString.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLString.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- XMLString.cpp     4 Feb 2003 21:37:45 -0000       1.20
  +++ XMLString.cpp     5 Feb 2003 18:50:56 -0000       1.21
  @@ -1670,7 +1670,7 @@
                ( *startPtr != chLF)    &&
                ( *startPtr != chHTab)  &&
                ( *startPtr != chSpace)  )
  -        {           
  +        {
               *retPtr++ = *startPtr;
           }
   
  @@ -1750,6 +1750,23 @@
       }
   }
   
  +void XMLString::release(char** buf)
  +{
  +    delete [] *buf;
  +    *buf = 0;
  +}
  +
  +void XMLString::release(XMLCh** buf)
  +{
  +    delete [] *buf;
  +    *buf = 0;
  +}
  +
  +void XMLString::release(XMLByte** buf)
  +{
  +    delete [] *buf;
  +    *buf = 0;
  +}
   
   // ---------------------------------------------------------------------------
   //  XMLString: Private static methods
  
  
  
  1.13      +230 -188  xml-xerces/c/src/xercesc/util/XMLString.hpp
  
  Index: XMLString.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLString.hpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XMLString.hpp     24 Jan 2003 23:16:33 -0000      1.12
  +++ XMLString.hpp     5 Feb 2003 18:50:56 -0000       1.13
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.13  2003/02/05 18:50:56  tng
  + * [Bug 11915] Utility for freeing memory.
  + *
    * Revision 1.12  2003/01/24 23:16:33  peiyongz
    * removeWS() added;
    *
  @@ -239,187 +242,7 @@
   {
   public:
       /* Static methods for native character mode string manipulation */
  -    /** @name Conversion functions */
  -    //@{
  -
  -    /** Converts binary data to a text string based a given radix
  -      *
  -      * @param toFormat The beginning of the input string to convert
  -      * @param toFill The buffer that will hold the output on return. The
  -      *        size of this buffer should at least be 'maxChars + 1'.
  -      * @param maxChars The maximum number of output characters that can be
  -      *         accepted. If the result will not fit, it is an error.
  -      * @param radix The radix of the input data, based on which the conversion
  -      * will be done
  -      */
  -    static void binToText
  -    (
  -        const   unsigned int    toFormat
  -        ,       char* const     toFill
  -        , const unsigned int    maxChars
  -        , const unsigned int    radix
  -    );
  -
  -    /** Converts binary data to a text string based a given radix
  -      *
  -      * @param toFormat The beginning of the input string to convert
  -      * @param toFill The buffer that will hold the output on return. The
  -      *        size of this buffer should at least be 'maxChars + 1'.
  -      * @param maxChars The maximum number of output characters that can be
  -      *         accepted. If the result will not fit, it is an error.
  -      * @param radix The radix of the input data, based on which the conversion
  -      * will be done
  -      */
  -    static void binToText
  -    (
  -        const   unsigned int    toFormat
  -        ,       XMLCh* const    toFill
  -        , const unsigned int    maxChars
  -        , const unsigned int    radix
  -    );
  -
  -    /** Converts binary data to a text string based a given radix
  -      *
  -      * @param toFormat The beginning of the input string to convert
  -      * @param toFill The buffer that will hold the output on return. The
  -      *        size of this buffer should at least be 'maxChars + 1'.
  -      * @param maxChars The maximum number of output characters that can be
  -      *         accepted. If the result will not fit, it is an error.
  -      * @param radix The radix of the input data, based on which the conversion
  -      * will be done
  -      */
  -    static void binToText
  -    (
  -        const   unsigned long   toFormat
  -        ,       char* const     toFill
  -        , const unsigned int    maxChars
  -        , const unsigned int    radix
  -    );
   
  -    /** Converts binary data to a text string based a given radix
  -      *
  -      * @param toFormat The beginning of the input string to convert
  -      * @param toFill The buffer that will hold the output on return. The
  -      *        size of this buffer should at least be 'maxChars + 1'.
  -      * @param maxChars The maximum number of output characters that can be
  -      *         accepted. If the result will not fit, it is an error.
  -      * @param radix The radix of the input data, based on which the conversion
  -      * will be done
  -      */
  -    static void binToText
  -    (
  -        const   unsigned long   toFormat
  -        ,       XMLCh* const    toFill
  -        , const unsigned int    maxChars
  -        , const unsigned int    radix
  -    );
  -
  -    /** Converts binary data to a text string based a given radix
  -      *
  -      * @param toFormat The beginning of the input string to convert
  -      * @param toFill The buffer that will hold the output on return. The
  -      *        size of this buffer should at least be 'maxChars + 1'.
  -      * @param maxChars The maximum number of output characters that can be
  -      *         accepted. If the result will not fit, it is an error.
  -      * @param radix The radix of the input data, based on which the conversion
  -      * will be done
  -      */
  -    static void binToText
  -    (
  -        const   long            toFormat
  -        ,       char* const     toFill
  -        , const unsigned int    maxChars
  -        , const unsigned int    radix
  -    );
  -
  -    /** Converts binary data to a text string based a given radix
  -      *
  -      * @param toFormat The beginning of the input string to convert
  -      * @param toFill The buffer that will hold the output on return. The
  -      *        size of this buffer should at least be 'maxChars + 1'.
  -      * @param maxChars The maximum number of output characters that can be
  -      *         accepted. If the result will not fit, it is an error.
  -      * @param radix The radix of the input data, based on which the conversion
  -      * will be done
  -      */
  -    static void binToText
  -    (
  -        const   long            toFormat
  -        ,       XMLCh* const    toFill
  -        , const unsigned int    maxChars
  -        , const unsigned int    radix
  -    );
  -
  -    /** Converts binary data to a text string based a given radix
  -      *
  -      * @param toFormat The beginning of the input string to convert
  -      * @param toFill The buffer that will hold the output on return. The
  -      *        size of this buffer should at least be 'maxChars + 1'.
  -      * @param maxChars The maximum number of output characters that can be
  -      *         accepted. If the result will not fit, it is an error.
  -      * @param radix The radix of the input data, based on which the conversion
  -      * will be done
  -      */
  -    static void binToText
  -    (
  -        const   int             toFormat
  -        ,       char* const     toFill
  -        , const unsigned int    maxChars
  -        , const unsigned int    radix
  -    );
  -
  -    /** Converts binary data to a text string based a given radix
  -      *
  -      * @param toFormat The beginning of the input string to convert
  -      * @param toFill The buffer that will hold the output on return. The
  -      *        size of this buffer should at least be 'maxChars + 1'.
  -      * @param maxChars The maximum number of output characters that can be
  -      *         accepted. If the result will not fit, it is an error.
  -      * @param radix The radix of the input data, based on which the conversion
  -      * will be done
  -      */
  -    static void binToText
  -    (
  -        const   int             toFormat
  -        ,       XMLCh* const    toFill
  -        , const unsigned int    maxChars
  -        , const unsigned int    radix
  -    );
  -
  -    /**
  -      * Converts a string of decimal chars to a binary value
  -      *
  -      * Note that leading and trailng whitespace is legal and will be ignored
  -      * but the remainder must be all decimal digits.
  -      *
  -      * @param toConvert The string of digits to convert
  -      * @param toFill    The unsigned int value to fill with the converted
  -      *                  value.
  -      */
  -    static bool textToBin
  -    (
  -        const   XMLCh* const    toConvert
  -        ,       unsigned int&   toFill
  -    );
  -
  -    /**
  -      * Converts a string of decimal chars to a binary value
  -      *
  -      * Note that leading and trailng whitespace is legal and will be ignored,
  -      *
  -      * Only one and either of (+,-) after the leading whitespace, before
  -      * any other characters are allowed.
  -      *
  -      * but the remainder must be all decimal digits.
  -      *
  -      * @param toConvert The string of digits to convert
  -      */
  -    static int parseInt
  -    (
  -        const   XMLCh* const    toConvert
  -    );
  -
  -    //@}
   
       /** @name String concatenation functions */
       //@{
  @@ -932,7 +755,7 @@
   
       //@}
   
  -         /** @name Substring function */
  +    /** @name Substring function */
       //@{
       /** Create a substring of a givend string. The substring begins at the
         * specified beginIndex and extends to the character at index
  @@ -971,14 +794,24 @@
       /** @name Replication function */
       //@{
       /** Replicates a string
  +      * 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
         * @return Returns a pointer to the replicated string
  +      * @see   XMLString::release(char**)
         */
       static char* replicate(const char* const toRep);
   
       /** Replicates a string
  +      * 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
         * @return Returns a pointer to the replicated string
  +      * @see   XMLString::release(XMLCh**)
         */
       static XMLCh* replicate(const XMLCh* const toRep);
   
  @@ -1172,11 +1005,195 @@
         */
       static bool isAllWhiteSpace(const XMLCh* const toCheck);
   
  +    /** Find is the string appears in the enum list
  +      * @param toFind the string to be found
  +      * @param enumList the list
  +      * return true if found
  +      */
  +    static bool isInList(const XMLCh* const toFind, const XMLCh* const enumList);
  +
       //@}
   
       /** @name Conversion functions */
       //@{
   
  +    /** Converts binary data to a text string based a given radix
  +      *
  +      * @param toFormat The beginning of the input string to convert
  +      * @param toFill The buffer that will hold the output on return. The
  +      *        size of this buffer should at least be 'maxChars + 1'.
  +      * @param maxChars The maximum number of output characters that can be
  +      *         accepted. If the result will not fit, it is an error.
  +      * @param radix The radix of the input data, based on which the conversion
  +      * will be done
  +      */
  +    static void binToText
  +    (
  +        const   unsigned int    toFormat
  +        ,       char* const     toFill
  +        , const unsigned int    maxChars
  +        , const unsigned int    radix
  +    );
  +
  +    /** Converts binary data to a text string based a given radix
  +      *
  +      * @param toFormat The beginning of the input string to convert
  +      * @param toFill The buffer that will hold the output on return. The
  +      *        size of this buffer should at least be 'maxChars + 1'.
  +      * @param maxChars The maximum number of output characters that can be
  +      *         accepted. If the result will not fit, it is an error.
  +      * @param radix The radix of the input data, based on which the conversion
  +      * will be done
  +      */
  +    static void binToText
  +    (
  +        const   unsigned int    toFormat
  +        ,       XMLCh* const    toFill
  +        , const unsigned int    maxChars
  +        , const unsigned int    radix
  +    );
  +
  +    /** Converts binary data to a text string based a given radix
  +      *
  +      * @param toFormat The beginning of the input string to convert
  +      * @param toFill The buffer that will hold the output on return. The
  +      *        size of this buffer should at least be 'maxChars + 1'.
  +      * @param maxChars The maximum number of output characters that can be
  +      *         accepted. If the result will not fit, it is an error.
  +      * @param radix The radix of the input data, based on which the conversion
  +      * will be done
  +      */
  +    static void binToText
  +    (
  +        const   unsigned long   toFormat
  +        ,       char* const     toFill
  +        , const unsigned int    maxChars
  +        , const unsigned int    radix
  +    );
  +
  +    /** Converts binary data to a text string based a given radix
  +      *
  +      * @param toFormat The beginning of the input string to convert
  +      * @param toFill The buffer that will hold the output on return. The
  +      *        size of this buffer should at least be 'maxChars + 1'.
  +      * @param maxChars The maximum number of output characters that can be
  +      *         accepted. If the result will not fit, it is an error.
  +      * @param radix The radix of the input data, based on which the conversion
  +      * will be done
  +      */
  +    static void binToText
  +    (
  +        const   unsigned long   toFormat
  +        ,       XMLCh* const    toFill
  +        , const unsigned int    maxChars
  +        , const unsigned int    radix
  +    );
  +
  +    /** Converts binary data to a text string based a given radix
  +      *
  +      * @param toFormat The beginning of the input string to convert
  +      * @param toFill The buffer that will hold the output on return. The
  +      *        size of this buffer should at least be 'maxChars + 1'.
  +      * @param maxChars The maximum number of output characters that can be
  +      *         accepted. If the result will not fit, it is an error.
  +      * @param radix The radix of the input data, based on which the conversion
  +      * will be done
  +      */
  +    static void binToText
  +    (
  +        const   long            toFormat
  +        ,       char* const     toFill
  +        , const unsigned int    maxChars
  +        , const unsigned int    radix
  +    );
  +
  +    /** Converts binary data to a text string based a given radix
  +      *
  +      * @param toFormat The beginning of the input string to convert
  +      * @param toFill The buffer that will hold the output on return. The
  +      *        size of this buffer should at least be 'maxChars + 1'.
  +      * @param maxChars The maximum number of output characters that can be
  +      *         accepted. If the result will not fit, it is an error.
  +      * @param radix The radix of the input data, based on which the conversion
  +      * will be done
  +      */
  +    static void binToText
  +    (
  +        const   long            toFormat
  +        ,       XMLCh* const    toFill
  +        , const unsigned int    maxChars
  +        , const unsigned int    radix
  +    );
  +
  +    /** Converts binary data to a text string based a given radix
  +      *
  +      * @param toFormat The beginning of the input string to convert
  +      * @param toFill The buffer that will hold the output on return. The
  +      *        size of this buffer should at least be 'maxChars + 1'.
  +      * @param maxChars The maximum number of output characters that can be
  +      *         accepted. If the result will not fit, it is an error.
  +      * @param radix The radix of the input data, based on which the conversion
  +      * will be done
  +      */
  +    static void binToText
  +    (
  +        const   int             toFormat
  +        ,       char* const     toFill
  +        , const unsigned int    maxChars
  +        , const unsigned int    radix
  +    );
  +
  +    /** Converts binary data to a text string based a given radix
  +      *
  +      * @param toFormat The beginning of the input string to convert
  +      * @param toFill The buffer that will hold the output on return. The
  +      *        size of this buffer should at least be 'maxChars + 1'.
  +      * @param maxChars The maximum number of output characters that can be
  +      *         accepted. If the result will not fit, it is an error.
  +      * @param radix The radix of the input data, based on which the conversion
  +      * will be done
  +      */
  +    static void binToText
  +    (
  +        const   int             toFormat
  +        ,       XMLCh* const    toFill
  +        , const unsigned int    maxChars
  +        , const unsigned int    radix
  +    );
  +
  +    /**
  +      * Converts a string of decimal chars to a binary value
  +      *
  +      * Note that leading and trailng whitespace is legal and will be ignored
  +      * but the remainder must be all decimal digits.
  +      *
  +      * @param toConvert The string of digits to convert
  +      * @param toFill    The unsigned int value to fill with the converted
  +      *                  value.
  +      */
  +    static bool textToBin
  +    (
  +        const   XMLCh* const    toConvert
  +        ,       unsigned int&   toFill
  +    );
  +
  +    /**
  +      * Converts a string of decimal chars to a binary value
  +      *
  +      * Note that leading and trailng whitespace is legal and will be ignored,
  +      *
  +      * Only one and either of (+,-) after the leading whitespace, before
  +      * any other characters are allowed.
  +      *
  +      * but the remainder must be all decimal digits.
  +      *
  +      * @param toConvert The string of digits to convert
  +      */
  +    static int parseInt
  +    (
  +        const   XMLCh* const    toConvert
  +    );
  +
       /** Cut leading chars from a string
         *
         * @param toCutFrom The string to cut chars from
  @@ -1192,9 +1209,11 @@
         *
         * 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 toTranscode The string to be transcoded
         * @return Returns the transcoded string
  +      * @see   XMLString::release(XMLCh**)
         */
       static char* transcode
       (
  @@ -1228,9 +1247,11 @@
         *
         * 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 toTranscode The string to be transcoded
         * @return Returns the transcoded string
  +      * @see   XMLString::release(char**)
         */
       static XMLCh* transcode
       (
  @@ -1277,13 +1298,6 @@
         */
       static BaseRefVectorOf<XMLCh>* tokenizeString(const XMLCh* const tokenizeSrc);
   
  -    /** Find is the string appears in the enum list
  -      * @param toFind the string to be found
  -      * @param enumList the list
  -      * return true if found
  -      */
  -    static bool isInList(const XMLCh* const toFind, const XMLCh* const enumList);
  -
       //@}
   
       /** @name Formatting functions */
  @@ -1375,6 +1389,34 @@
        * @param target The target string pre-allocated to store the fixed uri
        */
       static void fixURI(const XMLCh* const str, XMLCh* const target);
  +
  +    //@}
  +    /** @name String Memory Management functions */
  +    //@{
  +    /**
  +     * Release the parameter char string that was allocated by the implementation 
(i.e.the parser).
  +     *   The implementation will call operator delete[] and then turn the string to 
a null pointer.
  +     *
  +     * @param buf  The string to be deleted and become a null pointer.
  +     */
  +    static void release(char** buf);
  +
  +    /**
  +     * Release the parameter XMLCh string that was allocated by the implementation 
(i.e.the parser).
  +     *   The implementation will call operator delete[] and then turn the string to 
a null pointer.
  +     *
  +     * @param buf  The string to be deleted and become a null pointer.
  +     */
  +    static void release(XMLCh** buf);
  +
  +    /**
  +     * Release the parameter XMLByte string that was allocated by the 
implementation (i.e.the parser).
  +     *   The implementation will call operator delete[] and then turn the string to 
a null pointer.
  +     *
  +     * @param buf  The string to be deleted and become a null pointer.
  +     */
  +    static void release(XMLByte** buf);
  +
       //@}
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to