X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=blobdiff_plain;f=xmltooling%2FQName.cpp;h=d80d1a8747d20c091d4d62cf31b7f9fcc0c45ad8;hp=194f2c629e51fa060f1778ba13ef122b4e44bfea;hb=HEAD;hpb=5cb314df178f78c6fa7b9826c2c5a5298ec7a473 diff --git a/xmltooling/QName.cpp b/xmltooling/QName.cpp index 194f2c6..d80d1a8 100644 --- a/xmltooling/QName.cpp +++ b/xmltooling/QName.cpp @@ -1,17 +1,21 @@ -/* - * Copyright 2001-2007 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 +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + * + * UCAID licenses this file to you 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 + * 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. + * 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. */ /** @@ -26,11 +30,17 @@ using namespace xmltooling; using namespace std; +using xercesc::XMLString; + QName::QName(const XMLCh* uri, const XMLCh* localPart, const XMLCh* prefix) { -#ifndef HAVE_GOOD_STL - m_uri=m_prefix=m_local=NULL; -#endif + setNamespaceURI(uri); + setLocalPart(localPart); + setPrefix(prefix); +} + +QName::QName(const char* uri, const char* localPart, const char* prefix) +{ setNamespaceURI(uri); setLocalPart(localPart); setPrefix(prefix); @@ -38,74 +48,66 @@ QName::QName(const XMLCh* uri, const XMLCh* localPart, const XMLCh* prefix) QName::~QName() { -#ifndef HAVE_GOOD_STL - XMLString::release(&m_uri); - XMLString::release(&m_prefix); - XMLString::release(&m_local); -#endif } void QName::setPrefix(const XMLCh* prefix) { -#ifdef HAVE_GOOD_STL if (prefix) m_prefix=prefix; else m_prefix.erase(); -#else - if (m_prefix) - XMLString::release(&m_prefix); - m_prefix=XMLString::replicate(prefix); -#endif } void QName::setNamespaceURI(const XMLCh* uri) { -#ifdef HAVE_GOOD_STL if (uri) m_uri=uri; else m_uri.erase(); -#else - if (m_uri) - XMLString::release(&m_uri); - m_uri=XMLString::replicate(uri); -#endif } void QName::setLocalPart(const XMLCh* localPart) { -#ifdef HAVE_GOOD_STL if (localPart) m_local=localPart; else m_local.erase(); -#else - if (m_local) - XMLString::release(&m_local); - m_local=XMLString::replicate(localPart); -#endif } -#ifndef HAVE_GOOD_STL -QName::QName(const QName& src) +void QName::setPrefix(const char* prefix) { - m_uri=XMLString::replicate(src.getNamespaceURI()); - m_prefix=XMLString::replicate(src.getPrefix()); - m_local=XMLString::replicate(src.getLocalPart()); + if (prefix) { + auto_ptr_XMLCh temp(prefix); + m_prefix=temp.get(); + } + else + m_prefix.erase(); } -QName& QName::operator=(const QName& src) +void QName::setNamespaceURI(const char* uri) { - m_uri=XMLString::replicate(src.getNamespaceURI()); - m_prefix=XMLString::replicate(src.getPrefix()); - m_local=XMLString::replicate(src.getLocalPart()); - return *this; + if (uri) { + auto_ptr_XMLCh temp(uri); + m_uri=temp.get(); + } + else + m_uri.erase(); +} + +void QName::setLocalPart(const char* localPart) +{ + if (localPart) { + auto_ptr_XMLCh temp(localPart); + m_local=temp.get(); + } + else + m_local.erase(); } -#endif bool xmltooling::operator==(const QName& op1, const QName& op2) { + if (&op1 == &op2) + return true; return (!XMLString::compareString(op1.getNamespaceURI(),op2.getNamespaceURI()) && !XMLString::compareString(op1.getLocalPart(),op2.getLocalPart())); }