34 #ifndef GRPC_INTERNAL_COMPILER_CPP_GENERATOR_HELPERS_H
35 #define GRPC_INTERNAL_COMPILER_CPP_GENERATOR_HELPERS_H
38 #include "src/compiler/config.h"
39 #include "src/compiler/generator_helpers.h"
41 namespace grpc_cpp_generator {
43 inline grpc::string DotsToColons(
const grpc::string &name) {
44 return grpc_generator::StringReplace(name,
".",
"::");
47 inline grpc::string DotsToUnderscores(
const grpc::string &name) {
48 return grpc_generator::StringReplace(name,
".",
"_");
51 inline grpc::string ClassName(
const grpc::protobuf::Descriptor *descriptor,
55 const grpc::protobuf::Descriptor *outer = descriptor;
56 while (outer->containing_type() != NULL) outer = outer->containing_type();
58 const grpc::string &outer_name = outer->full_name();
59 grpc::string inner_name = descriptor->full_name().substr(outer_name.size());
62 return "::" + DotsToColons(outer_name) + DotsToUnderscores(inner_name);
64 return outer->name() + DotsToUnderscores(inner_name);
70 #endif // GRPC_INTERNAL_COMPILER_CPP_GENERATOR_HELPERS_H