|  | @@ -31,6 +31,9 @@
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +#include <string>
 | 
	
		
			
				|  |  | +#include <map>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  #include "src/compiler/cpp_generator.h"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #include "src/compiler/cpp_generator_helpers.h"
 | 
	
	
		
			
				|  | @@ -42,26 +45,23 @@
 | 
	
		
			
				|  |  |  namespace grpc_cpp_generator {
 | 
	
		
			
				|  |  |  namespace {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -bool NoStreaming(const google::protobuf::MethodDescriptor* method) {
 | 
	
		
			
				|  |  | -  return !method->client_streaming() &&
 | 
	
		
			
				|  |  | -         !method->server_streaming();
 | 
	
		
			
				|  |  | +bool NoStreaming(const google::protobuf::MethodDescriptor *method) {
 | 
	
		
			
				|  |  | +  return !method->client_streaming() && !method->server_streaming();
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -bool ClientOnlyStreaming(const google::protobuf::MethodDescriptor* method) {
 | 
	
		
			
				|  |  | -  return method->client_streaming() &&
 | 
	
		
			
				|  |  | -         !method->server_streaming();
 | 
	
		
			
				|  |  | +bool ClientOnlyStreaming(const google::protobuf::MethodDescriptor *method) {
 | 
	
		
			
				|  |  | +  return method->client_streaming() && !method->server_streaming();
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -bool ServerOnlyStreaming(const google::protobuf::MethodDescriptor* method) {
 | 
	
		
			
				|  |  | +bool ServerOnlyStreaming(const google::protobuf::MethodDescriptor *method) {
 | 
	
		
			
				|  |  |    return !method->client_streaming() && method->server_streaming();
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -bool BidiStreaming(const google::protobuf::MethodDescriptor* method) {
 | 
	
		
			
				|  |  | -  return method->client_streaming() &&
 | 
	
		
			
				|  |  | -         method->server_streaming();
 | 
	
		
			
				|  |  | +bool BidiStreaming(const google::protobuf::MethodDescriptor *method) {
 | 
	
		
			
				|  |  | +  return method->client_streaming() && method->server_streaming();
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  | +bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor *file) {
 | 
	
		
			
				|  |  |    for (int i = 0; i < file->service_count(); i++) {
 | 
	
		
			
				|  |  |      for (int j = 0; j < file->service(i)->method_count(); j++) {
 | 
	
		
			
				|  |  |        if (ClientOnlyStreaming(file->service(i)->method(j))) {
 | 
	
	
		
			
				|  | @@ -72,7 +72,7 @@ bool HasClientOnlyStreaming(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  |    return false;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -bool HasServerOnlyStreaming(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  | +bool HasServerOnlyStreaming(const google::protobuf::FileDescriptor *file) {
 | 
	
		
			
				|  |  |    for (int i = 0; i < file->service_count(); i++) {
 | 
	
		
			
				|  |  |      for (int j = 0; j < file->service(i)->method_count(); j++) {
 | 
	
		
			
				|  |  |        if (ServerOnlyStreaming(file->service(i)->method(j))) {
 | 
	
	
		
			
				|  | @@ -83,7 +83,7 @@ bool HasServerOnlyStreaming(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  |    return false;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -bool HasBidiStreaming(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  | +bool HasBidiStreaming(const google::protobuf::FileDescriptor *file) {
 | 
	
		
			
				|  |  |    for (int i = 0; i < file->service_count(); i++) {
 | 
	
		
			
				|  |  |      for (int j = 0; j < file->service(i)->method_count(); j++) {
 | 
	
		
			
				|  |  |        if (BidiStreaming(file->service(i)->method(j))) {
 | 
	
	
		
			
				|  | @@ -95,8 +95,8 @@ bool HasBidiStreaming(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  }  // namespace
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -string GetHeaderIncludes(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  | -  string temp =
 | 
	
		
			
				|  |  | +std::string GetHeaderIncludes(const google::protobuf::FileDescriptor *file) {
 | 
	
		
			
				|  |  | +  std::string temp =
 | 
	
		
			
				|  |  |        "#include \"grpc++/impl/internal_stub.h\"\n"
 | 
	
		
			
				|  |  |        "#include \"grpc++/status.h\"\n"
 | 
	
		
			
				|  |  |        "\n"
 | 
	
	
		
			
				|  | @@ -124,16 +124,16 @@ string GetHeaderIncludes(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  |    return temp;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -string GetSourceIncludes() {
 | 
	
		
			
				|  |  | +std::string GetSourceIncludes() {
 | 
	
		
			
				|  |  |    return "#include \"grpc++/channel_interface.h\"\n"
 | 
	
		
			
				|  |  |           "#include \"grpc++/impl/rpc_method.h\"\n"
 | 
	
		
			
				|  |  |           "#include \"grpc++/impl/rpc_service_method.h\"\n"
 | 
	
		
			
				|  |  |           "#include \"grpc++/stream.h\"\n";
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void PrintHeaderClientMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  | -                       const google::protobuf::MethodDescriptor* method,
 | 
	
		
			
				|  |  | -                       map<string, string>* vars) {
 | 
	
		
			
				|  |  | +void PrintHeaderClientMethod(google::protobuf::io::Printer *printer,
 | 
	
		
			
				|  |  | +                             const google::protobuf::MethodDescriptor *method,
 | 
	
		
			
				|  |  | +                             std::map<std::string, std::string> *vars) {
 | 
	
		
			
				|  |  |    (*vars)["Method"] = method->name();
 | 
	
		
			
				|  |  |    (*vars)["Request"] =
 | 
	
		
			
				|  |  |        grpc_cpp_generator::ClassName(method->input_type(), true);
 | 
	
	
		
			
				|  | @@ -146,23 +146,23 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |    } else if (ClientOnlyStreaming(method)) {
 | 
	
		
			
				|  |  |      printer->Print(
 | 
	
		
			
				|  |  |          *vars,
 | 
	
		
			
				|  |  | -        "::grpc::ClientWriter<$Request$>* $Method$("
 | 
	
		
			
				|  |  | +        "::grpc::ClientWriter< $Request$>* $Method$("
 | 
	
		
			
				|  |  |          "::grpc::ClientContext* context, $Response$* response);\n\n");
 | 
	
		
			
				|  |  |    } else if (ServerOnlyStreaming(method)) {
 | 
	
		
			
				|  |  |      printer->Print(
 | 
	
		
			
				|  |  |          *vars,
 | 
	
		
			
				|  |  | -        "::grpc::ClientReader<$Response$>* $Method$("
 | 
	
		
			
				|  |  | +        "::grpc::ClientReader< $Response$>* $Method$("
 | 
	
		
			
				|  |  |          "::grpc::ClientContext* context, const $Request$* request);\n\n");
 | 
	
		
			
				|  |  |    } else if (BidiStreaming(method)) {
 | 
	
		
			
				|  |  |      printer->Print(*vars,
 | 
	
		
			
				|  |  | -                   "::grpc::ClientReaderWriter<$Request$, $Response$>* "
 | 
	
		
			
				|  |  | +                   "::grpc::ClientReaderWriter< $Request$, $Response$>* "
 | 
	
		
			
				|  |  |                     "$Method$(::grpc::ClientContext* context);\n\n");
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void PrintHeaderServerMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  | -                             const google::protobuf::MethodDescriptor* method,
 | 
	
		
			
				|  |  | -                             map<string, string>* vars) {
 | 
	
		
			
				|  |  | +void PrintHeaderServerMethod(google::protobuf::io::Printer *printer,
 | 
	
		
			
				|  |  | +                             const google::protobuf::MethodDescriptor *method,
 | 
	
		
			
				|  |  | +                             std::map<std::string, std::string> *vars) {
 | 
	
		
			
				|  |  |    (*vars)["Method"] = method->name();
 | 
	
		
			
				|  |  |    (*vars)["Request"] =
 | 
	
		
			
				|  |  |        grpc_cpp_generator::ClassName(method->input_type(), true);
 | 
	
	
		
			
				|  | @@ -177,25 +177,26 @@ void PrintHeaderServerMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |      printer->Print(*vars,
 | 
	
		
			
				|  |  |                     "virtual ::grpc::Status $Method$("
 | 
	
		
			
				|  |  |                     "::grpc::ServerContext* context, "
 | 
	
		
			
				|  |  | -                   "::grpc::ServerReader<$Request$>* reader, "
 | 
	
		
			
				|  |  | +                   "::grpc::ServerReader< $Request$>* reader, "
 | 
	
		
			
				|  |  |                     "$Response$* response);\n");
 | 
	
		
			
				|  |  |    } else if (ServerOnlyStreaming(method)) {
 | 
	
		
			
				|  |  |      printer->Print(*vars,
 | 
	
		
			
				|  |  |                     "virtual ::grpc::Status $Method$("
 | 
	
		
			
				|  |  |                     "::grpc::ServerContext* context, const $Request$* request, "
 | 
	
		
			
				|  |  | -                   "::grpc::ServerWriter<$Response$>* writer);\n");
 | 
	
		
			
				|  |  | +                   "::grpc::ServerWriter< $Response$>* writer);\n");
 | 
	
		
			
				|  |  |    } else if (BidiStreaming(method)) {
 | 
	
		
			
				|  |  | -    printer->Print(*vars,
 | 
	
		
			
				|  |  | -                   "virtual ::grpc::Status $Method$("
 | 
	
		
			
				|  |  | -                   "::grpc::ServerContext* context, "
 | 
	
		
			
				|  |  | -                   "::grpc::ServerReaderWriter<$Response$, $Request$>* stream);"
 | 
	
		
			
				|  |  | -                   "\n");
 | 
	
		
			
				|  |  | +    printer->Print(
 | 
	
		
			
				|  |  | +        *vars,
 | 
	
		
			
				|  |  | +        "virtual ::grpc::Status $Method$("
 | 
	
		
			
				|  |  | +        "::grpc::ServerContext* context, "
 | 
	
		
			
				|  |  | +        "::grpc::ServerReaderWriter< $Response$, $Request$>* stream);"
 | 
	
		
			
				|  |  | +        "\n");
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void PrintHeaderService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  | -                        const google::protobuf::ServiceDescriptor* service,
 | 
	
		
			
				|  |  | -                        map<string, string>* vars) {
 | 
	
		
			
				|  |  | +void PrintHeaderService(google::protobuf::io::Printer *printer,
 | 
	
		
			
				|  |  | +                        const google::protobuf::ServiceDescriptor *service,
 | 
	
		
			
				|  |  | +                        std::map<std::string, std::string> *vars) {
 | 
	
		
			
				|  |  |    (*vars)["Service"] = service->name();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    printer->Print(*vars,
 | 
	
	
		
			
				|  | @@ -204,8 +205,9 @@ void PrintHeaderService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |    printer->Indent();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    // Client side
 | 
	
		
			
				|  |  | -  printer->Print("class Stub : public ::grpc::InternalStub {\n"
 | 
	
		
			
				|  |  | -                 " public:\n");
 | 
	
		
			
				|  |  | +  printer->Print(
 | 
	
		
			
				|  |  | +      "class Stub : public ::grpc::InternalStub {\n"
 | 
	
		
			
				|  |  | +      " public:\n");
 | 
	
		
			
				|  |  |    printer->Indent();
 | 
	
		
			
				|  |  |    for (int i = 0; i < service->method_count(); ++i) {
 | 
	
		
			
				|  |  |      PrintHeaderClientMethod(printer, service->method(i), vars);
 | 
	
	
		
			
				|  | @@ -213,14 +215,15 @@ void PrintHeaderService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |    printer->Outdent();
 | 
	
		
			
				|  |  |    printer->Print("};\n");
 | 
	
		
			
				|  |  |    printer->Print(
 | 
	
		
			
				|  |  | -      "static Stub* NewStub(const std::shared_ptr<::grpc::ChannelInterface>& "
 | 
	
		
			
				|  |  | +      "static Stub* NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& "
 | 
	
		
			
				|  |  |        "channel);\n");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    printer->Print("\n");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    // Server side
 | 
	
		
			
				|  |  | -  printer->Print("class Service {\n"
 | 
	
		
			
				|  |  | -                " public:\n");
 | 
	
		
			
				|  |  | +  printer->Print(
 | 
	
		
			
				|  |  | +      "class Service {\n"
 | 
	
		
			
				|  |  | +      " public:\n");
 | 
	
		
			
				|  |  |    printer->Indent();
 | 
	
		
			
				|  |  |    printer->Print("Service() : service_(nullptr) {}\n");
 | 
	
		
			
				|  |  |    printer->Print("virtual ~Service();\n");
 | 
	
	
		
			
				|  | @@ -229,19 +232,20 @@ void PrintHeaderService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    printer->Print("::grpc::RpcService* service();\n");
 | 
	
		
			
				|  |  |    printer->Outdent();
 | 
	
		
			
				|  |  | -  printer->Print(" private:\n"
 | 
	
		
			
				|  |  | -                 "  ::grpc::RpcService* service_;\n");
 | 
	
		
			
				|  |  | +  printer->Print(
 | 
	
		
			
				|  |  | +      " private:\n"
 | 
	
		
			
				|  |  | +      "  ::grpc::RpcService* service_;\n");
 | 
	
		
			
				|  |  |    printer->Print("};\n");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    printer->Outdent();
 | 
	
		
			
				|  |  |    printer->Print("};\n");
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -string GetHeaderServices(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  | -  string output;
 | 
	
		
			
				|  |  | +std::string GetHeaderServices(const google::protobuf::FileDescriptor *file) {
 | 
	
		
			
				|  |  | +  std::string output;
 | 
	
		
			
				|  |  |    google::protobuf::io::StringOutputStream output_stream(&output);
 | 
	
		
			
				|  |  |    google::protobuf::io::Printer printer(&output_stream, '$');
 | 
	
		
			
				|  |  | -  map<string, string> vars;
 | 
	
		
			
				|  |  | +  std::map<std::string, std::string> vars;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    for (int i = 0; i < file->service_count(); ++i) {
 | 
	
		
			
				|  |  |      PrintHeaderService(&printer, file->service(i), &vars);
 | 
	
	
		
			
				|  | @@ -250,9 +254,9 @@ string GetHeaderServices(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  |    return output;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void PrintSourceClientMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  | -                       const google::protobuf::MethodDescriptor* method,
 | 
	
		
			
				|  |  | -                       map<string, string>* vars) {
 | 
	
		
			
				|  |  | +void PrintSourceClientMethod(google::protobuf::io::Printer *printer,
 | 
	
		
			
				|  |  | +                             const google::protobuf::MethodDescriptor *method,
 | 
	
		
			
				|  |  | +                             std::map<std::string, std::string> *vars) {
 | 
	
		
			
				|  |  |    (*vars)["Method"] = method->name();
 | 
	
		
			
				|  |  |    (*vars)["Request"] =
 | 
	
		
			
				|  |  |        grpc_cpp_generator::ClassName(method->input_type(), true);
 | 
	
	
		
			
				|  | @@ -269,11 +273,12 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |                     "context, request, response);\n"
 | 
	
		
			
				|  |  |                     "}\n\n");
 | 
	
		
			
				|  |  |    } else if (ClientOnlyStreaming(method)) {
 | 
	
		
			
				|  |  | +    printer->Print(
 | 
	
		
			
				|  |  | +        *vars,
 | 
	
		
			
				|  |  | +        "::grpc::ClientWriter< $Request$>* $Service$::Stub::$Method$("
 | 
	
		
			
				|  |  | +        "::grpc::ClientContext* context, $Response$* response) {\n");
 | 
	
		
			
				|  |  |      printer->Print(*vars,
 | 
	
		
			
				|  |  | -                   "::grpc::ClientWriter<$Request$>* $Service$::Stub::$Method$("
 | 
	
		
			
				|  |  | -                   "::grpc::ClientContext* context, $Response$* response) {\n");
 | 
	
		
			
				|  |  | -    printer->Print(*vars,
 | 
	
		
			
				|  |  | -                   "  return new ::grpc::ClientWriter<$Request$>("
 | 
	
		
			
				|  |  | +                   "  return new ::grpc::ClientWriter< $Request$>("
 | 
	
		
			
				|  |  |                     "channel()->CreateStream("
 | 
	
		
			
				|  |  |                     "::grpc::RpcMethod(\"/$Package$$Service$/$Method$\", "
 | 
	
		
			
				|  |  |                     "::grpc::RpcMethod::RpcType::CLIENT_STREAMING), "
 | 
	
	
		
			
				|  | @@ -282,10 +287,10 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |    } else if (ServerOnlyStreaming(method)) {
 | 
	
		
			
				|  |  |      printer->Print(
 | 
	
		
			
				|  |  |          *vars,
 | 
	
		
			
				|  |  | -        "::grpc::ClientReader<$Response$>* $Service$::Stub::$Method$("
 | 
	
		
			
				|  |  | +        "::grpc::ClientReader< $Response$>* $Service$::Stub::$Method$("
 | 
	
		
			
				|  |  |          "::grpc::ClientContext* context, const $Request$* request) {\n");
 | 
	
		
			
				|  |  |      printer->Print(*vars,
 | 
	
		
			
				|  |  | -                   "  return new ::grpc::ClientReader<$Response$>("
 | 
	
		
			
				|  |  | +                   "  return new ::grpc::ClientReader< $Response$>("
 | 
	
		
			
				|  |  |                     "channel()->CreateStream("
 | 
	
		
			
				|  |  |                     "::grpc::RpcMethod(\"/$Package$$Service$/$Method$\", "
 | 
	
		
			
				|  |  |                     "::grpc::RpcMethod::RpcType::SERVER_STREAMING), "
 | 
	
	
		
			
				|  | @@ -294,11 +299,11 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |    } else if (BidiStreaming(method)) {
 | 
	
		
			
				|  |  |      printer->Print(
 | 
	
		
			
				|  |  |          *vars,
 | 
	
		
			
				|  |  | -        "::grpc::ClientReaderWriter<$Request$, $Response$>* "
 | 
	
		
			
				|  |  | +        "::grpc::ClientReaderWriter< $Request$, $Response$>* "
 | 
	
		
			
				|  |  |          "$Service$::Stub::$Method$(::grpc::ClientContext* context) {\n");
 | 
	
		
			
				|  |  |      printer->Print(
 | 
	
		
			
				|  |  |          *vars,
 | 
	
		
			
				|  |  | -        "  return new ::grpc::ClientReaderWriter<$Request$, $Response$>("
 | 
	
		
			
				|  |  | +        "  return new ::grpc::ClientReaderWriter< $Request$, $Response$>("
 | 
	
		
			
				|  |  |          "channel()->CreateStream("
 | 
	
		
			
				|  |  |          "::grpc::RpcMethod(\"/$Package$$Service$/$Method$\", "
 | 
	
		
			
				|  |  |          "::grpc::RpcMethod::RpcType::BIDI_STREAMING), "
 | 
	
	
		
			
				|  | @@ -307,9 +312,9 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void PrintSourceServerMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  | -                       const google::protobuf::MethodDescriptor* method,
 | 
	
		
			
				|  |  | -                       map<string, string>* vars) {
 | 
	
		
			
				|  |  | +void PrintSourceServerMethod(google::protobuf::io::Printer *printer,
 | 
	
		
			
				|  |  | +                             const google::protobuf::MethodDescriptor *method,
 | 
	
		
			
				|  |  | +                             std::map<std::string, std::string> *vars) {
 | 
	
		
			
				|  |  |    (*vars)["Method"] = method->name();
 | 
	
		
			
				|  |  |    (*vars)["Request"] =
 | 
	
		
			
				|  |  |        grpc_cpp_generator::ClassName(method->input_type(), true);
 | 
	
	
		
			
				|  | @@ -328,7 +333,7 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |      printer->Print(*vars,
 | 
	
		
			
				|  |  |                     "::grpc::Status $Service$::Service::$Method$("
 | 
	
		
			
				|  |  |                     "::grpc::ServerContext* context, "
 | 
	
		
			
				|  |  | -                   "::grpc::ServerReader<$Request$>* reader, "
 | 
	
		
			
				|  |  | +                   "::grpc::ServerReader< $Request$>* reader, "
 | 
	
		
			
				|  |  |                     "$Response$* response) {\n");
 | 
	
		
			
				|  |  |      printer->Print(
 | 
	
		
			
				|  |  |          "  return ::grpc::Status("
 | 
	
	
		
			
				|  | @@ -339,7 +344,7 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |                     "::grpc::Status $Service$::Service::$Method$("
 | 
	
		
			
				|  |  |                     "::grpc::ServerContext* context, "
 | 
	
		
			
				|  |  |                     "const $Request$* request, "
 | 
	
		
			
				|  |  | -                   "::grpc::ServerWriter<$Response$>* writer) {\n");
 | 
	
		
			
				|  |  | +                   "::grpc::ServerWriter< $Response$>* writer) {\n");
 | 
	
		
			
				|  |  |      printer->Print(
 | 
	
		
			
				|  |  |          "  return ::grpc::Status("
 | 
	
		
			
				|  |  |          "::grpc::StatusCode::UNIMPLEMENTED);\n");
 | 
	
	
		
			
				|  | @@ -348,7 +353,7 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |      printer->Print(*vars,
 | 
	
		
			
				|  |  |                     "::grpc::Status $Service$::Service::$Method$("
 | 
	
		
			
				|  |  |                     "::grpc::ServerContext* context, "
 | 
	
		
			
				|  |  | -                   "::grpc::ServerReaderWriter<$Response$, $Request$>* "
 | 
	
		
			
				|  |  | +                   "::grpc::ServerReaderWriter< $Response$, $Request$>* "
 | 
	
		
			
				|  |  |                     "stream) {\n");
 | 
	
		
			
				|  |  |      printer->Print(
 | 
	
		
			
				|  |  |          "  return ::grpc::Status("
 | 
	
	
		
			
				|  | @@ -357,13 +362,14 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void PrintSourceService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  | -                        const google::protobuf::ServiceDescriptor* service,
 | 
	
		
			
				|  |  | -                        map<string, string>* vars) {
 | 
	
		
			
				|  |  | +void PrintSourceService(google::protobuf::io::Printer *printer,
 | 
	
		
			
				|  |  | +                        const google::protobuf::ServiceDescriptor *service,
 | 
	
		
			
				|  |  | +                        std::map<std::string, std::string> *vars) {
 | 
	
		
			
				|  |  |    (*vars)["Service"] = service->name();
 | 
	
		
			
				|  |  | -  printer->Print(*vars,
 | 
	
		
			
				|  |  | +  printer->Print(
 | 
	
		
			
				|  |  | +      *vars,
 | 
	
		
			
				|  |  |        "$Service$::Stub* $Service$::NewStub("
 | 
	
		
			
				|  |  | -      "const std::shared_ptr<::grpc::ChannelInterface>& channel) {\n"
 | 
	
		
			
				|  |  | +      "const std::shared_ptr< ::grpc::ChannelInterface>& channel) {\n"
 | 
	
		
			
				|  |  |        "  $Service$::Stub* stub = new $Service$::Stub();\n"
 | 
	
		
			
				|  |  |        "  stub->set_channel(channel);\n"
 | 
	
		
			
				|  |  |        "  return stub;\n"
 | 
	
	
		
			
				|  | @@ -380,14 +386,15 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |      PrintSourceServerMethod(printer, service->method(i), vars);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    printer->Print(*vars,
 | 
	
		
			
				|  |  | -      "::grpc::RpcService* $Service$::Service::service() {\n");
 | 
	
		
			
				|  |  | +                 "::grpc::RpcService* $Service$::Service::service() {\n");
 | 
	
		
			
				|  |  |    printer->Indent();
 | 
	
		
			
				|  |  | -  printer->Print("if (service_ != nullptr) {\n"
 | 
	
		
			
				|  |  | -                 "  return service_;\n"
 | 
	
		
			
				|  |  | -                 "}\n");
 | 
	
		
			
				|  |  | +  printer->Print(
 | 
	
		
			
				|  |  | +      "if (service_ != nullptr) {\n"
 | 
	
		
			
				|  |  | +      "  return service_;\n"
 | 
	
		
			
				|  |  | +      "}\n");
 | 
	
		
			
				|  |  |    printer->Print("service_ = new ::grpc::RpcService();\n");
 | 
	
		
			
				|  |  |    for (int i = 0; i < service->method_count(); ++i) {
 | 
	
		
			
				|  |  | -    const google::protobuf::MethodDescriptor* method = service->method(i);
 | 
	
		
			
				|  |  | +    const google::protobuf::MethodDescriptor *method = service->method(i);
 | 
	
		
			
				|  |  |      (*vars)["Method"] = method->name();
 | 
	
		
			
				|  |  |      (*vars)["Request"] =
 | 
	
		
			
				|  |  |          grpc_cpp_generator::ClassName(method->input_type(), true);
 | 
	
	
		
			
				|  | @@ -399,9 +406,9 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |            "service_->AddMethod(new ::grpc::RpcServiceMethod(\n"
 | 
	
		
			
				|  |  |            "    \"/$Package$$Service$/$Method$\",\n"
 | 
	
		
			
				|  |  |            "    ::grpc::RpcMethod::NORMAL_RPC,\n"
 | 
	
		
			
				|  |  | -          "    new ::grpc::RpcMethodHandler<$Service$::Service, $Request$, "
 | 
	
		
			
				|  |  | +          "    new ::grpc::RpcMethodHandler< $Service$::Service, $Request$, "
 | 
	
		
			
				|  |  |            "$Response$>(\n"
 | 
	
		
			
				|  |  | -          "        std::function<::grpc::Status($Service$::Service*, "
 | 
	
		
			
				|  |  | +          "        std::function< ::grpc::Status($Service$::Service*, "
 | 
	
		
			
				|  |  |            "::grpc::ServerContext*, const $Request$*, $Response$*)>("
 | 
	
		
			
				|  |  |            "&$Service$::Service::$Method$), this),\n"
 | 
	
		
			
				|  |  |            "    new $Request$, new $Response$));\n");
 | 
	
	
		
			
				|  | @@ -411,11 +418,11 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |            "service_->AddMethod(new ::grpc::RpcServiceMethod(\n"
 | 
	
		
			
				|  |  |            "    \"/$Package$$Service$/$Method$\",\n"
 | 
	
		
			
				|  |  |            "    ::grpc::RpcMethod::CLIENT_STREAMING,\n"
 | 
	
		
			
				|  |  | -          "    new ::grpc::ClientStreamingHandler<"
 | 
	
		
			
				|  |  | +          "    new ::grpc::ClientStreamingHandler< "
 | 
	
		
			
				|  |  |            "$Service$::Service, $Request$, $Response$>(\n"
 | 
	
		
			
				|  |  | -          "        std::function<::grpc::Status($Service$::Service*, "
 | 
	
		
			
				|  |  | +          "        std::function< ::grpc::Status($Service$::Service*, "
 | 
	
		
			
				|  |  |            "::grpc::ServerContext*, "
 | 
	
		
			
				|  |  | -          "::grpc::ServerReader<$Request$>*, $Response$*)>("
 | 
	
		
			
				|  |  | +          "::grpc::ServerReader< $Request$>*, $Response$*)>("
 | 
	
		
			
				|  |  |            "&$Service$::Service::$Method$), this),\n"
 | 
	
		
			
				|  |  |            "    new $Request$, new $Response$));\n");
 | 
	
		
			
				|  |  |      } else if (ServerOnlyStreaming(method)) {
 | 
	
	
		
			
				|  | @@ -424,11 +431,11 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |            "service_->AddMethod(new ::grpc::RpcServiceMethod(\n"
 | 
	
		
			
				|  |  |            "    \"/$Package$$Service$/$Method$\",\n"
 | 
	
		
			
				|  |  |            "    ::grpc::RpcMethod::SERVER_STREAMING,\n"
 | 
	
		
			
				|  |  | -          "    new ::grpc::ServerStreamingHandler<"
 | 
	
		
			
				|  |  | +          "    new ::grpc::ServerStreamingHandler< "
 | 
	
		
			
				|  |  |            "$Service$::Service, $Request$, $Response$>(\n"
 | 
	
		
			
				|  |  | -          "        std::function<::grpc::Status($Service$::Service*, "
 | 
	
		
			
				|  |  | +          "        std::function< ::grpc::Status($Service$::Service*, "
 | 
	
		
			
				|  |  |            "::grpc::ServerContext*, "
 | 
	
		
			
				|  |  | -          "const $Request$*, ::grpc::ServerWriter<$Response$>*)>("
 | 
	
		
			
				|  |  | +          "const $Request$*, ::grpc::ServerWriter< $Response$>*)>("
 | 
	
		
			
				|  |  |            "&$Service$::Service::$Method$), this),\n"
 | 
	
		
			
				|  |  |            "    new $Request$, new $Response$));\n");
 | 
	
		
			
				|  |  |      } else if (BidiStreaming(method)) {
 | 
	
	
		
			
				|  | @@ -437,11 +444,11 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |            "service_->AddMethod(new ::grpc::RpcServiceMethod(\n"
 | 
	
		
			
				|  |  |            "    \"/$Package$$Service$/$Method$\",\n"
 | 
	
		
			
				|  |  |            "    ::grpc::RpcMethod::BIDI_STREAMING,\n"
 | 
	
		
			
				|  |  | -          "    new ::grpc::BidiStreamingHandler<"
 | 
	
		
			
				|  |  | +          "    new ::grpc::BidiStreamingHandler< "
 | 
	
		
			
				|  |  |            "$Service$::Service, $Request$, $Response$>(\n"
 | 
	
		
			
				|  |  | -          "        std::function<::grpc::Status($Service$::Service*, "
 | 
	
		
			
				|  |  | +          "        std::function< ::grpc::Status($Service$::Service*, "
 | 
	
		
			
				|  |  |            "::grpc::ServerContext*, "
 | 
	
		
			
				|  |  | -          "::grpc::ServerReaderWriter<$Response$, $Request$>*)>("
 | 
	
		
			
				|  |  | +          "::grpc::ServerReaderWriter< $Response$, $Request$>*)>("
 | 
	
		
			
				|  |  |            "&$Service$::Service::$Method$), this),\n"
 | 
	
		
			
				|  |  |            "    new $Request$, new $Response$));\n");
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -451,11 +458,11 @@ void PrintSourceService(google::protobuf::io::Printer* printer,
 | 
	
		
			
				|  |  |    printer->Print("}\n\n");
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -string GetSourceServices(const google::protobuf::FileDescriptor* file) {
 | 
	
		
			
				|  |  | -  string output;
 | 
	
		
			
				|  |  | +std::string GetSourceServices(const google::protobuf::FileDescriptor *file) {
 | 
	
		
			
				|  |  | +  std::string output;
 | 
	
		
			
				|  |  |    google::protobuf::io::StringOutputStream output_stream(&output);
 | 
	
		
			
				|  |  |    google::protobuf::io::Printer printer(&output_stream, '$');
 | 
	
		
			
				|  |  | -  map<string, string> vars;
 | 
	
		
			
				|  |  | +  std::map<std::string, std::string> vars;
 | 
	
		
			
				|  |  |    // Package string is empty or ends with a dot. It is used to fully qualify
 | 
	
		
			
				|  |  |    // method names.
 | 
	
		
			
				|  |  |    vars["Package"] = file->package();
 |