1 /* 2 * Copyright (C) 2014 The Libphonenumber Authors 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 #ifndef I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_ 18 #define I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_ 19 20 #include <string> 21 22 #include "phonenumbers/base/basictypes.h" 23 #include "phonenumbers/base/memory/scoped_ptr.h" 24 #include "phonenumbers/matcher_api.h" 25 26 namespace i18n { 27 namespace phonenumbers { 28 29 class AbstractRegExpFactory; 30 class PhoneNumberDesc; 31 class RegExpCache; 32 33 // Implementation of the matcher API using the regular expressions in the 34 // PhoneNumberDesc proto message to match numbers. 35 class RegexBasedMatcher : public MatcherApi { 36 public: 37 RegexBasedMatcher(); 38 ~RegexBasedMatcher(); 39 40 bool MatchNationalNumber(const string& number, 41 const PhoneNumberDesc& number_desc, 42 bool allow_prefix_match) const; 43 44 private: 45 bool Match(const string& number, const string& number_pattern, 46 bool allow_prefix_match) const; 47 48 const scoped_ptr<const AbstractRegExpFactory> regexp_factory_; 49 const scoped_ptr<RegExpCache> regexp_cache_; 50 51 DISALLOW_COPY_AND_ASSIGN(RegexBasedMatcher); 52 }; 53 54 } // namespace phonenumbers 55 } // namespace i18n 56 57 #endif // I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_ 58