aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler/generator_helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/generator_helpers.h')
-rw-r--r--src/compiler/generator_helpers.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h
index 7ce4ec526c..373dd7f013 100644
--- a/src/compiler/generator_helpers.h
+++ b/src/compiler/generator_helpers.h
@@ -60,21 +60,26 @@ inline grpc::string StripProto(grpc::string filename) {
}
inline grpc::string StringReplace(grpc::string str, const grpc::string &from,
- const grpc::string &to) {
+ const grpc::string &to, bool replace_all) {
size_t pos = 0;
- for (;;) {
+ do {
pos = str.find(from, pos);
if (pos == grpc::string::npos) {
break;
}
str.replace(pos, from.length(), to);
pos += to.length();
- }
+ } while(replace_all);
return str;
}
+inline grpc::string StringReplace(grpc::string str, const grpc::string &from,
+ const grpc::string &to) {
+ return StringReplace(str, from, to, true);
+}
+
inline std::vector<grpc::string> tokenize(const grpc::string &input,
const grpc::string &delimiters) {
std::vector<grpc::string> tokens;