|
|
|
@ -31,6 +31,9 @@ |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <string> |
|
|
|
|
#include <map> |
|
|
|
|
|
|
|
|
|
#include "src/compiler/cpp_generator.h" |
|
|
|
|
|
|
|
|
|
#include "src/compiler/cpp_generator_helpers.h" |
|
|
|
@ -92,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" |
|
|
|
@ -121,7 +124,7 @@ 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" |
|
|
|
@ -130,7 +133,7 @@ string GetSourceIncludes() { |
|
|
|
|
|
|
|
|
|
void PrintHeaderClientMethod(google::protobuf::io::Printer* printer, |
|
|
|
|
const google::protobuf::MethodDescriptor* method, |
|
|
|
|
map<string, string>* vars) { |
|
|
|
|
std::map<std::string, std::string>* vars) { |
|
|
|
|
(*vars)["Method"] = method->name(); |
|
|
|
|
(*vars)["Request"] = |
|
|
|
|
grpc_cpp_generator::ClassName(method->input_type(), true); |
|
|
|
@ -159,7 +162,7 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer* printer, |
|
|
|
|
|
|
|
|
|
void PrintHeaderServerMethod(google::protobuf::io::Printer* printer, |
|
|
|
|
const google::protobuf::MethodDescriptor* method, |
|
|
|
|
map<string, string>* vars) { |
|
|
|
|
std::map<std::string, std::string>* vars) { |
|
|
|
|
(*vars)["Method"] = method->name(); |
|
|
|
|
(*vars)["Request"] = |
|
|
|
|
grpc_cpp_generator::ClassName(method->input_type(), true); |
|
|
|
@ -193,7 +196,7 @@ void PrintHeaderServerMethod(google::protobuf::io::Printer* printer, |
|
|
|
|
|
|
|
|
|
void PrintHeaderService(google::protobuf::io::Printer* printer, |
|
|
|
|
const google::protobuf::ServiceDescriptor* service, |
|
|
|
|
map<string, string>* vars) { |
|
|
|
|
std::map<std::string, std::string>* vars) { |
|
|
|
|
(*vars)["Service"] = service->name(); |
|
|
|
|
|
|
|
|
|
printer->Print(*vars, |
|
|
|
@ -238,11 +241,11 @@ void PrintHeaderService(google::protobuf::io::Printer* printer, |
|
|
|
|
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); |
|
|
|
@ -253,7 +256,7 @@ string GetHeaderServices(const google::protobuf::FileDescriptor* file) { |
|
|
|
|
|
|
|
|
|
void PrintSourceClientMethod(google::protobuf::io::Printer* printer, |
|
|
|
|
const google::protobuf::MethodDescriptor* method, |
|
|
|
|
map<string, string>* vars) { |
|
|
|
|
std::map<std::string, std::string>* vars) { |
|
|
|
|
(*vars)["Method"] = method->name(); |
|
|
|
|
(*vars)["Request"] = |
|
|
|
|
grpc_cpp_generator::ClassName(method->input_type(), true); |
|
|
|
@ -311,7 +314,7 @@ void PrintSourceClientMethod(google::protobuf::io::Printer* printer, |
|
|
|
|
|
|
|
|
|
void PrintSourceServerMethod(google::protobuf::io::Printer* printer, |
|
|
|
|
const google::protobuf::MethodDescriptor* method, |
|
|
|
|
map<string, string>* vars) { |
|
|
|
|
std::map<std::string, std::string>* vars) { |
|
|
|
|
(*vars)["Method"] = method->name(); |
|
|
|
|
(*vars)["Request"] = |
|
|
|
|
grpc_cpp_generator::ClassName(method->input_type(), true); |
|
|
|
@ -361,7 +364,7 @@ void PrintSourceServerMethod(google::protobuf::io::Printer* printer, |
|
|
|
|
|
|
|
|
|
void PrintSourceService(google::protobuf::io::Printer* printer, |
|
|
|
|
const google::protobuf::ServiceDescriptor* service, |
|
|
|
|
map<string, string>* vars) { |
|
|
|
|
std::map<std::string, std::string>* vars) { |
|
|
|
|
(*vars)["Service"] = service->name(); |
|
|
|
|
printer->Print( |
|
|
|
|
*vars, |
|
|
|
@ -455,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(); |
|
|
|
|