diff options
author | Michael Lumish <mlumish@google.com> | 2015-05-20 16:31:38 -0700 |
---|---|---|
committer | Michael Lumish <mlumish@google.com> | 2015-05-20 16:31:38 -0700 |
commit | e4b329ba14ad42c667114dc6fa79baa023aaeda5 (patch) | |
tree | 57061362aa8ac0fe905495c49a4a2418ad7fe669 /src/compiler/generator_helpers.h | |
parent | 0e6cd6c624dd9be7543e9f4c1ea4168ecb622a59 (diff) | |
parent | 3fffe60ef87966c050a56369097d883a57f25e2f (diff) |
Merge pull request #1675 from jtattermusch/csharp_codegen_improvements
grpc_csharp_plugin improvements
Diffstat (limited to 'src/compiler/generator_helpers.h')
-rw-r--r-- | src/compiler/generator_helpers.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h index a232fcc954..7bdaff1c9b 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; |