X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=blobdiff_plain;f=xmltooling%2FNamespace.h;h=0e97bbea467c74b0285a50db621ebc801b92b474;hp=a948477fbfa32588fcd130a7480ac4181bb28068;hb=HEAD;hpb=e037f6d25a1a0a66592903c9a0d065f892639415 diff --git a/xmltooling/Namespace.h b/xmltooling/Namespace.h index a948477..0e97bbe 100644 --- a/xmltooling/Namespace.h +++ b/xmltooling/Namespace.h @@ -1,23 +1,27 @@ -/* - * 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 +/** + * 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. * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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 xmltooling/Namespace.h * - * Representing XML namespace attributes + * Representing XML namespace attributes. */ #if !defined(__xmltooling_namespace_h__) @@ -33,18 +37,28 @@ namespace xmltooling { #endif /** - * A data structure for encapsulating XML Namespace attributes + * A data structure for encapsulating XML Namespace attributes. */ class XMLTOOL_API Namespace { public: /** + * Tri-state indicator of namespace usage. + */ + enum namespace_usage_t { + Indeterminate, + NonVisiblyUsed, + VisiblyUsed + }; + + /** * Constructor * @param uri namespace URI * @param prefix namespace prefix (without the colon) * @param alwaysDeclare true iff the namespace should always be declared regardless of in-scope declarations + * @param usage indicates usage of namespace in the context of an XMLObject */ - Namespace(const XMLCh* uri=NULL, const XMLCh* prefix=NULL, bool alwaysDeclare=false); + Namespace(const XMLCh* uri=nullptr, const XMLCh* prefix=nullptr, bool alwaysDeclare=false, namespace_usage_t usage=Indeterminate); ~Namespace(); @@ -64,7 +78,13 @@ namespace xmltooling { * Returns true iff the namespace should always be declared regardless of in-scope declarations * @return the alwaysDeclared setting */ - const bool alwaysDeclare() const { return m_pinned; } + const bool alwaysDeclare() const { return m_pinned; } + + /** + * Returns the usage of the namespace by an XMLObject + * @return the usage setting + */ + const namespace_usage_t usage() const { return m_usage; } /** * Sets the namespace prefix @@ -84,8 +104,15 @@ namespace xmltooling { */ void setAlwaysDeclare(bool alwaysDeclare) { m_pinned = alwaysDeclare; } + /** + * Sets the usage property + * @param usage usage of the namespace by an XMLObject + */ + void setUsage(namespace_usage_t usage) { m_usage = usage; } + private: bool m_pinned; + namespace_usage_t m_usage; xstring m_uri; xstring m_prefix; }; @@ -105,14 +132,12 @@ namespace xmltooling { */ extern XMLTOOL_API bool operator<(const Namespace& op1, const Namespace& op2); -#ifndef HAVE_GOOD_STL /** * Returns true iff op1's namespace and prefix are equal to op2's namespace and prefix. * @param op1 First namspace to compare * @param op2 Second namespace to compare */ extern XMLTOOL_API bool operator==(const Namespace& op1, const Namespace& op2); -#endif };