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

Side by Side Diff: base/regexp.h

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « base/reg_key_unittest.cc ('k') | base/regexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2005-2009 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 //
16 // Implementors: There is only one function to implement -- DoMatchImpl
17 // See below
18
19 #ifndef OMAHA_COMMON_REGEXP_H__
20 #define OMAHA_COMMON_REGEXP_H__
21
22 #include <atlstr.h>
23
24 namespace omaha {
25
26 // Interface for regular expression matching. Also corresponds to a
27 // pre-compiled regular expression. An "RE" object is safe for
28 // concurrent use by multiple threads.
29 class RE {
30 public:
31
32 // Matches "text" against "pattern". If pointer arguments are
33 // supplied, copies matched sub-patterns into them. Use braces
34 // "{", "}" within the regexp to indicate a pattern to be copied.
35 //
36 // Returns true iff all of the following conditions are satisfied:
37 // a. some substring of "text" matches "pattern"
38 // b. The number of matched sub-patterns is >= number of supplied pointers
39 static bool PartialMatch(const TCHAR* text, const RE& re, // 3..16 args
40 CString * a0 = NULL,
41 CString * a1 = NULL,
42 CString * a2 = NULL,
43 CString * a3 = NULL,
44 CString * a4 = NULL,
45 CString * a5 = NULL,
46 CString * a6 = NULL,
47 CString * a7 = NULL,
48 CString * a8 = NULL,
49 CString * a9 = NULL,
50 CString * a10 = NULL,
51 CString * a11 = NULL,
52 CString * a12 = NULL,
53 CString * a13 = NULL,
54 CString * a14 = NULL,
55 CString * a15 = NULL);
56
57 // Like PartialMatch(), except the "input" is advanced past the matched
58 // text. Note: "input" is modified iff this routine returns true.
59 // For example, "FindAndConsume(s, "{\\w+}", &word)" finds the next
60 // word in "s" and stores it in "word".
61 static bool FindAndConsume(const TCHAR** input, const RE& re,
62 CString * a0 = NULL,
63 CString * a1 = NULL,
64 CString * a2 = NULL,
65 CString * a3 = NULL,
66 CString * a4 = NULL,
67 CString * a5 = NULL,
68 CString * a6 = NULL,
69 CString * a7 = NULL,
70 CString * a8 = NULL,
71 CString * a9 = NULL,
72 CString * a10 = NULL,
73 CString * a11 = NULL,
74 CString * a12 = NULL,
75 CString * a13 = NULL,
76 CString * a14 = NULL,
77 CString * a15 = NULL);
78
79 protected:
80
81 // The behavior of this function is subject to how it's used
82 // in PartialMatch() and FindAndConsume() above. See the header
83 // description of those functions to understand how an implementation
84 // should behave.
85 // text is the text we're looking in
86 // args is where matches should be outputted
87 // n is the number of CStrings in args
88 // match_end is a pointer to the position in text that
89 // we ended matching on
90 // returns true if data was found, false otherwise
91 // Example:Suppose text = "google 1\nYahoo! 2\n ..." and the regexp
92 // is something like "{\w+} \d". If args has two CStrings (n=2),
93 // then args[0] = "google", arg[1] = "1" and match_end will point to the \n
94 // before "Yahoo!"
95 virtual bool DoMatchImpl(const TCHAR *text,
96 CString * args[],
97 int n,
98 const TCHAR ** match_end) const = 0;
99 };
100
101 } // namespace omaha
102
103 #endif // OMAHA_COMMON_REGEXP_H__
OLDNEW
« no previous file with comments | « base/reg_key_unittest.cc ('k') | base/regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698