Get rid of `using std::string;`. (part 3 of N)
Change-Id: I24c9a04ba92ec6503bb040658f07e7aabacf74f2
Reviewed-on: https://code-review.googlesource.com/c/re2/+/39114
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/re2/dfa.cc b/re2/dfa.cc
index 89b9b77..91292d4 100644
--- a/re2/dfa.cc
+++ b/re2/dfa.cc
@@ -106,7 +106,7 @@
// Computes min and max for matching strings. Won't return strings
// bigger than maxlen.
- bool PossibleMatchRange(string* min, string* max, int maxlen);
+ bool PossibleMatchRange(std::string* min, std::string* max, int maxlen);
// These data structures are logically private, but C++ makes it too
// difficult to mark them as such.
@@ -241,10 +241,10 @@
void AddToQueue(Workq* q, int id, uint32_t flag);
// For debugging, returns a text representation of State.
- static string DumpState(State* state);
+ static std::string DumpState(State* state);
// For debugging, returns a text representation of a Workq.
- static string DumpWorkq(Workq* q);
+ static std::string DumpWorkq(Workq* q);
// Search parameters
struct SearchParams {
@@ -505,8 +505,8 @@
// Debugging printouts
// For debugging, returns a string representation of the work queue.
-string DFA::DumpWorkq(Workq* q) {
- string s;
+std::string DFA::DumpWorkq(Workq* q) {
+ std::string s;
const char* sep = "";
for (Workq::iterator it = q->begin(); it != q->end(); ++it) {
if (q->is_mark(*it)) {
@@ -521,14 +521,14 @@
}
// For debugging, returns a string representation of the state.
-string DFA::DumpState(State* state) {
+std::string DFA::DumpState(State* state) {
if (state == NULL)
return "_";
if (state == DeadState)
return "X";
if (state == FullMatchState)
return "*";
- string s;
+ std::string s;
const char* sep = "";
StringAppendF(&s, "(%p)", state);
for (int i = 0; i < state->ninst_; i++) {
@@ -1769,7 +1769,7 @@
if (ExtraDebug) {
fprintf(stderr, "\nprogram:\n%s\n", prog_->DumpUnanchored().c_str());
fprintf(stderr, "text %s anchored=%d earliest=%d fwd=%d kind %d\n",
- string(text).c_str(), anchored, want_earliest_match,
+ std::string(text).c_str(), anchored, want_earliest_match,
run_forward, kind_);
}
@@ -1995,7 +1995,7 @@
// Computes min and max for matching string.
// Won't return strings bigger than maxlen.
-bool DFA::PossibleMatchRange(string* min, string* max, int maxlen) {
+bool DFA::PossibleMatchRange(std::string* min, std::string* max, int maxlen) {
if (!ok())
return false;
@@ -2132,7 +2132,7 @@
}
// PossibleMatchRange for a Prog.
-bool Prog::PossibleMatchRange(string* min, string* max, int maxlen) {
+bool Prog::PossibleMatchRange(std::string* min, std::string* max, int maxlen) {
// Have to use dfa_longest_ to get all strings for full matches.
// For example, (a|aa) never matches aa in first-match mode.
return GetDFA(kLongestMatch)->PossibleMatchRange(min, max, maxlen);
diff --git a/re2/nfa.cc b/re2/nfa.cc
index 432b69a..e459b6f 100644
--- a/re2/nfa.cc
+++ b/re2/nfa.cc
@@ -105,7 +105,7 @@
const char* p);
// Returns text version of capture information, for debugging.
- string FormatCapture(const char** capture);
+ std::string FormatCapture(const char** capture);
inline void CopyCapture(const char** dst, const char** src);
@@ -425,9 +425,8 @@
return 0;
}
-string NFA::FormatCapture(const char** capture) {
- string s;
-
+std::string NFA::FormatCapture(const char** capture) {
+ std::string s;
for (int i = 0; i < ncapture_; i+=2) {
if (capture[i] == NULL)
StringAppendF(&s, "(?,?)");
@@ -492,7 +491,8 @@
if (ExtraDebug)
fprintf(stderr, "NFA::Search %s (context: %s) anchored=%d longest=%d\n",
- string(text).c_str(), string(context).c_str(), anchored, longest);
+ std::string(text).c_str(), std::string(context).c_str(), anchored,
+ longest);
// Set up search.
Threadq* runq = &q0_;
diff --git a/re2/onepass.cc b/re2/onepass.cc
index edd2c48..e04c56d 100644
--- a/re2/onepass.cc
+++ b/re2/onepass.cc
@@ -590,7 +590,7 @@
if (nodebyid[i] != -1)
idmap[nodebyid[i]] = i;
- string dump;
+ std::string dump;
for (Instq::iterator it = tovisit.begin(); it != tovisit.end(); ++it) {
int id = *it;
int nodeindex = nodebyid[id];
diff --git a/re2/prog.cc b/re2/prog.cc
index 4b3ea67..9853d6d 100644
--- a/re2/prog.cc
+++ b/re2/prog.cc
@@ -65,7 +65,7 @@
set_opcode(kInstFail);
}
-string Prog::Inst::Dump() {
+std::string Prog::Inst::Dump() {
switch (opcode()) {
default:
return StringPrintf("opcode %d", static_cast<int>(opcode()));
@@ -129,8 +129,8 @@
q->insert(id);
}
-static string ProgToString(Prog* prog, Workq* q) {
- string s;
+static std::string ProgToString(Prog* prog, Workq* q) {
+ std::string s;
for (Workq::iterator i = q->begin(); i != q->end(); ++i) {
int id = *i;
Prog::Inst* ip = prog->inst(id);
@@ -142,8 +142,8 @@
return s;
}
-static string FlattenedProgToString(Prog* prog, int start) {
- string s;
+static std::string FlattenedProgToString(Prog* prog, int start) {
+ std::string s;
for (int id = start; id < prog->size(); id++) {
Prog::Inst* ip = prog->inst(id);
if (ip->last())
@@ -154,7 +154,7 @@
return s;
}
-string Prog::Dump() {
+std::string Prog::Dump() {
if (did_flatten_)
return FlattenedProgToString(this, start_);
@@ -163,7 +163,7 @@
return ProgToString(this, &q);
}
-string Prog::DumpUnanchored() {
+std::string Prog::DumpUnanchored() {
if (did_flatten_)
return FlattenedProgToString(this, start_unanchored_);
@@ -172,8 +172,8 @@
return ProgToString(this, &q);
}
-string Prog::DumpByteMap() {
- string map;
+std::string Prog::DumpByteMap() {
+ std::string map;
for (int c = 0; c < 256; c++) {
int b = bytemap_[c];
int lo = c;
diff --git a/re2/prog.h b/re2/prog.h
index 68df8d6..bacc411 100644
--- a/re2/prog.h
+++ b/re2/prog.h
@@ -107,7 +107,7 @@
}
// Returns string representation for debugging.
- string Dump();
+ std::string Dump();
// Maximum instruction id.
// (Must fit in out_opcode_. PatchList/last steal another bit.)
@@ -222,9 +222,9 @@
int first_byte();
// Returns string representation of program for debugging.
- string Dump();
- string DumpUnanchored();
- string DumpByteMap();
+ std::string Dump();
+ std::string DumpUnanchored();
+ std::string DumpByteMap();
// Returns the set of kEmpty flags that are in effect at
// position p within context.
@@ -346,7 +346,7 @@
// do not compile down to infinite repetitions.
//
// Returns true on success, false on error.
- bool PossibleMatchRange(string* min, string* max, int maxlen);
+ bool PossibleMatchRange(std::string* min, std::string* max, int maxlen);
// EXPERIMENTAL! SUBJECT TO CHANGE!
// Outputs the program fanout into the given sparse array.
diff --git a/re2/regexp.cc b/re2/regexp.cc
index 7cfbbcb..7995ffc 100644
--- a/re2/regexp.cc
+++ b/re2/regexp.cc
@@ -510,16 +510,16 @@
"invalid named capture group",
};
-string RegexpStatus::CodeText(enum RegexpStatusCode code) {
+std::string RegexpStatus::CodeText(enum RegexpStatusCode code) {
if (code < 0 || code >= arraysize(kErrorStrings))
code = kRegexpInternalError;
return kErrorStrings[code];
}
-string RegexpStatus::Text() const {
+std::string RegexpStatus::Text() const {
if (error_arg_.empty())
return CodeText(code_);
- string s;
+ std::string s;
s.append(CodeText(code_));
s.append(": ");
s.append(error_arg_.data(), error_arg_.size());
@@ -569,8 +569,8 @@
NamedCapturesWalker() : map_(NULL) {}
~NamedCapturesWalker() { delete map_; }
- std::map<string, int>* TakeMap() {
- std::map<string, int>* m = map_;
+ std::map<std::string, int>* TakeMap() {
+ std::map<std::string, int>* m = map_;
map_ = NULL;
return m;
}
@@ -579,7 +579,7 @@
if (re->op() == kRegexpCapture && re->name() != NULL) {
// Allocate map once we find a name.
if (map_ == NULL)
- map_ = new std::map<string, int>;
+ map_ = new std::map<std::string, int>;
// Record first occurrence of each name.
// (The rule is that if you have the same name
@@ -597,13 +597,13 @@
}
private:
- std::map<string, int>* map_;
+ std::map<std::string, int>* map_;
NamedCapturesWalker(const NamedCapturesWalker&) = delete;
NamedCapturesWalker& operator=(const NamedCapturesWalker&) = delete;
};
-std::map<string, int>* Regexp::NamedCaptures() {
+std::map<std::string, int>* Regexp::NamedCaptures() {
NamedCapturesWalker w;
w.Walk(this, 0);
return w.TakeMap();
@@ -615,8 +615,8 @@
CaptureNamesWalker() : map_(NULL) {}
~CaptureNamesWalker() { delete map_; }
- std::map<int, string>* TakeMap() {
- std::map<int, string>* m = map_;
+ std::map<int, std::string>* TakeMap() {
+ std::map<int, std::string>* m = map_;
map_ = NULL;
return m;
}
@@ -625,7 +625,7 @@
if (re->op() == kRegexpCapture && re->name() != NULL) {
// Allocate map once we find a name.
if (map_ == NULL)
- map_ = new std::map<int, string>;
+ map_ = new std::map<int, std::string>;
(*map_)[re->cap()] = *re->name();
}
@@ -639,13 +639,13 @@
}
private:
- std::map<int, string>* map_;
+ std::map<int, std::string>* map_;
CaptureNamesWalker(const CaptureNamesWalker&) = delete;
CaptureNamesWalker& operator=(const CaptureNamesWalker&) = delete;
};
-std::map<int, string>* Regexp::CaptureNames() {
+std::map<int, std::string>* Regexp::CaptureNames() {
CaptureNamesWalker w;
w.Walk(this, 0);
return w.TakeMap();
@@ -655,7 +655,8 @@
// with a fixed string prefix. If so, returns the prefix and
// the regexp that remains after the prefix. The prefix might
// be ASCII case-insensitive.
-bool Regexp::RequiredPrefix(string* prefix, bool* foldcase, Regexp** suffix) {
+bool Regexp::RequiredPrefix(std::string* prefix, bool* foldcase,
+ Regexp** suffix) {
// No need for a walker: the regexp must be of the form
// 1. some number of ^ anchors
// 2. a literal char or string
diff --git a/re2/regexp.h b/re2/regexp.h
index 2ca96cd..a5d85c8 100644
--- a/re2/regexp.h
+++ b/re2/regexp.h
@@ -194,7 +194,7 @@
void set_code(RegexpStatusCode code) { code_ = code; }
void set_error_arg(const StringPiece& error_arg) { error_arg_ = error_arg; }
- void set_tmp(string* tmp) { delete tmp_; tmp_ = tmp; }
+ void set_tmp(std::string* tmp) { delete tmp_; tmp_ = tmp; }
RegexpStatusCode code() const { return code_; }
const StringPiece& error_arg() const { return error_arg_; }
bool ok() const { return code() == kRegexpSuccess; }
@@ -204,16 +204,16 @@
// Returns text equivalent of code, e.g.:
// "Bad character class"
- static string CodeText(RegexpStatusCode code);
+ static std::string CodeText(RegexpStatusCode code);
// Returns text describing error, e.g.:
// "Bad character class: [z-a]"
- string Text() const;
+ std::string Text() const;
private:
RegexpStatusCode code_; // Kind of error
- StringPiece error_arg_; // Piece of regexp containing syntax error.
- string* tmp_; // Temporary storage, possibly where error_arg_ is.
+ StringPiece error_arg_; // Piece of regexp containing syntax error.
+ std::string* tmp_; // Temporary storage, possibly where error_arg_ is.
RegexpStatus(const RegexpStatus&) = delete;
RegexpStatus& operator=(const RegexpStatus&) = delete;
@@ -336,7 +336,7 @@
Rune rune() { DCHECK_EQ(op_, kRegexpLiteral); return rune_; }
CharClass* cc() { DCHECK_EQ(op_, kRegexpCharClass); return cc_; }
int cap() { DCHECK_EQ(op_, kRegexpCapture); return cap_; }
- const string* name() { DCHECK_EQ(op_, kRegexpCapture); return name_; }
+ const std::string* name() { DCHECK_EQ(op_, kRegexpCapture); return name_; }
Rune* runes() { DCHECK_EQ(op_, kRegexpLiteralString); return runes_; }
int nrunes() { DCHECK_EQ(op_, kRegexpLiteralString); return nrunes_; }
int match_id() { DCHECK_EQ(op_, kRegexpHaveMatch); return match_id_; }
@@ -368,8 +368,7 @@
// string representation of the simplified form. Returns true on success.
// Returns false and sets *status (if status != NULL) on parse error.
static bool SimplifyRegexp(const StringPiece& src, ParseFlags flags,
- string* dst,
- RegexpStatus* status);
+ std::string* dst, RegexpStatus* status);
// Returns the number of capturing groups in the regexp.
int NumCaptures();
@@ -378,16 +377,16 @@
// Returns a map from names to capturing group indices,
// or NULL if the regexp contains no named capture groups.
// The caller is responsible for deleting the map.
- std::map<string, int>* NamedCaptures();
+ std::map<std::string, int>* NamedCaptures();
// Returns a map from capturing group indices to capturing group
// names or NULL if the regexp contains no named capture groups. The
// caller is responsible for deleting the map.
- std::map<int, string>* CaptureNames();
+ std::map<int, std::string>* CaptureNames();
// Returns a string representation of the current regexp,
// using as few parentheses as possible.
- string ToString();
+ std::string ToString();
// Convenience functions. They consume the passed reference,
// so in many cases you should use, e.g., Plus(re->Incref(), flags).
@@ -409,7 +408,7 @@
// Debugging function. Returns string format for regexp
// that makes structure clear. Does NOT use regexp syntax.
- string Dump();
+ std::string Dump();
// Helper traversal class, defined fully in walker-inl.h.
template<typename T> class Walker;
@@ -438,7 +437,8 @@
// follows it.
// Callers should expect *prefix, *foldcase and *suffix to be "zeroed"
// regardless of the return value.
- bool RequiredPrefix(string* prefix, bool* foldcase, Regexp** suffix);
+ bool RequiredPrefix(std::string* prefix, bool* foldcase,
+ Regexp** suffix);
private:
// Constructor allocates vectors as appropriate for operator.
@@ -564,7 +564,7 @@
};
struct { // Capture
int cap_;
- string* name_;
+ std::string* name_;
};
struct { // LiteralString
int nrunes_;
diff --git a/re2/simplify.cc b/re2/simplify.cc
index 7cc0419..8939678 100644
--- a/re2/simplify.cc
+++ b/re2/simplify.cc
@@ -21,8 +21,7 @@
// string representation of the simplified form. Returns true on success.
// Returns false and sets *error (if error != NULL) on error.
bool Regexp::SimplifyRegexp(const StringPiece& src, ParseFlags flags,
- string* dst,
- RegexpStatus* status) {
+ std::string* dst, RegexpStatus* status) {
Regexp* re = Parse(src, flags, status);
if (re == NULL)
return false;
diff --git a/re2/tostring.cc b/re2/tostring.cc
index 278c310..2d06551 100644
--- a/re2/tostring.cc
+++ b/re2/tostring.cc
@@ -28,7 +28,7 @@
};
// Helper function. See description below.
-static void AppendCCRange(string* t, Rune lo, Rune hi);
+static void AppendCCRange(std::string* t, Rune lo, Rune hi);
// Walker to generate string in s_.
// The arg pointers are actually integers giving the
@@ -36,7 +36,7 @@
// The child_args are always NULL.
class ToStringWalker : public Regexp::Walker<int> {
public:
- explicit ToStringWalker(string* t) : t_(t) {}
+ explicit ToStringWalker(std::string* t) : t_(t) {}
virtual int PreVisit(Regexp* re, int parent_arg, bool* stop);
virtual int PostVisit(Regexp* re, int parent_arg, int pre_arg,
@@ -46,14 +46,14 @@
}
private:
- string* t_; // The string the walker appends to.
+ std::string* t_; // The string the walker appends to.
ToStringWalker(const ToStringWalker&) = delete;
ToStringWalker& operator=(const ToStringWalker&) = delete;
};
-string Regexp::ToString() {
- string t;
+std::string Regexp::ToString() {
+ std::string t;
ToStringWalker w(&t);
w.WalkExponential(this, PrecToplevel, 100000);
if (w.stopped_early())
@@ -126,7 +126,7 @@
return nprec;
}
-static void AppendLiteral(string *t, Rune r, bool foldcase) {
+static void AppendLiteral(std::string *t, Rune r, bool foldcase) {
if (r != 0 && r < 0x80 && strchr("(){}[]*+?|.^$\\", r)) {
t->append(1, '\\');
t->append(1, static_cast<char>(r));
@@ -303,7 +303,7 @@
}
// Appends a rune for use in a character class to the string t.
-static void AppendCCChar(string* t, Rune r) {
+static void AppendCCChar(std::string* t, Rune r) {
if (0x20 <= r && r <= 0x7E) {
if (strchr("[]^-\\", r))
t->append("\\");
@@ -338,7 +338,7 @@
StringAppendF(t, "\\x{%x}", static_cast<int>(r));
}
-static void AppendCCRange(string* t, Rune lo, Rune hi) {
+static void AppendCCRange(std::string* t, Rune lo, Rune hi) {
if (lo > hi)
return;
AppendCCChar(t, lo);