ce6982832730afe2f97f69d831ee64d9c441a7aa
[platform/upstream/libphonenumber.git] / cpp / src / phonenumbers / regex_based_matcher.h
1 #ifndef I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_
2 #define I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_
3
4 #include <memory>
5 #include <string>
6
7 #include "phonenumbers/base/basictypes.h"
8 #include "phonenumbers/base/memory/scoped_ptr.h"
9 #include "phonenumbers/matcher_api.h"
10
11 namespace i18n {
12 namespace phonenumbers {
13
14 class AbstractRegExpFactory;
15 class PhoneNumberDesc;
16 class RegExpCache;
17
18 // Implementation of the matcher API using the regular expressions in the
19 // PhoneNumberDesc proto message to match numbers.
20 class RegexBasedMatcher : public MatcherApi {
21  public:
22   RegexBasedMatcher();
23   ~RegexBasedMatcher();
24
25   bool MatchesNationalNumber(const string& national_number,
26                              const PhoneNumberDesc& number_desc,
27                              bool allow_prefix_match) const;
28
29   bool MatchesPossibleNumber(const string& national_number,
30                              const PhoneNumberDesc& number_desc) const;
31
32  private:
33   bool Match(const string& national_number, const string& number_pattern,
34              bool allow_prefix_match) const;
35
36   const scoped_ptr<const AbstractRegExpFactory> regexp_factory_;
37   const scoped_ptr<RegExpCache> regexp_cache_;
38
39   DISALLOW_COPY_AND_ASSIGN(RegexBasedMatcher);
40 };
41
42 }  // namespace phonenumbers
43 }  // namespace i18n
44
45 #endif  // I18N_PHONENUMBERS_REGEX_BASED_MATCHER_H_