1 | /*
|
---|
2 | * Copyright 2001-2002,2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * $Id: RangeToken.hpp,v 1.8 2004/09/08 13:56:47 peiyongz Exp $
|
---|
19 | */
|
---|
20 |
|
---|
21 | #if !defined(RANGETOKEN_HPP)
|
---|
22 | #define RANGETOKEN_HPP
|
---|
23 |
|
---|
24 | // ---------------------------------------------------------------------------
|
---|
25 | // Includes
|
---|
26 | // ---------------------------------------------------------------------------
|
---|
27 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
28 | #include <xercesc/util/regx/Token.hpp>
|
---|
29 |
|
---|
30 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
31 |
|
---|
32 | // ---------------------------------------------------------------------------
|
---|
33 | // Forward Declaration
|
---|
34 | // ---------------------------------------------------------------------------
|
---|
35 | class TokenFactory;
|
---|
36 |
|
---|
37 |
|
---|
38 | class XMLUTIL_EXPORT RangeToken : public Token {
|
---|
39 | public:
|
---|
40 | // -----------------------------------------------------------------------
|
---|
41 | // Public Constructors and Destructor
|
---|
42 | // -----------------------------------------------------------------------
|
---|
43 | RangeToken(const unsigned short tokType,
|
---|
44 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
45 | ~RangeToken();
|
---|
46 |
|
---|
47 | // -----------------------------------------------------------------------
|
---|
48 | // Public Constants
|
---|
49 | // -----------------------------------------------------------------------
|
---|
50 | static const int MAPSIZE;
|
---|
51 | static const unsigned int INITIALSIZE;
|
---|
52 |
|
---|
53 | // -----------------------------------------------------------------------
|
---|
54 | // Getter methods
|
---|
55 | // -----------------------------------------------------------------------
|
---|
56 | RangeToken* getCaseInsensitiveToken(TokenFactory* const tokFactory);
|
---|
57 |
|
---|
58 | // -----------------------------------------------------------------------
|
---|
59 | // Setter methods
|
---|
60 | // -----------------------------------------------------------------------
|
---|
61 | void setRangeValues(XMLInt32* const rangeValues, const unsigned int count);
|
---|
62 |
|
---|
63 | // -----------------------------------------------------------------------
|
---|
64 | // Range manipulation methods
|
---|
65 | // -----------------------------------------------------------------------
|
---|
66 | void addRange(const XMLInt32 start, const XMLInt32 end);
|
---|
67 | void mergeRanges(const Token *const tok);
|
---|
68 | void sortRanges();
|
---|
69 | void compactRanges();
|
---|
70 | void subtractRanges(RangeToken* const tok);
|
---|
71 | void intersectRanges(RangeToken* const tok);
|
---|
72 | static Token* complementRanges(RangeToken* const tok,
|
---|
73 | TokenFactory* const tokFactory,
|
---|
74 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
75 |
|
---|
76 | // -----------------------------------------------------------------------
|
---|
77 | // Match methods
|
---|
78 | // -----------------------------------------------------------------------
|
---|
79 | bool match(const XMLInt32 ch);
|
---|
80 |
|
---|
81 | private:
|
---|
82 | // -----------------------------------------------------------------------
|
---|
83 | // Unimplemented constructors and operators
|
---|
84 | // -----------------------------------------------------------------------
|
---|
85 | RangeToken(const RangeToken&);
|
---|
86 | RangeToken& operator=(const RangeToken&);
|
---|
87 |
|
---|
88 | // -----------------------------------------------------------------------
|
---|
89 | // Private Helper methods
|
---|
90 | // -----------------------------------------------------------------------
|
---|
91 | void createMap();
|
---|
92 | void expand(const unsigned int length);
|
---|
93 |
|
---|
94 | // -----------------------------------------------------------------------
|
---|
95 | // Private data members
|
---|
96 | // -----------------------------------------------------------------------
|
---|
97 | bool fSorted;
|
---|
98 | bool fCompacted;
|
---|
99 | int fNonMapIndex;
|
---|
100 | unsigned int fElemCount;
|
---|
101 | unsigned int fMaxCount;
|
---|
102 | int* fMap;
|
---|
103 | XMLInt32* fRanges;
|
---|
104 | RangeToken* fCaseIToken;
|
---|
105 | MemoryManager* fMemoryManager;
|
---|
106 | };
|
---|
107 |
|
---|
108 | XERCES_CPP_NAMESPACE_END
|
---|
109 |
|
---|
110 | #endif
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * End of file RangeToken.hpp
|
---|
114 | */
|
---|
115 |
|
---|