gcc const fix, converted linefeeds
[shibboleth/cpp-xmltooling.git] / xmltooling / QName.h
index c26e900..ac17d27 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 QName.h\r
- * \r
- * Representing XML QNames \r
- */\r
-\r
-#if !defined(__xmltooling_qname_h__)\r
-#define __xmltooling_qname_h__\r
-\r
-#include <algorithm>\r
-#include <xmltooling/unicode.h>\r
-\r
-namespace xmltooling {\r
-    \r
-    /**\r
-     * A data structure for encapsulating XML QNames.\r
-     * The Xerces class is too limited to use at the moment.\r
-     */\r
-    class XMLTOOL_API QName\r
-    {\r
-    public:\r
-        /**\r
-         * Constructor\r
-         * @param uri       namespace URI\r
-         * @param localPart local name\r
-         * @param prefix    namespace prefix (without the colon)\r
-         */\r
-        QName(const XMLCh* uri=NULL, const XMLCh* localPart=NULL, const XMLCh* prefix=NULL);\r
-        \r
-        ~QName();\r
-#ifndef HAVE_GOOD_STL\r
-        /**\r
-         * Deep copy constructor\r
-         */\r
-        QName(const QName& src);\r
-\r
-        /**\r
-         * Deep assignment operator\r
-         */\r
-        QName& operator=(const QName& src);\r
-#endif\r
-        \r
-#ifdef HAVE_GOOD_STL\r
-        /**\r
-         * Indicates whether the QName has a prefix.\r
-         * @return  true iff the prefix is non-empty\r
-         */\r
-        bool hasPrefix() const { return !m_prefix.empty(); }\r
-\r
-        /**\r
-         * Indicates whether the QName has a non-empty namespace.\r
-         * @return  true iff the namespace is non-empty\r
-         */\r
-        bool hasNamespaceURI() const { return !m_uri.empty(); }\r
-\r
-        /**\r
-         * Indicates whether the QName has a non-empty local name.\r
-         * @return  true iff the local name is non-empty\r
-         */\r
-        bool hasLocalPart() const { return !m_local.empty(); }\r
-\r
-        /**\r
-         * Returns the namespace prefix\r
-         * @return  Null-terminated Unicode string containing the prefix, without the colon\r
-         */\r
-        const XMLCh* getPrefix() const { return m_prefix.c_str(); }\r
-\r
-        /**\r
-         * Returns the namespace URI\r
-         * @return  Null-terminated Unicode string containing the URI\r
-         */\r
-        const XMLCh* getNamespaceURI() const { return m_uri.c_str(); }\r
-\r
-        /**\r
-         * Returns the local part of the name\r
-         * @return  Null-terminated Unicode string containing the local name\r
-         */\r
-        const XMLCh* getLocalPart() const { return m_local.c_str(); }\r
-#else\r
-        /**\r
-         * Indicates whether the QName has a prefix.\r
-         * @return  true iff the prefix is non-empty\r
-         */\r
-        bool hasPrefix() const { return m_prefix && *m_prefix; }\r
-\r
-        /**\r
-         * Indicates whether the QName has a non-empty namespace.\r
-         * @return  true iff the namespace is non-empty\r
-         */\r
-        bool hasNamespaceURI() const { return m_uri && *m_uri; }\r
-\r
-        /**\r
-         * Indicates whether the QName has a non-empty local name.\r
-         * @return  true iff the local name is non-empty\r
-         */\r
-        bool hasLocalPart() const { return m_local && *m_local; }\r
-\r
-        /**\r
-         * Returns the namespace prefix\r
-         * @return  Null-terminated Unicode string containing the prefix, without the colon\r
-         */\r
-        const XMLCh* getPrefix() const { return m_prefix; }\r
-\r
-        /**\r
-         * Returns the namespace URI\r
-         * @return  Null-terminated Unicode string containing the URI\r
-         */\r
-        const XMLCh* getNamespaceURI() const { return m_uri; }\r
-\r
-        /**\r
-         * Returns the local part of the name\r
-         * @return  Null-terminated Unicode string containing the local name\r
-         */\r
-        const XMLCh* getLocalPart() const { return m_local; }\r
-#endif\r
-\r
-        /**\r
-         * Sets the namespace prefix\r
-         * @param prefix    Null-terminated Unicode string containing the prefix, without the colon\r
-         */\r
-        void setPrefix(const XMLCh* prefix);\r
-\r
-        /**\r
-         * Sets the namespace URI\r
-         * @param uri  Null-terminated Unicode string containing the URI\r
-         */\r
-        void setNamespaceURI(const XMLCh* uri);\r
-        \r
-        /**\r
-         * Sets the local part of the name\r
-         * @param localPart  Null-terminated Unicode string containing the local name\r
-         */\r
-        void setLocalPart(const XMLCh* localPart);\r
-        \r
-        /**\r
-         * Gets a string representation of the QName for logging, etc.\r
-         * Format is prefix:localPart or {namespaceURI}localPart if no prefix.\r
-         * \r
-         * @return the string representation\r
-         */\r
-        std::string toString() const;\r
-        \r
-    private:\r
-#ifdef HAVE_GOOD_STL\r
-        xstring m_uri;\r
-        xstring m_local;\r
-        xstring m_prefix;\r
-#else\r
-        XMLCh* m_uri;\r
-        XMLCh* m_local;\r
-        XMLCh* m_prefix;\r
-#endif\r
-    };\r
-\r
-    /**\r
-     * Returns true iff op1's namespace lexically compares less than op2's namespace,\r
-     * or if equal, iff op1's prefix lexically compares less than op2's prefix.\r
-     * \r
-     * Needed for use with sorted STL containers.\r
-     * \r
-     * @param op1   First qname to compare\r
-     * @param op2   Second qname to compare\r
-     */\r
-    extern XMLTOOL_API bool operator<(const QName& op1, const QName& op2);\r
-\r
-    /**\r
-     * Returns true iff op1's components are equal to op2's components, excluding prefix.\r
-     * @param op1   First qname to compare\r
-     * @param op2   Second qname to compare\r
-     */\r
-    extern XMLTOOL_API bool operator==(const QName& op1, const QName& op2);\r
-\r
-    /**\r
-     * Returns true iff op1's components are not equal to op2's components, excluding prefix.\r
-     * @param op1   First qname to compare\r
-     * @param op2   Second qname to compare\r
-     */\r
-    extern XMLTOOL_API bool operator!=(const QName& op1, const QName& op2);\r
-\r
-};\r
-\r
-#endif /* __xmltooling_qname_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 QName.h
+ * 
+ * Representing XML QNames 
+ */
+
+#if !defined(__xmltooling_qname_h__)
+#define __xmltooling_qname_h__
+
+#include <algorithm>
+#include <xmltooling/unicode.h>
+
+namespace xmltooling {
+    
+    /**
+     * A data structure for encapsulating XML QNames.
+     * The Xerces class is too limited to use at the moment.
+     */
+    class XMLTOOL_API QName
+    {
+    public:
+        /**
+         * Constructor
+         * @param uri       namespace URI
+         * @param localPart local name
+         * @param prefix    namespace prefix (without the colon)
+         */
+        QName(const XMLCh* uri=NULL, const XMLCh* localPart=NULL, const XMLCh* prefix=NULL);
+        
+        ~QName();
+#ifndef HAVE_GOOD_STL
+        /**
+         * Deep copy constructor
+         */
+        QName(const QName& src);
+
+        /**
+         * Deep assignment operator
+         */
+        QName& operator=(const QName& src);
+#endif
+        
+#ifdef HAVE_GOOD_STL
+        /**
+         * Indicates whether the QName has a prefix.
+         * @return  true iff the prefix is non-empty
+         */
+        bool hasPrefix() const { return !m_prefix.empty(); }
+
+        /**
+         * Indicates whether the QName has a non-empty namespace.
+         * @return  true iff the namespace is non-empty
+         */
+        bool hasNamespaceURI() const { return !m_uri.empty(); }
+
+        /**
+         * Indicates whether the QName has a non-empty local name.
+         * @return  true iff the local name is non-empty
+         */
+        bool hasLocalPart() const { return !m_local.empty(); }
+
+        /**
+         * Returns the namespace prefix
+         * @return  Null-terminated Unicode string containing the prefix, without the colon
+         */
+        const XMLCh* getPrefix() const { return m_prefix.c_str(); }
+
+        /**
+         * Returns the namespace URI
+         * @return  Null-terminated Unicode string containing the URI
+         */
+        const XMLCh* getNamespaceURI() const { return m_uri.c_str(); }
+
+        /**
+         * Returns the local part of the name
+         * @return  Null-terminated Unicode string containing the local name
+         */
+        const XMLCh* getLocalPart() const { return m_local.c_str(); }
+#else
+        /**
+         * Indicates whether the QName has a prefix.
+         * @return  true iff the prefix is non-empty
+         */
+        bool hasPrefix() const { return m_prefix && *m_prefix; }
+
+        /**
+         * Indicates whether the QName has a non-empty namespace.
+         * @return  true iff the namespace is non-empty
+         */
+        bool hasNamespaceURI() const { return m_uri && *m_uri; }
+
+        /**
+         * Indicates whether the QName has a non-empty local name.
+         * @return  true iff the local name is non-empty
+         */
+        bool hasLocalPart() const { return m_local && *m_local; }
+
+        /**
+         * Returns the namespace prefix
+         * @return  Null-terminated Unicode string containing the prefix, without the colon
+         */
+        const XMLCh* getPrefix() const { return m_prefix; }
+
+        /**
+         * Returns the namespace URI
+         * @return  Null-terminated Unicode string containing the URI
+         */
+        const XMLCh* getNamespaceURI() const { return m_uri; }
+
+        /**
+         * Returns the local part of the name
+         * @return  Null-terminated Unicode string containing the local name
+         */
+        const XMLCh* getLocalPart() const { return m_local; }
+#endif
+
+        /**
+         * Sets the namespace prefix
+         * @param prefix    Null-terminated Unicode string containing the prefix, without the colon
+         */
+        void setPrefix(const XMLCh* prefix);
+
+        /**
+         * Sets the namespace URI
+         * @param uri  Null-terminated Unicode string containing the URI
+         */
+        void setNamespaceURI(const XMLCh* uri);
+        
+        /**
+         * Sets the local part of the name
+         * @param localPart  Null-terminated Unicode string containing the local name
+         */
+        void setLocalPart(const XMLCh* localPart);
+        
+        /**
+         * Gets a string representation of the QName for logging, etc.
+         * Format is prefix:localPart or {namespaceURI}localPart if no prefix.
+         * 
+         * @return the string representation
+         */
+        std::string toString() const;
+        
+    private:
+#ifdef HAVE_GOOD_STL
+        xstring m_uri;
+        xstring m_local;
+        xstring m_prefix;
+#else
+        XMLCh* m_uri;
+        XMLCh* m_local;
+        XMLCh* m_prefix;
+#endif
+    };
+
+    /**
+     * Returns true iff op1's namespace lexically compares less than op2's namespace,
+     * or if equal, iff op1's prefix lexically compares less than op2's prefix.
+     * 
+     * Needed for use with sorted STL containers.
+     * 
+     * @param op1   First qname to compare
+     * @param op2   Second qname to compare
+     */
+    extern XMLTOOL_API bool operator<(const QName& op1, const QName& op2);
+
+    /**
+     * Returns true iff op1's components are equal to op2's components, excluding prefix.
+     * @param op1   First qname to compare
+     * @param op2   Second qname to compare
+     */
+    extern XMLTOOL_API bool operator==(const QName& op1, const QName& op2);
+
+    /**
+     * Returns true iff op1's components are not equal to op2's components, excluding prefix.
+     * @param op1   First qname to compare
+     * @param op2   Second qname to compare
+     */
+    extern XMLTOOL_API bool operator!=(const QName& op1, const QName& op2);
+
+};
+
+#endif /* __xmltooling_qname_h__ */