1 | /*
|
---|
2 | * Copyright 2001-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: BMPattern.hpp,v 1.5 2004/09/08 13:56:47 peiyongz Exp $
|
---|
19 | */
|
---|
20 |
|
---|
21 | #if !defined(BMPATTERN_HPP)
|
---|
22 | #define BMPATTERN_HPP
|
---|
23 | // ---------------------------------------------------------------------------
|
---|
24 | // Includes
|
---|
25 | // ---------------------------------------------------------------------------
|
---|
26 | #include <xercesc/util/XMemory.hpp>
|
---|
27 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
28 |
|
---|
29 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
30 |
|
---|
31 | class XMLUTIL_EXPORT BMPattern : public XMemory
|
---|
32 | {
|
---|
33 | public:
|
---|
34 | // -----------------------------------------------------------------------
|
---|
35 | // Public Constructors and Destructor
|
---|
36 | // -----------------------------------------------------------------------
|
---|
37 | /** @name Constructors */
|
---|
38 | //@{
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * This is the onstructor which takes the pattern information. A default
|
---|
42 | * shift table size is used.
|
---|
43 | *
|
---|
44 | * @param pattern The pattern to match against.
|
---|
45 | *
|
---|
46 | * @param ignoreCase A flag to indicate whether to ignore case
|
---|
47 | * matching or not.
|
---|
48 | *
|
---|
49 | * @param manager The configurable memory manager
|
---|
50 | */
|
---|
51 | BMPattern
|
---|
52 | (
|
---|
53 | const XMLCh* const pattern
|
---|
54 | , bool ignoreCase
|
---|
55 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
56 | );
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * This is the constructor which takes all of the information
|
---|
60 | * required to construct a BM pattern object.
|
---|
61 | *
|
---|
62 | * @param pattern The pattern to match against.
|
---|
63 | *
|
---|
64 | * @param tableSize Indicates the size of the shift table.
|
---|
65 | *
|
---|
66 | * @param ignoreCase A flag to indicate whether to ignore case
|
---|
67 | * matching or not.
|
---|
68 | *
|
---|
69 | * @param manager The configurable memory manager
|
---|
70 | */
|
---|
71 | BMPattern
|
---|
72 | (
|
---|
73 | const XMLCh* const pattern
|
---|
74 | , int tableSize
|
---|
75 | , bool ignoreCase
|
---|
76 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
77 | );
|
---|
78 |
|
---|
79 | //@}
|
---|
80 |
|
---|
81 | /** @name Destructor. */
|
---|
82 | //@{
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Destructor of BMPattern
|
---|
86 | */
|
---|
87 | ~BMPattern();
|
---|
88 |
|
---|
89 | //@}
|
---|
90 |
|
---|
91 | // -----------------------------------------------------------------------
|
---|
92 | // Matching functions
|
---|
93 | // -----------------------------------------------------------------------
|
---|
94 | /** @name Matching Functions */
|
---|
95 | //@{
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * This method will perform a match of the given content against a
|
---|
99 | * predefined pattern.
|
---|
100 | */
|
---|
101 | int matches(const XMLCh* const content, int start, int limit);
|
---|
102 |
|
---|
103 | //@}
|
---|
104 |
|
---|
105 | private :
|
---|
106 | // -----------------------------------------------------------------------
|
---|
107 | // Unimplemented constructors and operators
|
---|
108 | // -----------------------------------------------------------------------
|
---|
109 | BMPattern();
|
---|
110 | BMPattern(const BMPattern&);
|
---|
111 | BMPattern& operator=(const BMPattern&);
|
---|
112 |
|
---|
113 | // -----------------------------------------------------------------------
|
---|
114 | // This method will perform a case insensitive match
|
---|
115 | // -----------------------------------------------------------------------
|
---|
116 | bool matchesIgnoreCase(const XMLCh ch1, const XMLCh ch2);
|
---|
117 |
|
---|
118 | // -----------------------------------------------------------------------
|
---|
119 | // Initialize/Clean up methods
|
---|
120 | // -----------------------------------------------------------------------
|
---|
121 | void initialize();
|
---|
122 | void cleanUp();
|
---|
123 |
|
---|
124 | // -----------------------------------------------------------------------
|
---|
125 | // Private data members
|
---|
126 | //
|
---|
127 | // fPattern
|
---|
128 | // fUppercasePattern
|
---|
129 | // This is the pattern to match against, and its upper case form.
|
---|
130 | //
|
---|
131 | // fIgnoreCase
|
---|
132 | // This is an indicator whether cases should be ignored during
|
---|
133 | // matching.
|
---|
134 | //
|
---|
135 | // fShiftTable
|
---|
136 | // fShiftTableLen
|
---|
137 | // This is a table of offsets for shifting purposes used by the BM
|
---|
138 | // search algorithm, and its length.
|
---|
139 | // -----------------------------------------------------------------------
|
---|
140 | bool fIgnoreCase;
|
---|
141 | unsigned int fShiftTableLen;
|
---|
142 | int* fShiftTable;
|
---|
143 | XMLCh* fPattern;
|
---|
144 | XMLCh* fUppercasePattern;
|
---|
145 | MemoryManager* fMemoryManager;
|
---|
146 | };
|
---|
147 |
|
---|
148 | XERCES_CPP_NAMESPACE_END
|
---|
149 |
|
---|
150 | #endif
|
---|
151 |
|
---|
152 | /*
|
---|
153 | * End of file BMPattern.hpp
|
---|
154 | */
|
---|
155 |
|
---|