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