Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: third_party/libphonenumber/cpp/src/regexp_adapter.h

Issue 6930013: Re-committing http://codereview.chromium.org/6803005/ after fixing multi-dll build: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (C) 2011 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Author: George Yakovlev
16
17 #ifndef I18N_PHONENUMBERS_REGEXP_ADAPTER_H_
18 #define I18N_PHONENUMBERS_REGEXP_ADAPTER_H_
19
20 #include <string>
21
22 // Regexp adapter to allow pluggable regexp engine, as it is external to
23 // libphonenumber.
24
25 namespace reg_exp {
26
27 // The reg exp input class.
28 // It supports only functions used in phonelibrary.
29 class RegularExpressionInput {
30 public:
31 virtual ~RegularExpressionInput() {};
32
33 // Matches string to regular expression, returns true if expression was
34 // matched, false otherwise, advances position in the match.
35 // |reg_exp| - expression to be matched.
36 // |beginning_only| - if true match would be successfull only if appears at
37 // the beginning of the tested region of the string.
38 // |matched_string1| - successfully matched first string. Can be NULL.
39 // |matched_string2| - successfully matched second string. Can be NULL.
40 virtual bool ConsumeRegExp(std::string const& reg_exp,
41 bool beginning_only,
42 std::string* matched_string1,
43 std::string* matched_string2) = 0;
44 // Convert unmatched input to a string.
45 virtual std::string ToString() const = 0;
46 };
47
48 // The regular expression class.
49 // It supports only functions used in phonelibrary.
50 class RegularExpression {
51 public:
52 RegularExpression() {}
53 virtual ~RegularExpression() {}
54
55 // Matches string to regular expression, returns true if expression was
56 // matched, false otherwise, advances position in the match.
57 // |input_string| - string to be searched.
58 // |beginning_only| - if true match would be successfull only if appears at
59 // the beginning of the tested region of the string.
60 // |matched_string1| - successfully matched first string. Can be NULL.
61 // |matched_string2| - successfully matched second string. Can be NULL.
62 // |matched_string3| - successfully matched third string. Can be NULL.
63 virtual bool Consume(RegularExpressionInput* input_string,
64 bool beginning_only,
65 std::string* matched_string1 = NULL,
66 std::string* matched_string2 = NULL,
67 std::string* matched_string3 = NULL) const = 0;
68
69
70 // Matches string to regular expression, returns true if expression was
71 // matched, false otherwise.
72 // |input_string| - string to be searched.
73 // |full_match| - if true match would be successfull only if it matches the
74 // complete string.
75 // |matched_string| - successfully matched string. Can be NULL.
76 virtual bool Match(const char* input_string,
77 bool full_match,
78 std::string* matched_string) const = 0;
79
80 // Replaces match(es) in the |string_to_process|. if |global| is true,
81 // replaces all the matches, only the first match otherwise.
82 // |replacement_string| - text the matches are replaced with.
83 // Returns true if expression successfully processed through the string,
84 // even if no actual replacements were made. Returns false in case of an
85 // error.
86 virtual bool Replace(std::string* string_to_process,
87 bool global,
88 const char* replacement_string) const = 0;
89 };
90
91 RegularExpressionInput* CreateRegularExpressionInput(const char* utf8_input);
92 RegularExpression* CreateRegularExpression(const char* utf8_regexp);
93
94 } // namespace reg_exp
95
96 #endif // I18N_PHONENUMBERS_REGEXP_ADAPTER_H_
OLDNEW
« no previous file with comments | « third_party/libphonenumber/cpp/src/re2_cache_test.cc ('k') | third_party/libphonenumber/cpp/src/regexp_adapter_re2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698