11767c5feSopenharmony_ci/* 21767c5feSopenharmony_ci * Copyright (C) 2014 The Libphonenumber Authors 31767c5feSopenharmony_ci * 41767c5feSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 51767c5feSopenharmony_ci * you may not use this file except in compliance with the License. 61767c5feSopenharmony_ci * You may obtain a copy of the License at 71767c5feSopenharmony_ci * 81767c5feSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 91767c5feSopenharmony_ci * 101767c5feSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 111767c5feSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 121767c5feSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131767c5feSopenharmony_ci * See the License for the specific language governing permissions and 141767c5feSopenharmony_ci * limitations under the License. 151767c5feSopenharmony_ci */ 161767c5feSopenharmony_ci 171767c5feSopenharmony_ci#ifndef I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_ 181767c5feSopenharmony_ci#define I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_ 191767c5feSopenharmony_ci 201767c5feSopenharmony_ci#include <string> 211767c5feSopenharmony_ci 221767c5feSopenharmony_ci#include "phonenumbers/base/basictypes.h" 231767c5feSopenharmony_ci#include "phonenumbers/base/memory/scoped_ptr.h" 241767c5feSopenharmony_ci#include "phonenumbers/matcher_api.h" 251767c5feSopenharmony_ci 261767c5feSopenharmony_cinamespace i18n { 271767c5feSopenharmony_cinamespace phonenumbers { 281767c5feSopenharmony_ci 291767c5feSopenharmony_ciclass AbstractRegExpFactory; 301767c5feSopenharmony_ciclass PhoneNumberDesc; 311767c5feSopenharmony_ciclass RegExpCache; 321767c5feSopenharmony_ci 331767c5feSopenharmony_ci// Implementation of the matcher API using the regular expressions in the 341767c5feSopenharmony_ci// PhoneNumberDesc proto message to match numbers. 351767c5feSopenharmony_ciclass RegexBasedMatcher : public MatcherApi { 361767c5feSopenharmony_ci public: 371767c5feSopenharmony_ci RegexBasedMatcher(); 381767c5feSopenharmony_ci 391767c5feSopenharmony_ci // This type is neither copyable nor movable. 401767c5feSopenharmony_ci RegexBasedMatcher(const RegexBasedMatcher&) = delete; 411767c5feSopenharmony_ci RegexBasedMatcher& operator=(const RegexBasedMatcher&) = delete; 421767c5feSopenharmony_ci 431767c5feSopenharmony_ci ~RegexBasedMatcher(); 441767c5feSopenharmony_ci 451767c5feSopenharmony_ci bool MatchNationalNumber(const string& number, 461767c5feSopenharmony_ci const PhoneNumberDesc& number_desc, 471767c5feSopenharmony_ci bool allow_prefix_match) const; 481767c5feSopenharmony_ci 491767c5feSopenharmony_ci private: 501767c5feSopenharmony_ci bool Match(const string& number, const string& number_pattern, 511767c5feSopenharmony_ci bool allow_prefix_match) const; 521767c5feSopenharmony_ci 531767c5feSopenharmony_ci const scoped_ptr<const AbstractRegExpFactory> regexp_factory_; 541767c5feSopenharmony_ci const scoped_ptr<RegExpCache> regexp_cache_; 551767c5feSopenharmony_ci 561767c5feSopenharmony_ci}; 571767c5feSopenharmony_ci 581767c5feSopenharmony_ci} // namespace phonenumbers 591767c5feSopenharmony_ci} // namespace i18n 601767c5feSopenharmony_ci 611767c5feSopenharmony_ci#endif // I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_ 62