CppPlugin.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Generates C++ tars service interface out of Protobuf IDL.
  2. //
  3. // This is a Proto2 compiler plugin. See net/proto2/compiler/proto/plugin.proto
  4. // and net/proto2/compiler/public/plugin.h for more information on plugins.
  5. #include <string>
  6. #include <google/protobuf/compiler/code_generator.h>
  7. namespace google
  8. {
  9. namespace protobuf
  10. {
  11. class FileDescriptor;
  12. }
  13. }
  14. class CppTarsGenerator : public google::protobuf::compiler::CodeGenerator {
  15. public:
  16. CppTarsGenerator() {}
  17. virtual ~CppTarsGenerator() {}
  18. bool Generate(const google::protobuf::FileDescriptor *file,
  19. const std::string &parameter,
  20. google::protobuf::compiler::GeneratorContext *context,
  21. std::string *error) const; //override final;
  22. private:
  23. bool _CheckFile(const google::protobuf::FileDescriptor* file, std::string* error) const;
  24. static std::string _GenHeader(const std::string& file);
  25. static std::string _GenNamespaceBegin(const std::string& ns);
  26. static std::string _GenNamespaceEnd(const std::string& ns);
  27. static std::string _GenResponse(const std::string& filename, const std::string& content);
  28. };