~sahana-agasti-ocr/+junk/working_source

« back to all changes in this revision

Viewing changes to Projects/common/include/xercesc/validators/schema/NamespaceScope.hpp

  • Committer: Thilanka
  • Date: 2010-07-14 07:34:15 UTC
  • Revision ID: thilanka@thilanka-laptop-20100714073415-1etpm1i0xtbrldus
This commit contains all the working source for sahana OCR till midterm evaluation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
8
 * 
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 * 
 
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.
 
16
 */
 
17
 
 
18
/*
 
19
 * $Id: NamespaceScope.hpp 527149 2007-04-10 14:56:39Z amassari $
 
20
 */
 
21
 
 
22
#if !defined(XERCESC_INCLUDE_GUARD_NAMESPACESCOPE_HPP)
 
23
#define XERCESC_INCLUDE_GUARD_NAMESPACESCOPE_HPP
 
24
 
 
25
#include <xercesc/util/StringPool.hpp>
 
26
 
 
27
XERCES_CPP_NAMESPACE_BEGIN
 
28
 
 
29
// Define a pure interface to allow XercesXPath to work on both NamespaceScope and DOMXPathNSResolver
 
30
class VALIDATORS_EXPORT XercesNamespaceResolver
 
31
{
 
32
public:
 
33
    virtual unsigned int getNamespaceForPrefix(const XMLCh* const prefix) const = 0;
 
34
};
 
35
 
 
36
//
 
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.
 
40
//
 
41
 
 
42
class VALIDATORS_EXPORT NamespaceScope : public XMemory,
 
43
                                         public XercesNamespaceResolver
 
44
{
 
45
public :
 
46
    // -----------------------------------------------------------------------
 
47
    //  Class specific data types
 
48
    //
 
49
    //  These really should be private, but some of the compilers we have to
 
50
    //  support are too dumb to deal with that.
 
51
    //
 
52
    //  PrefMapElem
 
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.
 
56
    //
 
57
    //  StackElem
 
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
 
62
    {
 
63
        unsigned int        fPrefId;
 
64
        unsigned int        fURIId;
 
65
    };
 
66
 
 
67
    struct StackElem : public XMemory
 
68
    {
 
69
        PrefMapElem*        fMap;
 
70
        unsigned int        fMapCapacity;
 
71
        unsigned int        fMapCount;
 
72
    };
 
73
 
 
74
 
 
75
    // -----------------------------------------------------------------------
 
76
    //  Constructors and Destructor
 
77
    // -----------------------------------------------------------------------
 
78
    NamespaceScope(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 
79
    NamespaceScope(const NamespaceScope* const initialize, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 
80
    ~NamespaceScope();
 
81
 
 
82
 
 
83
    // -----------------------------------------------------------------------
 
84
    //  Stack access
 
85
    // -----------------------------------------------------------------------
 
86
    unsigned int increaseDepth();
 
87
    unsigned int decreaseDepth();
 
88
 
 
89
    // -----------------------------------------------------------------------
 
90
    //  Prefix map methods
 
91
    // -----------------------------------------------------------------------
 
92
    void addPrefix(const XMLCh* const prefixToAdd,
 
93
                   const unsigned int uriId);
 
94
 
 
95
    virtual unsigned int getNamespaceForPrefix(const XMLCh* const prefixToMap) const;
 
96
 
 
97
 
 
98
    // -----------------------------------------------------------------------
 
99
    //  Miscellaneous methods
 
100
    // -----------------------------------------------------------------------
 
101
    bool isEmpty() const;
 
102
    void reset(const unsigned int emptyId);
 
103
 
 
104
 
 
105
private :
 
106
    // -----------------------------------------------------------------------
 
107
    //  Unimplemented constructors and operators
 
108
    // -----------------------------------------------------------------------
 
109
    NamespaceScope(const NamespaceScope&);
 
110
    NamespaceScope& operator=(const NamespaceScope&);
 
111
 
 
112
 
 
113
    // -----------------------------------------------------------------------
 
114
    //  Private helper methods
 
115
    // -----------------------------------------------------------------------
 
116
    void expandMap(StackElem* const toExpand);
 
117
    void expandStack();
 
118
 
 
119
 
 
120
    // -----------------------------------------------------------------------
 
121
    //  Data members
 
122
    //
 
123
    //  fEmptyNamespaceId
 
124
    //      This is the special URI id for the "" namespace, which is magic
 
125
    //      because of the xmlns="" operation.
 
126
    //
 
127
    //  fPrefixPool
 
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.
 
130
    //
 
131
    //  fStack
 
132
    //  fStackCapacity
 
133
    //  fStackTop
 
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
 
137
    //      being used.)
 
138
    // -----------------------------------------------------------------------
 
139
    unsigned int  fEmptyNamespaceId;
 
140
    unsigned int  fStackCapacity;
 
141
    unsigned int  fStackTop;
 
142
    XMLStringPool fPrefixPool;
 
143
    StackElem**   fStack;
 
144
    MemoryManager* fMemoryManager;
 
145
};
 
146
 
 
147
// ---------------------------------------------------------------------------
 
148
//  NamespaceScope: Miscellaneous methods
 
149
// ---------------------------------------------------------------------------
 
150
inline bool NamespaceScope::isEmpty() const
 
151
{
 
152
    return (fStackTop == 0);
 
153
}
 
154
 
 
155
XERCES_CPP_NAMESPACE_END
 
156
 
 
157
#endif
 
158
 
 
159
/**
 
160
  * End of file NameSpaceScope.hpp
 
161
  */
 
162