TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BnetCodeGenerator Class Reference

#include <BnetCodeGenerator.h>

Public Member Functions

bool Generate (pb::FileDescriptor const *file, std::string const &parameter, pbc::GeneratorContext *generator_context, std::string *error) const override
 

Member Function Documentation

bool BnetCodeGenerator::Generate ( pb::FileDescriptor const file,
std::string const parameter,
pbc::GeneratorContext *  generator_context,
std::string *  error 
) const
override
16 {
17  std::vector<std::pair<std::string, std::string>> options;
18  google::protobuf::compiler::ParseGeneratorParameter(parameter, &options);
19 
20  // -----------------------------------------------------------------
21  // parse generator options
22 
24 
25  for (int i = 0; i < options.size(); i++)
26  {
27  if (options[i].first == "dllexport_decl")
28  {
29  file_options.dllexport_decl = options[i].second;
30  }
31  else if (options[i].first == "safe_boundary_check")
32  {
33  file_options.safe_boundary_check = true;
34  }
35  else
36  {
37  *error = "Unknown generator option: " + options[i].first;
38  return false;
39  }
40  }
41 
42  // -----------------------------------------------------------------
43 
44 
45  std::string basename = google::protobuf::compiler::cpp::StripProto(file->name());
46  basename.append(".pb");
47 
48  BnetFileGenerator file_generator(file, file_options);
49 
50  // Generate header.
51  {
52  pb::scoped_ptr <google::protobuf::io::ZeroCopyOutputStream> output(
53  generator_context->Open(basename + ".h"));
54  google::protobuf::io::Printer printer(output.get(), '$');
55  file_generator.GenerateHeader(&printer);
56  }
57 
58  // Generate cc file.
59  {
60  pb::scoped_ptr <google::protobuf::io::ZeroCopyOutputStream> output(
61  generator_context->Open(basename + ".cc"));
62  google::protobuf::io::Printer printer(output.get(), '$');
63  file_generator.GenerateSource(&printer);
64  }
65 
66  return true;
67 }
Definition: cpp_options.h:45
#define output
Definition: wire_format_lite.h:381
Definition: BnetFileGenerator.h:76
Definition: printer.h:64
bool safe_boundary_check
Definition: cpp_options.h:49
string StripProto(const string &filename)
string dllexport_decl
Definition: cpp_options.h:48

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: