My favorites
▼
|
Sign in
re2
an efficient, principled regular expression library
Project Home
Issues
Source
Repository:
default
wiki
Checkout
Browse
Changes
Clones
Source path:
hg
/
re2
/
testing
/
string_generator.h
2d252384c5e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2008 The RE2 Authors. All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// String generator: generates all possible strings of up to
// maxlen letters using the set of letters in alpha.
// Fetch strings using a Java-like Next()/HasNext() interface.
#ifndef RE2_TESTING_STRING_GENERATOR_H__
#define RE2_TESTING_STRING_GENERATOR_H__
#include <string>
#include <vector>
#include "util/util.h"
#include "util/random.h"
#include "re2/stringpiece.h"
namespace re2 {
class StringGenerator {
public:
StringGenerator(int maxlen, const vector<string>& alphabet);
~StringGenerator();
const StringPiece& Next();
bool HasNext() { return hasnext_; }
// Resets generator to start sequence over.
void Reset();
// Causes generator to emit random strings for next n calls to Next().
void Random(int32 seed, int n);
// Causes generator to emit a NULL as the next call.
void GenerateNULL();
private:
bool IncrementDigits();
bool RandomDigits();
// Global state.
int maxlen_; // Maximum length string to generate.
vector<string> alphabet_; // Alphabet, one string per letter.
// Iteration state.
StringPiece sp_; // Last StringPiece returned by Next().
string s_; // String data in last StringPiece returned by Next().
bool hasnext_; // Whether Next() can be called again.
vector<int> digits_; // Alphabet indices for next string.
bool generate_null_; // Whether to generate a NULL StringPiece next.
bool random_; // Whether generated strings are random.
int nrandom_; // Number of random strings left to generate.
ACMRandom* acm_; // Random number generator
DISALLOW_EVIL_CONSTRUCTORS(StringGenerator);
};
} // namespace re2
#endif // RE2_TESTING_STRING_GENERATOR_H__
Show details
Hide details
Change log
166b9c1905c7
by Russ Cox <r...@swtch.com> on Mar 2, 2010
Diff
initial release
Go to:
/.hgignore
/AUTHORS
/CONTRIBUTORS
/LICENSE
/Makefile
/README
/benchlog/benchlog.c2
/benchlog/benchlog.mini
/benchlog/benchlog.r70
/benchlog/benchlog.wreck
/benchlog/mktable
/doc/README.xkcd
/doc/mksyntaxhtml
/doc/syntax.html
/doc/syntax.txt
/doc/xkcd.png
/re2/Makefile
/re2/bitstate.cc
/re2/compile.cc
/re2/dfa.cc
/re2/filtered_re2.cc
/re2/filtered_re2.h
/re2/make_perl_groups.pl
/re2/make_unicode_casefold.py
/re2/make_unicode_groups.py
/re2/mimics_pcre.cc
/re2/nfa.cc
/re2/onepass.cc
/re2/parse.cc
/re2/perl_groups.cc
/re2/prefilter.cc
/re2/prefilter.h
/re2/prefilter_tree.cc
/re2/prefilter_tree.h
/re2/prog.cc
/re2/prog.h
/re2/re2.cc
/re2/re2.h
/re2/regexp.cc
/re2/regexp.h
/re2/simplify.cc
/re2/stringpiece.h
/re2/testing/backtrack.cc
/re2/testing/charclass_test.cc
/re2/testing/compile_test.cc
/re2/testing/dfa_test.cc
/re2/testing/dump.cc
/re2/testing/exhaustive1_test.cc
/re2/testing/exhaustive2_test.cc
/re2/testing/exhaustive3_test.cc
Older revisions
All revisions of this file
File info
Size: 1905 bytes, 58 lines
View raw file
Powered by
Google Project Hosting