source: icXML/icXML-devel/src/xercesc/util/regx/RangeToken.hpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 5.1 KB
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 678879 2008-07-22 20:05:05Z amassari $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_RANGETOKEN_HPP)
23#define XERCESC_INCLUDE_GUARD_RANGETOKEN_HPP
24
25// ---------------------------------------------------------------------------
26//  Includes
27// ---------------------------------------------------------------------------
28#include <icxercesc/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 tokType tkType,
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 RangeToken* complementRanges(RangeToken* const tok,
76                                   TokenFactory* const tokFactory,
77                                   MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
78
79    bool empty() const;
80
81    // -----------------------------------------------------------------------
82    //  Match methods
83    // -----------------------------------------------------------------------
84    bool match(const XMLInt32 ch);
85
86    // -----------------------------------------------------------------------
87    //  Creates the map.  This will happen automatically,
88    //  necessary.
89    // -----------------------------------------------------------------------
90    void createMap();
91
92private:
93    // -----------------------------------------------------------------------
94    //  Unimplemented constructors and operators
95    // -----------------------------------------------------------------------
96    RangeToken(const RangeToken&);
97    RangeToken& operator=(const RangeToken&);
98
99    // -----------------------------------------------------------------------
100    // Private Helper methods
101    // -----------------------------------------------------------------------
102    void expand(const unsigned int length);
103
104    void doCreateMap();
105
106    // -----------------------------------------------------------------------
107    //  Private data members
108    // -----------------------------------------------------------------------
109    bool         fSorted;
110    bool         fCompacted;
111    int          fNonMapIndex;
112    unsigned int fElemCount;
113    unsigned int fMaxCount;
114    int*         fMap;
115    XMLInt32*    fRanges;
116    RangeToken*  fCaseIToken;
117    MemoryManager* fMemoryManager;
118};
119
120
121inline void RangeToken::setCaseInsensitiveToken(RangeToken* tok)
122{
123    fCaseIToken = tok;
124}
125
126inline void RangeToken::createMap()
127{
128    if (!fMap)
129    {
130        doCreateMap();
131    }
132}
133
134inline bool RangeToken::empty() const
135{
136    return fElemCount==0; 
137}
138
139XERCES_CPP_NAMESPACE_END
140
141#endif
142
143/**
144  * End of file RangeToken.hpp
145  */
146
Note: See TracBrowser for help on using the repository browser.