|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 /* |
|
18 * Licensed to the Apache Software Foundation (ASF) under one or more |
|
19 * contributor license agreements. See the NOTICE file distributed with |
|
20 * this work for additional information regarding copyright ownership. |
|
21 * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
22 * (the "License"); you may not use this file except in compliance with |
|
23 * the License. You may obtain a copy of the License at |
|
24 * |
|
25 * http://www.apache.org/licenses/LICENSE-2.0 |
|
26 * |
|
27 * Unless required by applicable law or agreed to in writing, software |
|
28 * distributed under the License is distributed on an "AS IS" BASIS, |
|
29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
30 * See the License for the specific language governing permissions and |
|
31 * limitations under the License. |
|
32 */ |
|
33 |
|
34 /* |
|
35 * $Id: BMPattern.hpp 568078 2007-08-21 11:43:25Z amassari $ |
|
36 */ |
|
37 |
|
38 #if !defined(BMPATTERN_HPP) |
|
39 #define BMPATTERN_HPP |
|
40 // --------------------------------------------------------------------------- |
|
41 // Includes |
|
42 // --------------------------------------------------------------------------- |
|
43 #include <xercesc/util/XMemory.hpp> |
|
44 #include <xercesc/util/PlatformUtils.hpp> |
|
45 |
|
46 XERCES_CPP_NAMESPACE_BEGIN |
|
47 |
|
48 class XMLUTIL_EXPORT BMPattern : public XMemory |
|
49 { |
|
50 public: |
|
51 // ----------------------------------------------------------------------- |
|
52 // Public Constructors and Destructor |
|
53 // ----------------------------------------------------------------------- |
|
54 /** @name Constructors */ |
|
55 //@{ |
|
56 |
|
57 /** |
|
58 * This is the onstructor which takes the pattern information. A default |
|
59 * shift table size is used. |
|
60 * |
|
61 * @param pattern The pattern to match against. |
|
62 * |
|
63 * @param ignoreCase A flag to indicate whether to ignore case |
|
64 * matching or not. |
|
65 * |
|
66 * @param manager The configurable memory manager |
|
67 */ |
|
68 BMPattern |
|
69 ( |
|
70 const XMLCh* const pattern |
|
71 , bool ignoreCase |
|
72 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
|
73 ); |
|
74 |
|
75 /** |
|
76 * This is the constructor which takes all of the information |
|
77 * required to construct a BM pattern object. |
|
78 * |
|
79 * @param pattern The pattern to match against. |
|
80 * |
|
81 * @param tableSize Indicates the size of the shift table. |
|
82 * |
|
83 * @param ignoreCase A flag to indicate whether to ignore case |
|
84 * matching or not. |
|
85 * |
|
86 * @param manager The configurable memory manager |
|
87 */ |
|
88 BMPattern |
|
89 ( |
|
90 const XMLCh* const pattern |
|
91 , int tableSize |
|
92 , bool ignoreCase |
|
93 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
|
94 ); |
|
95 |
|
96 //@} |
|
97 |
|
98 /** @name Destructor. */ |
|
99 //@{ |
|
100 |
|
101 /** |
|
102 * Destructor of BMPattern |
|
103 */ |
|
104 ~BMPattern(); |
|
105 |
|
106 //@} |
|
107 |
|
108 // ----------------------------------------------------------------------- |
|
109 // Matching functions |
|
110 // ----------------------------------------------------------------------- |
|
111 /** @name Matching Functions */ |
|
112 //@{ |
|
113 |
|
114 /** |
|
115 * This method will perform a match of the given content against a |
|
116 * predefined pattern. |
|
117 */ |
|
118 int matches(const XMLCh* const content, int start, int limit); |
|
119 |
|
120 //@} |
|
121 |
|
122 private : |
|
123 // ----------------------------------------------------------------------- |
|
124 // Unimplemented constructors and operators |
|
125 // ----------------------------------------------------------------------- |
|
126 BMPattern(); |
|
127 BMPattern(const BMPattern&); |
|
128 BMPattern& operator=(const BMPattern&); |
|
129 |
|
130 // ----------------------------------------------------------------------- |
|
131 // This method will perform a case insensitive match |
|
132 // ----------------------------------------------------------------------- |
|
133 bool matchesIgnoreCase(const XMLCh ch1, const XMLCh ch2); |
|
134 |
|
135 // ----------------------------------------------------------------------- |
|
136 // Initialize/Clean up methods |
|
137 // ----------------------------------------------------------------------- |
|
138 void initialize(); |
|
139 void cleanUp(); |
|
140 |
|
141 // ----------------------------------------------------------------------- |
|
142 // Private data members |
|
143 // |
|
144 // fPattern |
|
145 // fUppercasePattern |
|
146 // This is the pattern to match against, and its upper case form. |
|
147 // |
|
148 // fIgnoreCase |
|
149 // This is an indicator whether cases should be ignored during |
|
150 // matching. |
|
151 // |
|
152 // fShiftTable |
|
153 // fShiftTableLen |
|
154 // This is a table of offsets for shifting purposes used by the BM |
|
155 // search algorithm, and its length. |
|
156 // ----------------------------------------------------------------------- |
|
157 bool fIgnoreCase; |
|
158 unsigned int fShiftTableLen; |
|
159 int* fShiftTable; |
|
160 XMLCh* fPattern; |
|
161 XMLCh* fUppercasePattern; |
|
162 MemoryManager* fMemoryManager; |
|
163 }; |
|
164 |
|
165 XERCES_CPP_NAMESPACE_END |
|
166 |
|
167 #endif |
|
168 |
|
169 /* |
|
170 * End of file BMPattern.hpp |
|
171 */ |
|
172 |