source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/util/regx/RangeToken.hpp @ 2674

Revision 2674, 4.9 KB checked in by mattausch, 16 years ago (diff)
Line 
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: RangeToken.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22#if !defined(RANGETOKEN_HPP)
23#define RANGETOKEN_HPP
24
25// ---------------------------------------------------------------------------
26//  Includes
27// ---------------------------------------------------------------------------
28#include <xercesc/util/PlatformUtils.hpp>
29#include <xercesc/util/regx/Token.hpp>
30
31XERCES_CPP_NAMESPACE_BEGIN
32
33// ---------------------------------------------------------------------------
34//  Forward Declaration
35// ---------------------------------------------------------------------------
36class TokenFactory;
37
38
39class XMLUTIL_EXPORT RangeToken : public Token {
40public:
41    // -----------------------------------------------------------------------
42    //  Public Constructors and Destructor
43    // -----------------------------------------------------------------------
44    RangeToken(const unsigned short tokType,
45               MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
46    ~RangeToken();
47
48    // -----------------------------------------------------------------------
49    //  Public Constants
50    // -----------------------------------------------------------------------
51    static const int MAPSIZE;
52    static const unsigned int INITIALSIZE;
53
54    // -----------------------------------------------------------------------
55    //  Getter methods
56    // -----------------------------------------------------------------------
57    RangeToken* getCaseInsensitiveToken(TokenFactory* const tokFactory);
58
59    void setCaseInsensitiveToken(RangeToken* tok);
60
61    // -----------------------------------------------------------------------
62    //  Setter methods
63    // -----------------------------------------------------------------------
64    void setRangeValues(XMLInt32* const rangeValues, const unsigned int count);
65
66    // -----------------------------------------------------------------------
67    //  Range manipulation methods
68    // -----------------------------------------------------------------------
69    void addRange(const XMLInt32 start, const XMLInt32 end);
70    void mergeRanges(const Token *const tok);
71    void sortRanges();
72    void compactRanges();
73    void subtractRanges(RangeToken* const tok);
74    void intersectRanges(RangeToken* const tok);
75    static Token* complementRanges(RangeToken* const tok,
76                                   TokenFactory* const tokFactory,
77                                   MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
78
79    // -----------------------------------------------------------------------
80    //  Match methods
81    // -----------------------------------------------------------------------
82    bool match(const XMLInt32 ch);
83
84    // -----------------------------------------------------------------------
85    //  Creates the map.  This will happen automatically,
86    //  necessary.
87    // -----------------------------------------------------------------------
88    void
89    createMap();
90
91private:
92    // -----------------------------------------------------------------------
93    //  Unimplemented constructors and operators
94    // -----------------------------------------------------------------------
95    RangeToken(const RangeToken&);
96    RangeToken& operator=(const RangeToken&);
97
98    // -----------------------------------------------------------------------
99    // Private Helper methods
100    // -----------------------------------------------------------------------
101    void expand(const unsigned int length);
102
103    void doCreateMap();
104
105    // -----------------------------------------------------------------------
106    //  Private data members
107    // -----------------------------------------------------------------------
108    bool         fSorted;
109    bool         fCompacted;
110    int          fNonMapIndex;
111    unsigned int fElemCount;
112    unsigned int fMaxCount;
113    int*         fMap;
114    XMLInt32*    fRanges;
115    RangeToken*  fCaseIToken;
116    MemoryManager* fMemoryManager;
117};
118
119
120inline void RangeToken::setCaseInsensitiveToken(RangeToken* tok)
121{
122    fCaseIToken = tok;
123}
124
125inline void RangeToken::createMap()
126{
127    if (!fMap)
128    {
129        doCreateMap();
130    }
131}
132
133
134XERCES_CPP_NAMESPACE_END
135
136#endif
137
138/**
139  * End of file RangeToken.hpp
140  */
141
Note: See TracBrowser for help on using the repository browser.