Added typename to template
authorScott Cantor <cantor.2@osu.edu>
Thu, 2 Mar 2006 22:06:15 +0000 (22:06 +0000)
committerScott Cantor <cantor.2@osu.edu>
Thu, 2 Mar 2006 22:06:15 +0000 (22:06 +0000)
xmltooling/base.h

index 5194776..2fbfda4 100644 (file)
-/*\r
- *  Copyright 2001-2006 Internet2\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * @file base.h\r
- * \r
- * Base header file definitions\r
- * Must be included prior to including any other header\r
- */\r
-\r
-#if !defined(__xmltooling_base_h__)\r
-#define __xmltooling_base_h__\r
-\r
-#if defined (_MSC_VER) || defined(__BORLANDC__)\r
-  #include <xmltooling/config_pub_win32.h>\r
-#else\r
-  #include <xmltooling/config_pub.h>\r
-#endif\r
-\r
-/**\r
- * @namespace xmltooling\r
- * Public namespace of XML Tooling library\r
- */\r
-\r
-// Windows and GCC4 Symbol Visibility Macros\r
-\r
-#ifdef WIN32\r
-  #define XMLTOOL_IMPORT __declspec(dllimport)\r
-  #define XMLTOOL_EXPORT __declspec(dllexport)\r
-  #define XMLTOOL_DLLLOCAL\r
-  #define XMLTOOL_DLLPUBLIC\r
-#else\r
-  #define XMLTOOL_IMPORT\r
-  #ifdef GCC_HASCLASSVISIBILITY\r
-    #define XMLTOOL_EXPORT __attribute__ ((visibility("default")))\r
-    #define XMLTOOL_DLLLOCAL __attribute__ ((visibility("hidden")))\r
-    #define XMLTOOL_DLLPUBLIC __attribute__ ((visibility("default")))\r
-  #else\r
-    #define XMLTOOL_EXPORT\r
-    #define XMLTOOL_DLLLOCAL\r
-    #define XMLTOOL_DLLPUBLIC\r
-  #endif\r
-#endif\r
-\r
-// Define XMLTOOL_API for DLL builds\r
-#ifdef XMLTOOLING_EXPORTS\r
-  #define XMLTOOL_API XMLTOOL_EXPORT\r
-#else\r
-  #define XMLTOOL_API XMLTOOL_IMPORT\r
-#endif\r
-\r
-// Throwable classes must always be visible on GCC in all binaries\r
-#ifdef WIN32\r
-  #define XMLTOOL_EXCEPTIONAPI(api) api\r
-#elif defined(GCC_HASCLASSVISIBILITY)\r
-  #define XMLTOOL_EXCEPTIONAPI(api) XMLTOOL_EXPORT\r
-#else\r
-  #define XMLTOOL_EXCEPTIONAPI(api)\r
-#endif\r
-\r
-// Macro to block copy c'tor and assignment operator for a class\r
-#define MAKE_NONCOPYABLE(type) \\r
-    private: \\r
-        type(const type&); \\r
-        type& operator=(const type&);\r
-\r
-#ifndef NULL\r
-#define NULL    0\r
-#endif\r
-\r
-#include <utility>\r
-\r
-namespace xmltooling {\r
-\r
-    /**\r
-     * Template function for cloning a sequence of XMLObjects.\r
-     * Invokes the clone() member on each element of the input sequence and adds the copy to\r
-     * the output sequence. Order is preserved.\r
-     * \r
-     * @param in    input sequence to clone\r
-     * @param out   output sequence to copy cloned pointers into\r
-     */\r
-    template<class InputSequence,class OutputSequence> void clone(const InputSequence& in, OutputSequence& out) {\r
-        for (InputSequence::const_iterator i=in.begin(); i!=in.end(); i++)\r
-            out.push_back((*i)->clone());\r
-    }\r
-\r
-    /*\r
-     * Functor for cleaning up heap objects in containers.\r
-     */\r
-    template<class T> struct cleanup\r
-    {\r
-        /**\r
-         * Function operator to delete an object.\r
-         * \r
-         * @param ptr   object to delete\r
-         */\r
-        void operator()(T* ptr) {delete ptr;}\r
-        \r
-        /**\r
-         * Function operator to delete an object stored as const.\r
-         * \r
-         * @param ptr   object to delete after casting away const\r
-         */\r
-        void operator()(const T* ptr) {delete const_cast<T*>(ptr);}\r
-    };\r
-\r
-    /*\r
-     * Functor for cleaning up heap objects in key/value containers.\r
-     */\r
-    template<class A,class B> struct cleanup_pair\r
-    {\r
-        /**\r
-         * Function operator to delete an object.\r
-         * \r
-         * @param p   a pair in which the second component is the object to delete\r
-         */\r
-        void operator()(const std::pair<A,B*>& p) {delete p.second;}\r
-    };\r
-};\r
-\r
-#endif /* __xmltooling_base_h__ */\r
+/*
+ *  Copyright 2001-2006 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file base.h
+ * 
+ * Base header file definitions
+ * Must be included prior to including any other header
+ */
+
+#if !defined(__xmltooling_base_h__)
+#define __xmltooling_base_h__
+
+#if defined (_MSC_VER) || defined(__BORLANDC__)
+  #include <xmltooling/config_pub_win32.h>
+#else
+  #include <xmltooling/config_pub.h>
+#endif
+
+/**
+ * @namespace xmltooling
+ * Public namespace of XML Tooling library
+ */
+
+// Windows and GCC4 Symbol Visibility Macros
+
+#ifdef WIN32
+  #define XMLTOOL_IMPORT __declspec(dllimport)
+  #define XMLTOOL_EXPORT __declspec(dllexport)
+  #define XMLTOOL_DLLLOCAL
+  #define XMLTOOL_DLLPUBLIC
+#else
+  #define XMLTOOL_IMPORT
+  #ifdef GCC_HASCLASSVISIBILITY
+    #define XMLTOOL_EXPORT __attribute__ ((visibility("default")))
+    #define XMLTOOL_DLLLOCAL __attribute__ ((visibility("hidden")))
+    #define XMLTOOL_DLLPUBLIC __attribute__ ((visibility("default")))
+  #else
+    #define XMLTOOL_EXPORT
+    #define XMLTOOL_DLLLOCAL
+    #define XMLTOOL_DLLPUBLIC
+  #endif
+#endif
+
+// Define XMLTOOL_API for DLL builds
+#ifdef XMLTOOLING_EXPORTS
+  #define XMLTOOL_API XMLTOOL_EXPORT
+#else
+  #define XMLTOOL_API XMLTOOL_IMPORT
+#endif
+
+// Throwable classes must always be visible on GCC in all binaries
+#ifdef WIN32
+  #define XMLTOOL_EXCEPTIONAPI(api) api
+#elif defined(GCC_HASCLASSVISIBILITY)
+  #define XMLTOOL_EXCEPTIONAPI(api) XMLTOOL_EXPORT
+#else
+  #define XMLTOOL_EXCEPTIONAPI(api)
+#endif
+
+// Macro to block copy c'tor and assignment operator for a class
+#define MAKE_NONCOPYABLE(type) \
+    private: \
+        type(const type&); \
+        type& operator=(const type&);
+
+#ifndef NULL
+#define NULL    0
+#endif
+
+#include <utility>
+
+namespace xmltooling {
+
+    /**
+     * Template function for cloning a sequence of XMLObjects.
+     * Invokes the clone() member on each element of the input sequence and adds the copy to
+     * the output sequence. Order is preserved.
+     * 
+     * @param in    input sequence to clone
+     * @param out   output sequence to copy cloned pointers into
+     */
+    template<class InputSequence,class OutputSequence> void clone(const InputSequence& in, OutputSequence& out) {
+        for (typename InputSequence::const_iterator i=in.begin(); i!=in.end(); i++)
+            out.push_back((*i)->clone());
+    }
+
+    /*
+     * Functor for cleaning up heap objects in containers.
+     */
+    template<class T> struct cleanup
+    {
+        /**
+         * Function operator to delete an object.
+         * 
+         * @param ptr   object to delete
+         */
+        void operator()(T* ptr) {delete ptr;}
+        
+        /**
+         * Function operator to delete an object stored as const.
+         * 
+         * @param ptr   object to delete after casting away const
+         */
+        void operator()(const T* ptr) {delete const_cast<T*>(ptr);}
+    };
+
+    /*
+     * Functor for cleaning up heap objects in key/value containers.
+     */
+    template<class A,class B> struct cleanup_pair
+    {
+        /**
+         * Function operator to delete an object.
+         * 
+         * @param p   a pair in which the second component is the object to delete
+         */
+        void operator()(const std::pair<A,B*>& p) {delete p.second;}
+    };
+};
+
+#endif /* __xmltooling_base_h__ */