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.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h
index 374e1374cf..7ce4ec526c 100644
--- a/src/compiler/generator_helpers.h
+++ b/src/compiler/generator_helpers.h
@@ -116,6 +116,29 @@ inline grpc::string FileNameInUpperCamel(const grpc::protobuf::FileDescriptor *f
return LowerUnderscoreToUpperCamel(StripProto(file->name()));
}
+enum MethodType {
+ METHODTYPE_NO_STREAMING,
+ METHODTYPE_CLIENT_STREAMING,
+ METHODTYPE_SERVER_STREAMING,
+ METHODTYPE_BIDI_STREAMING
+};
+
+inline MethodType GetMethodType(const grpc::protobuf::MethodDescriptor *method) {
+ if (method->client_streaming()) {
+ if (method->server_streaming()) {
+ return METHODTYPE_BIDI_STREAMING;
+ } else {
+ return METHODTYPE_CLIENT_STREAMING;
+ }
+ } else {
+ if (method->server_streaming()) {
+ return METHODTYPE_SERVER_STREAMING;
+ } else {
+ return METHODTYPE_NO_STREAMING;
+ }
+ }
+}
+
} // namespace grpc_generator
#endif // GRPC_INTERNAL_COMPILER_GENERATOR_HELPERS_H