Add default constructors.
authorcantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Tue, 3 Feb 2009 22:46:41 +0000 (22:46 +0000)
committercantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Tue, 3 Feb 2009 22:46:41 +0000 (22:46 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1@558 de75baf8-a10c-0410-a50a-987c0e22f00f

xmltooling/unicode.h

index 6cc8763..06f79ee 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *  Copyright 2001-2007 Internet2
- * 
+ *  Copyright 2001-2009 Internet2
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 /**
  * @file xmltooling/unicode.h
- * 
+ *
  * Helper classes and types for manipulating Unicode
  */
+
 #ifndef __xmltooling_unicode_h__
 #define __xmltooling_unicode_h__
 
@@ -30,7 +30,7 @@
 #include <xercesc/util/XMLString.hpp>
 
 namespace xmltooling {
-    
+
     #ifdef HAVE_GOOD_STL
         /**
          * An STL string type that supports 16-bit Unicode.
@@ -41,25 +41,25 @@ namespace xmltooling {
 
     /**
      * Transcodes a 16-bit Unicode string into UTF-8.
-     * 
+     *
      * @param src           the 16-bit string to transcode
      * @param use_malloc    true iff the result should be allocated with malloc, false to use new
-     * @return      a UTF-8 string allocated by the Xerces memory manager 
+     * @return      a UTF-8 string allocated by the Xerces memory manager
      */
     extern XMLTOOL_API char* toUTF8(const XMLCh* src, bool use_malloc=false);
 
     /**
      * Transcodes a UTF-8 string into 16-bit Unicode.
-     * 
+     *
      * @param src           the UTF-8 string to transcode
      * @param use_malloc    true iff the result should be allocated with malloc, false to use new
-     * @return      a 16-bit Unicode string allocated by the Xerces memory manager 
+     * @return      a 16-bit Unicode string allocated by the Xerces memory manager
      */
     extern XMLTOOL_API XMLCh* fromUTF8(const char* src, bool use_malloc=false);
 
     /**
      * Writes a Unicode string to an ASCII stream by transcoding to UTF8.
-     * 
+     *
      * @param ostr  stream to write to
      * @param s     string to write
      * @return      reference to output stream
@@ -69,18 +69,24 @@ namespace xmltooling {
     /**
      * A minimal auto_ptr-like class that can copy or transcode a buffer into
      * the local code page and free the result automatically.
-     * 
+     *
      * Needed because a standard auto_ptr would use delete on the resulting
-     * pointer. 
+     * pointer.
      */
     class XMLTOOL_API auto_ptr_char
     {
         MAKE_NONCOPYABLE(auto_ptr_char);
     public:
         /**
+         * Default constructor.
+         */
+        auto_ptr_char() : m_buf(NULL) {
+        }
+
+        /**
          * Constructor transcodes a 16-bit Unicode string into the local code page (NOT UTF-8) and wraps the result.
          * @param src   the 16-bit string to transcode and wrap
-         * @param trim  trims leading/trailing whitespace from the result (defaults to true) 
+         * @param trim  trims leading/trailing whitespace from the result (defaults to true)
          */
         auto_ptr_char(const XMLCh* src, bool trim=true) : m_buf(xercesc::XMLString::transcode(src)) {
             if (trim && m_buf) xercesc::XMLString::trim(m_buf);
@@ -89,7 +95,7 @@ namespace xmltooling {
         /**
          * Constructor copies a local code page (NOT UTF-8) string and wraps the result.
          * @param src   the local string to copy and wrap
-         * @param trim  trims leading/trailing whitespace from the result (defaults to true) 
+         * @param trim  trims leading/trailing whitespace from the result (defaults to true)
          */
         auto_ptr_char(const char* src, bool trim=true) : m_buf(xercesc::XMLString::replicate(src)) {
             if (trim && m_buf) xercesc::XMLString::trim(m_buf);
@@ -118,25 +124,31 @@ namespace xmltooling {
             char* temp=m_buf; m_buf=NULL; return temp;
         }
 
-    private:    
+    private:
         char* m_buf;
     };
 
     /**
      * A minimal auto_ptr-like class that can copy or transcode a buffer into
      * 16-bit Unicode and free the result automatically.
-     * 
+     *
      * Needed because a standard auto_ptr would use delete on the resulting
-     * pointer. 
+     * pointer.
      */
     class XMLTOOL_API auto_ptr_XMLCh
     {
         MAKE_NONCOPYABLE(auto_ptr_XMLCh);
     public:
         /**
+         * Default constructor.
+         */
+        auto_ptr_XMLCh() : m_buf(NULL) {
+        }
+
+        /**
          * Constructor transcodes a local code page (NOT UTF-8) string into 16-bit Unicode and wraps the result.
          * @param src   the local string to transcode and wrap
-         * @param trim  trims leading/trailing whitespace from the result (defaults to true) 
+         * @param trim  trims leading/trailing whitespace from the result (defaults to true)
          */
         auto_ptr_XMLCh(const char* src, bool trim=true) : m_buf(xercesc::XMLString::transcode(src)) {
             if (trim && m_buf) xercesc::XMLString::trim(m_buf);
@@ -145,7 +157,7 @@ namespace xmltooling {
         /**
          * Constructor copies a 16-bit Unicode string and wraps the result.
          * @param src   the Unicode string to copy and wrap
-         * @param trim  trims leading/trailing whitespace from the result (defaults to true) 
+         * @param trim  trims leading/trailing whitespace from the result (defaults to true)
          */
         auto_ptr_XMLCh(const XMLCh* src, bool trim=true) : m_buf(xercesc::XMLString::replicate(src)) {
             if (trim && m_buf) xercesc::XMLString::trim(m_buf);
@@ -165,7 +177,7 @@ namespace xmltooling {
         const XMLCh* get() const {
             return m_buf;
         }
-        
+
         /**
          * Returns the wrapped buffer and transfers ownership of it to the caller.
          * @return a null-terminated Unicode string