X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2FNamespace.h;h=de17cb074f961a4eea31c40589ec5393fe5f5038;hb=a0d768778a8f5f539b909baf5b115e70ea765f0f;hp=117769386e49c2714093f3d0438cb941933dbef4;hpb=e7a65d784215bc04355f014141219b3e7ab4559a;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/Namespace.h b/xmltooling/Namespace.h index 1177693..de17cb0 100644 --- a/xmltooling/Namespace.h +++ b/xmltooling/Namespace.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Internet2 + * Copyright 2001-2010 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ */ /** - * @file Namespace.h + * @file xmltooling/Namespace.h * - * Representing XML namespace attributes + * Representing XML namespace attributes. */ #if !defined(__xmltooling_namespace_h__) @@ -26,35 +26,38 @@ #include namespace xmltooling { - + +#if defined (_MSC_VER) + #pragma warning( push ) + #pragma warning( disable : 4251 ) +#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(); -#ifndef HAVE_GOOD_STL - /** - * Deep copy constructor - */ - Namespace(const Namespace& src); - - /** - * Deep assignment operator - */ - Namespace& operator=(const Namespace& src); -#endif -#ifdef HAVE_GOOD_STL /** * Returns the namespace prefix * @return Null-terminated Unicode string containing the prefix, without the colon @@ -66,25 +69,18 @@ namespace xmltooling { * @return Null-terminated Unicode string containing the URI */ const XMLCh* getNamespaceURI() const { return m_uri.c_str(); } -#else - /** - * Returns the namespace prefix - * @return Null-terminated Unicode string containing the prefix, without the colon - */ - const XMLCh* getNamespacePrefix() const { return m_prefix; } /** - * Returns the namespace URI - * @return Null-terminated Unicode string containing the URI + * Returns true iff the namespace should always be declared regardless of in-scope declarations + * @return the alwaysDeclared setting */ - const XMLCh* getNamespaceURI() const { return m_uri; } -#endif + const bool alwaysDeclare() const { return m_pinned; } /** - * Returns true iff the namespace should always be declared regardless of in-scope declarations - * @return the alwaysDeclared setting + * Returns the usage of the namespace by an XMLObject + * @return the usage setting */ - const bool alwaysDeclare() const { return m_pinned; } + const namespace_usage_t usage() const { return m_usage; } /** * Sets the namespace prefix @@ -104,17 +100,23 @@ 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; -#ifdef HAVE_GOOD_STL + namespace_usage_t m_usage; xstring m_uri; xstring m_prefix; -#else - XMLCh* m_uri; - XMLCh* m_prefix; -#endif }; +#if defined (_MSC_VER) + #pragma warning( pop ) +#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. @@ -126,14 +128,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 };