Adding missing license information for the new matcher API files.
[platform/upstream/libphonenumber.git] / cpp / src / phonenumbers / regex_based_matcher.h
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 <memory>
21 #include <string>
22
23 #include "phonenumbers/base/basictypes.h"
24 #include "phonenumbers/base/memory/scoped_ptr.h"
25 #include "phonenumbers/matcher_api.h"
26
27 namespace i18n {
28 namespace phonenumbers {
29
30 class AbstractRegExpFactory;
31 class PhoneNumberDesc;
32 class RegExpCache;
33
34 // Implementation of the matcher API using the regular expressions in the
35 // PhoneNumberDesc proto message to match numbers.
36 class RegexBasedMatcher : public MatcherApi {
37  public:
38   RegexBasedMatcher();
39   ~RegexBasedMatcher();
40
41   bool MatchesNationalNumber(const string& national_number,
42                              const PhoneNumberDesc& number_desc,
43                              bool allow_prefix_match) const;
44
45   bool MatchesPossibleNumber(const string& national_number,
46                              const PhoneNumberDesc& number_desc) const;
47
48  private:
49   bool Match(const string& national_number, const string& number_pattern,
50              bool allow_prefix_match) const;
51
52   const scoped_ptr<const AbstractRegExpFactory> regexp_factory_;
53   const scoped_ptr<RegExpCache> regexp_cache_;
54
55   DISALLOW_COPY_AND_ASSIGN(RegexBasedMatcher);
56 };
57
58 }  // namespace phonenumbers
59 }  // namespace i18n
60
61 #endif  // I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_