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

Side by Side Diff: third_party/re2/re2/testing/string_generator.h

Issue 1544433002: Replace RE2 import with a dependency (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-Added LICENSE and OWNERS file Created 4 years, 12 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
OLDNEW
(Empty)
1 // Copyright 2008 The RE2 Authors. All Rights Reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // String generator: generates all possible strings of up to
6 // maxlen letters using the set of letters in alpha.
7 // Fetch strings using a Java-like Next()/HasNext() interface.
8
9 #ifndef RE2_TESTING_STRING_GENERATOR_H__
10 #define RE2_TESTING_STRING_GENERATOR_H__
11
12 #include <string>
13 #include <vector>
14 #include "util/util.h"
15 #include "util/random.h"
16 #include "re2/stringpiece.h"
17
18 namespace re2 {
19
20 class StringGenerator {
21 public:
22 StringGenerator(int maxlen, const vector<string>& alphabet);
23 ~StringGenerator();
24 const StringPiece& Next();
25 bool HasNext() { return hasnext_; }
26
27 // Resets generator to start sequence over.
28 void Reset();
29
30 // Causes generator to emit random strings for next n calls to Next().
31 void Random(int32 seed, int n);
32
33 // Causes generator to emit a NULL as the next call.
34 void GenerateNULL();
35
36 private:
37 bool IncrementDigits();
38 bool RandomDigits();
39
40 // Global state.
41 int maxlen_; // Maximum length string to generate.
42 vector<string> alphabet_; // Alphabet, one string per letter.
43
44 // Iteration state.
45 StringPiece sp_; // Last StringPiece returned by Next().
46 string s_; // String data in last StringPiece returned by Next ().
47 bool hasnext_; // Whether Next() can be called again.
48 vector<int> digits_; // Alphabet indices for next string.
49 bool generate_null_; // Whether to generate a NULL StringPiece next.
50 bool random_; // Whether generated strings are random.
51 int nrandom_; // Number of random strings left to generate.
52 ACMRandom* acm_; // Random number generator
53 DISALLOW_COPY_AND_ASSIGN(StringGenerator);
54 };
55
56 } // namespace re2
57
58 #endif // RE2_TESTING_STRING_GENERATOR_H__
OLDNEW
« no previous file with comments | « third_party/re2/re2/testing/simplify_test.cc ('k') | third_party/re2/re2/testing/string_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698