2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
19
* $Id: NamespaceScope.hpp 527149 2007-04-10 14:56:39Z amassari $
22
#if !defined(XERCESC_INCLUDE_GUARD_NAMESPACESCOPE_HPP)
23
#define XERCESC_INCLUDE_GUARD_NAMESPACESCOPE_HPP
25
#include <xercesc/util/StringPool.hpp>
27
XERCES_CPP_NAMESPACE_BEGIN
29
// Define a pure interface to allow XercesXPath to work on both NamespaceScope and DOMXPathNSResolver
30
class VALIDATORS_EXPORT XercesNamespaceResolver
33
virtual unsigned int getNamespaceForPrefix(const XMLCh* const prefix) const = 0;
37
// NamespaceScope provides a data structure for mapping namespace prefixes
38
// to their URI's. The mapping accurately reflects the scoping of namespaces
39
// at a particular instant in time.
42
class VALIDATORS_EXPORT NamespaceScope : public XMemory,
43
public XercesNamespaceResolver
46
// -----------------------------------------------------------------------
47
// Class specific data types
49
// These really should be private, but some of the compilers we have to
50
// support are too dumb to deal with that.
53
// fURIId is the id of the URI from the validator's URI map. The
54
// fPrefId is the id of the prefix from our own prefix pool. The
55
// namespace stack consists of these elements.
58
// The fMapCapacity is how large fMap has grown so far. fMapCount
59
// is how many of them are valid right now.
60
// -----------------------------------------------------------------------
61
struct PrefMapElem : public XMemory
67
struct StackElem : public XMemory
70
unsigned int fMapCapacity;
71
unsigned int fMapCount;
75
// -----------------------------------------------------------------------
76
// Constructors and Destructor
77
// -----------------------------------------------------------------------
78
NamespaceScope(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
79
NamespaceScope(const NamespaceScope* const initialize, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
83
// -----------------------------------------------------------------------
85
// -----------------------------------------------------------------------
86
unsigned int increaseDepth();
87
unsigned int decreaseDepth();
89
// -----------------------------------------------------------------------
91
// -----------------------------------------------------------------------
92
void addPrefix(const XMLCh* const prefixToAdd,
93
const unsigned int uriId);
95
virtual unsigned int getNamespaceForPrefix(const XMLCh* const prefixToMap) const;
98
// -----------------------------------------------------------------------
99
// Miscellaneous methods
100
// -----------------------------------------------------------------------
101
bool isEmpty() const;
102
void reset(const unsigned int emptyId);
106
// -----------------------------------------------------------------------
107
// Unimplemented constructors and operators
108
// -----------------------------------------------------------------------
109
NamespaceScope(const NamespaceScope&);
110
NamespaceScope& operator=(const NamespaceScope&);
113
// -----------------------------------------------------------------------
114
// Private helper methods
115
// -----------------------------------------------------------------------
116
void expandMap(StackElem* const toExpand);
120
// -----------------------------------------------------------------------
124
// This is the special URI id for the "" namespace, which is magic
125
// because of the xmlns="" operation.
128
// This is the prefix pool where prefixes are hashed and given unique
129
// ids. These ids are used to track prefixes in the element stack.
134
// This the stack array. Its an array of pointers to StackElem
135
// structures. The capacity is the current high water mark of the
136
// stack. The top is the current top of stack (i.e. the part of it
138
// -----------------------------------------------------------------------
139
unsigned int fEmptyNamespaceId;
140
unsigned int fStackCapacity;
141
unsigned int fStackTop;
142
XMLStringPool fPrefixPool;
144
MemoryManager* fMemoryManager;
147
// ---------------------------------------------------------------------------
148
// NamespaceScope: Miscellaneous methods
149
// ---------------------------------------------------------------------------
150
inline bool NamespaceScope::isEmpty() const
152
return (fStackTop == 0);
155
XERCES_CPP_NAMESPACE_END
160
* End of file NameSpaceScope.hpp