ASCII constructors for QNames.
authorScott Cantor <cantor.2@osu.edu>
Sat, 28 Apr 2007 18:57:52 +0000 (18:57 +0000)
committerScott Cantor <cantor.2@osu.edu>
Sat, 28 Apr 2007 18:57:52 +0000 (18:57 +0000)
xmltooling/QName.cpp
xmltooling/QName.h

index 194f2c6..29f2714 100644 (file)
@@ -36,6 +36,16 @@ QName::QName(const XMLCh* uri, const XMLCh* localPart, const XMLCh* prefix)
     setPrefix(prefix);
 }
 
+QName::QName(const char* uri, const char* localPart, const char* prefix)
+{
+#ifndef HAVE_GOOD_STL
+    m_uri=m_prefix=m_local=NULL;
+#endif
+    setNamespaceURI(uri);
+    setLocalPart(localPart);
+    setPrefix(prefix);
+}
+
 QName::~QName()
 {
 #ifndef HAVE_GOOD_STL
@@ -87,6 +97,54 @@ void QName::setLocalPart(const XMLCh* localPart)
 #endif
 }
 
+void QName::setPrefix(const char* prefix)
+{
+#ifdef HAVE_GOOD_STL
+    if (prefix) {
+        auto_ptr_XMLCh temp(prefix);
+        m_prefix=temp.get();
+    }
+    else
+        m_prefix.erase();
+#else
+    if (m_prefix)
+        XMLString::release(&m_prefix);
+    m_prefix=XMLString::transcode(prefix);
+#endif
+}
+
+void QName::setNamespaceURI(const char* uri)
+{
+#ifdef HAVE_GOOD_STL
+    if (uri) {
+        auto_ptr_XMLCh temp(uri);
+        m_uri=temp.get();
+    }
+    else
+        m_uri.erase();
+#else
+    if (m_uri)
+        XMLString::release(&m_uri);
+    m_uri=XMLString::transcode(uri);
+#endif
+}
+
+void QName::setLocalPart(const char* localPart)
+{
+#ifdef HAVE_GOOD_STL
+    if (localPart) {
+        auto_ptr_XMLCh temp(localPart);
+        m_local=temp.get();
+    }
+    else
+        m_local.erase();
+#else
+    if (m_local)
+        XMLString::release(&m_local);
+    m_local=XMLString::transcode(localPart);
+#endif
+}
+
 #ifndef HAVE_GOOD_STL
 QName::QName(const QName& src)
 {
index c0e5b95..17d8d77 100644 (file)
@@ -42,11 +42,21 @@ namespace xmltooling {
     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);
+
+        /**
+         * Constructor
+         * 
+         * @param uri       namespace URI
+         * @param localPart local name
+         * @param prefix    namespace prefix (without the colon)
+         */
+        QName(const char* uri, const char* localPart, const char* prefix=NULL);
         
         ~QName();
 #ifndef HAVE_GOOD_STL
@@ -154,6 +164,24 @@ namespace xmltooling {
         void setLocalPart(const XMLCh* localPart);
         
         /**
+         * Sets the namespace prefix
+         * @param prefix    Null-terminated ASCII string containing the prefix, without the colon
+         */
+        void setPrefix(const char* prefix);
+
+        /**
+         * Sets the namespace URI
+         * @param uri  Null-terminated ASCII string containing the URI
+         */
+        void setNamespaceURI(const char* uri);
+        
+        /**
+         * Sets the local part of the name
+         * @param localPart  Null-terminated ASCII string containing the local name
+         */
+        void setLocalPart(const char* localPart);
+        
+        /**
          * Gets a string representation of the QName for logging, etc.
          * Format is prefix:localPart or {namespaceURI}localPart if no prefix.
          *