#include <BnetServiceGenerator.h>
18 if (options.dllexport_decl.empty())
19 vars_[
"dllexport"] =
"";
21 vars_[
"dllexport"] = options.dllexport_decl +
" ";
string ToUpper(const string &s)
Definition: strutil.h:152
const string & name() const
extern::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::ServiceOptions,::google::protobuf::internal::StringTypeTraits, 9, false > original_fully_qualified_descriptor_name
Definition: service_options.pb.h:44
const string & full_name() const
LIBPROTOBUF_EXPORT string ToHex(uint64 num)
std::uint32_t HashServiceName(std::string const &name)
Definition: BnetServiceGenerator.cpp:309
const pb::ServiceDescriptor * descriptor_
Definition: BnetServiceGenerator.h:80
std::map< std::string, std::string > vars_
Definition: BnetServiceGenerator.h:81
const ServiceOptions & options() const
BnetServiceGenerator::~BnetServiceGenerator |
( |
| ) |
|
void BnetServiceGenerator::GenerateClientMethodImplementations |
( |
pb::io::Printer * |
printer | ) |
|
|
private |
167 std::map<std::string, std::string> sub_vars;
168 sub_vars[
"classname"] =
vars_[
"classname"];
169 sub_vars[
"name"] = method->
name();
178 printer->Print(sub_vars,
179 "void $classname$::$name$($input_type$ const* request, std::function<void($output_type$ const*)> responseCallback) {\n"
180 " TC_LOG_DEBUG(\"service.protobuf\", \"%s Server called client method $full_name$($input_type_name${ %s })\",\n"
181 " GetCallerInfo().c_str(), request->ShortDebugString().c_str());\n"
182 " std::function<void(MessageBuffer)> callback = [responseCallback](MessageBuffer buffer) -> void {\n"
183 " $output_type$ response;\n"
184 " if (response.ParseFromArray(buffer.GetReadPointer(), buffer.GetActiveSize()))\n"
185 " responseCallback(&response);\n"
187 " SendRequest(service_hash_, $method_id$, request, std::move(callback));\n"
193 printer->Print(sub_vars,
194 "void $classname$::$name$($input_type$ const* request) { \n"
195 " TC_LOG_DEBUG(\"service.protobuf\", \"%s Server called client method $full_name$($input_type_name${ %s })\",\n"
196 " GetCallerInfo().c_str(), request->ShortDebugString().c_str());\n"
197 " SendRequest(service_hash_, $method_id$, request);\n"
Definition: descriptor.h:918
extern::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MethodOptions,::google::protobuf::internal::PrimitiveTypeTraits< ::google::protobuf::uint32 >, 13, false > method_id
Definition: method_options.pb.h:44
const MethodOptions & options() const
const Descriptor * output_type() const
const string & name() const
const string & name() const
const Descriptor * input_type() const
const string & full_name() const
const string & name() const
LIBPROTOBUF_EXPORT string SimpleItoa(int i)
const pb::ServiceDescriptor * descriptor_
Definition: BnetServiceGenerator.h:80
std::map< std::string, std::string > vars_
Definition: BnetServiceGenerator.h:81
string ClassName(const Descriptor *descriptor, bool qualified)
const MethodDescriptor * method(int index) const
void BnetServiceGenerator::GenerateClientMethodSignatures |
( |
pb::io::Printer * |
printer | ) |
|
|
private |
91 std::map<std::string, std::string> sub_vars;
92 sub_vars[
"name"] = method->
name();
100 printer->Print(sub_vars,
"void $name$($input_type$ const* request, std::function<void($output_type$ const*)> responseCallback);\n");
102 printer->Print(sub_vars,
"void $name$($input_type$ const* request);\n");
Definition: descriptor.h:918
extern::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MethodOptions,::google::protobuf::internal::PrimitiveTypeTraits< ::google::protobuf::uint32 >, 13, false > method_id
Definition: method_options.pb.h:44
const MethodOptions & options() const
const Descriptor * output_type() const
const string & name() const
const string & name() const
const Descriptor * input_type() const
const string & full_name() const
const string & name() const
LIBPROTOBUF_EXPORT string SimpleItoa(int i)
const pb::ServiceDescriptor * descriptor_
Definition: BnetServiceGenerator.h:80
string ClassName(const Descriptor *descriptor, bool qualified)
const MethodDescriptor * method(int index) const
void BnetServiceGenerator::GenerateDeclarations |
( |
pb::io::Printer * |
printer | ) |
|
void GenerateInterface(pb::io::Printer *printer)
Definition: BnetServiceGenerator.cpp:34
void BnetServiceGenerator::GenerateDescriptorInitializer |
( |
pb::io::Printer * |
printer, |
|
|
int |
index |
|
) |
| |
130 std::map<std::string, std::string> vars;
134 printer->Print(vars,
"$classname$_descriptor_ = file->service($index$);\n");
const string & name() const
LIBPROTOBUF_EXPORT string SimpleItoa(int i)
const pb::ServiceDescriptor * descriptor_
Definition: BnetServiceGenerator.h:80
void BnetServiceGenerator::GenerateImplementation |
( |
pb::io::Printer * |
printer | ) |
|
141 printer->Print(
vars_,
142 "$classname$::$classname$(bool use_original_hash) : service_hash_(use_original_hash ? OriginalHash::value : NameHash::value) {\n"
145 "$classname$::~$classname$() {\n"
148 "google::protobuf::ServiceDescriptor const* $classname$::descriptor() {\n"
149 " protobuf_AssignDescriptorsOnce();\n"
150 " return $classname$_descriptor_;\n"
void GenerateServerCallMethod(pb::io::Printer *printer)
Definition: BnetServiceGenerator.cpp:204
void GenerateClientMethodImplementations(pb::io::Printer *printer)
Definition: BnetServiceGenerator.cpp:159
void GenerateServerImplementations(pb::io::Printer *printer)
Definition: BnetServiceGenerator.cpp:273
std::map< std::string, std::string > vars_
Definition: BnetServiceGenerator.h:81
void BnetServiceGenerator::GenerateInterface |
( |
pb::io::Printer * |
printer | ) |
|
|
private |
37 "class $dllexport$$classname$ : public ServiceBase\n"
41 " explicit $classname$(bool use_original_hash);\n"
42 " virtual ~$classname$();\n"
51 "static google::protobuf::ServiceDescriptor const* descriptor();\n"
53 "// client methods --------------------------------------------------\n"
59 "// server methods --------------------------------------------------\n"
61 "void CallServerMethod(uint32 token, uint32 methodId, MessageBuffer buffer) override final;\n"
66 printer->Print(
" protected:\n ");
77 " uint32 service_hash_;\n"
79 " GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($classname$);\n"
void GenerateClientMethodSignatures(pb::io::Printer *printer)
Definition: BnetServiceGenerator.cpp:83
void GenerateServerMethodSignatures(pb::io::Printer *printer)
Definition: BnetServiceGenerator.cpp:106
std::map< std::string, std::string > vars_
Definition: BnetServiceGenerator.h:81
void BnetServiceGenerator::GenerateServerCallMethod |
( |
pb::io::Printer * |
printer | ) |
|
|
private |
206 printer->Print(
vars_,
207 "void $classname$::CallServerMethod(uint32 token, uint32 methodId, MessageBuffer buffer) {\n"
208 " switch(methodId) {\n");
216 std::map<std::string, std::string> sub_vars;
217 sub_vars[
"name"] = method->
name();
225 printer->Print(sub_vars,
226 " case $method_id$: {\n"
227 " $input_type$ request;\n"
228 " if (!request.ParseFromArray(buffer.GetReadPointer(), buffer.GetActiveSize())) {\n"
229 " TC_LOG_DEBUG(\"service.protobuf\", \"%s Failed to parse request for $full_name$ server method call.\", GetCallerInfo().c_str());\n"
230 " SendResponse(service_hash_, $method_id$, token, ERROR_RPC_MALFORMED_REQUEST);\n"
238 printer->Print(sub_vars,
239 " $output_type$ response;\n"
240 " uint32 status = Handle$name$(&request, &response);\n"
241 " TC_LOG_DEBUG(\"service.protobuf\", \"%s Client called server method $full_name$($input_type_name${ %s }) returned $output_type_name${ %s } status %u.\",\n"
242 " GetCallerInfo().c_str(), request.ShortDebugString().c_str(), response.ShortDebugString().c_str(), status);\n"
244 " SendResponse(service_hash_, $method_id$, token, &response);\n"
246 " SendResponse(service_hash_, $method_id$, token, status);\n");
250 printer->Print(sub_vars,
251 " uint32 status = Handle$name$(&request);\n"
252 " TC_LOG_DEBUG(\"service.protobuf\", \"%s Client called server method $full_name$($input_type_name${ %s }) status %u.\",\n"
253 " GetCallerInfo().c_str(), request.ShortDebugString().c_str(), status);\n"
255 " SendResponse(service_hash_, $method_id$, token, status);\n");
258 printer->Print(sub_vars,
263 printer->Print(
vars_,
265 " TC_LOG_ERROR(\"service.protobuf\", \"Bad method id %u.\", methodId);\n"
266 " SendResponse(service_hash_, methodId, token, ERROR_RPC_INVALID_METHOD);\n"
Definition: descriptor.h:918
extern::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MethodOptions,::google::protobuf::internal::PrimitiveTypeTraits< ::google::protobuf::uint32 >, 13, false > method_id
Definition: method_options.pb.h:44
const MethodOptions & options() const
const Descriptor * output_type() const
const string & name() const
const string & name() const
const Descriptor * input_type() const
const string & full_name() const
const string & name() const
LIBPROTOBUF_EXPORT string SimpleItoa(int i)
const pb::ServiceDescriptor * descriptor_
Definition: BnetServiceGenerator.h:80
std::map< std::string, std::string > vars_
Definition: BnetServiceGenerator.h:81
string ClassName(const Descriptor *descriptor, bool qualified)
const MethodDescriptor * method(int index) const
void BnetServiceGenerator::GenerateServerImplementations |
( |
pb::io::Printer * |
printer | ) |
|
|
private |
281 std::map<std::string, std::string> sub_vars;
282 sub_vars[
"classname"] =
vars_[
"classname"];
283 sub_vars[
"name"] = method->
name();
290 printer->Print(sub_vars,
"uint32 $classname$::Handle$name$($input_type$ const* request, $output_type$* response) {\n"
291 " TC_LOG_ERROR(\"service.protobuf\", \"%s Client tried to call not implemented method $full_name$({ %s })\",\n"
292 " GetCallerInfo().c_str(), request->ShortDebugString().c_str());\n"
293 " return ERROR_RPC_NOT_IMPLEMENTED;\n"
299 printer->Print(sub_vars,
"uint32 $classname$::Handle$name$($input_type$ const* request) {\n"
300 " TC_LOG_ERROR(\"service.protobuf\", \"%s Client tried to call not implemented method $full_name$({ %s })\",\n"
301 " GetCallerInfo().c_str(), request->ShortDebugString().c_str());\n"
302 " return ERROR_RPC_NOT_IMPLEMENTED;\n"
Definition: descriptor.h:918
extern::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MethodOptions,::google::protobuf::internal::PrimitiveTypeTraits< ::google::protobuf::uint32 >, 13, false > method_id
Definition: method_options.pb.h:44
const MethodOptions & options() const
const Descriptor * output_type() const
const string & name() const
const string & name() const
const Descriptor * input_type() const
const string & name() const
const pb::ServiceDescriptor * descriptor_
Definition: BnetServiceGenerator.h:80
std::map< std::string, std::string > vars_
Definition: BnetServiceGenerator.h:81
string ClassName(const Descriptor *descriptor, bool qualified)
const MethodDescriptor * method(int index) const
void BnetServiceGenerator::GenerateServerMethodSignatures |
( |
pb::io::Printer * |
printer | ) |
|
|
private |
114 std::map<std::string, std::string> sub_vars;
115 sub_vars[
"name"] = method->
name();
120 printer->Print(sub_vars,
"virtual uint32 Handle$name$($input_type$ const* request, $output_type$* response);\n");
122 printer->Print(sub_vars,
"virtual uint32 Handle$name$($input_type$ const* request);\n");
Definition: descriptor.h:918
extern::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::MethodOptions,::google::protobuf::internal::PrimitiveTypeTraits< ::google::protobuf::uint32 >, 13, false > method_id
Definition: method_options.pb.h:44
const MethodOptions & options() const
const Descriptor * output_type() const
const string & name() const
const Descriptor * input_type() const
const string & name() const
const pb::ServiceDescriptor * descriptor_
Definition: BnetServiceGenerator.h:80
string ClassName(const Descriptor *descriptor, bool qualified)
const MethodDescriptor * method(int index) const
312 for (std::size_t i = 0; i < name.length(); ++i)
#define hash
Definition: private_namespace.h:186
unsigned int uint32_t
Definition: stdint.h:80
std::map<std::string, std::string> BnetServiceGenerator::vars_ |
|
private |
The documentation for this class was generated from the following files: