aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compiler/generator_helpers.h
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-03-24 02:33:18 +0100
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-03-24 02:35:05 +0100
commit375a82b35c24952f35a728e5ea4d54dced982977 (patch)
tree87f97fe4ead387fa846aa5801a6274aeb5bad046 /src/compiler/generator_helpers.h
parentf37bc1f2596984dc6ecbfc8591e2c3f0c405683c (diff)
Adding the ability to specify a service namespace on protoc's command line.
Usage example: protoc ... --grpc_out=services_namespace=xyz:./path/to/output/dir ... This is difficult to add a test for this without significantly changing all of the examples, or the build system. However this has been successfully tested locally.
Diffstat (limited to 'src/compiler/generator_helpers.h')
-rw-r--r--src/compiler/generator_helpers.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h
index 1e6727dd4c..30857891c7 100644
--- a/src/compiler/generator_helpers.h
+++ b/src/compiler/generator_helpers.h
@@ -75,6 +75,26 @@ inline grpc::string StringReplace(grpc::string str, const grpc::string &from,
return str;
}
+inline std::vector<grpc::string> tokenize(const grpc::string &input,
+ const grpc::string &delimiters) {
+ std::vector<grpc::string> tokens;
+ size_t pos, last_pos = 0;
+
+ for (;;) {
+ bool done = false;
+ pos = input.find_first_of(delimiters, last_pos);
+ if (pos == grpc::string::npos) {
+ done = true;
+ pos = input.length();
+ }
+
+ tokens.push_back(input.substr(last_pos, pos - last_pos));
+ if (done) return tokens;
+
+ last_pos = pos + 1;
+ }
+}
+
} // namespace grpc_generator
#endif // GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H