| 90 | }; |
| 91 | |
| 92 | class BaseGenerator { |
| 93 | public: |
| 94 | virtual bool generate() = 0; |
| 95 | |
| 96 | static std::string NamespaceDir(const Parser &parser, const std::string &path, |
| 97 | const Namespace &ns, |
| 98 | const bool dasherize = false); |
| 99 | |
| 100 | static std::string ToDasherizedCase(const std::string pascal_case); |
| 101 | |
| 102 | std::string GeneratedFileName(const std::string &path, |
| 103 | const std::string &file_name, |
| 104 | const IDLOptions &options) const; |
| 105 | |
| 106 | protected: |
| 107 | BaseGenerator(const Parser &parser, const std::string &path, |
| 108 | const std::string &file_name, std::string qualifying_start, |
| 109 | std::string qualifying_separator, std::string default_extension) |
| 110 | : parser_(parser), |
| 111 | path_(path), |
| 112 | file_name_(file_name), |
| 113 | qualifying_start_(qualifying_start), |
| 114 | qualifying_separator_(qualifying_separator), |
| 115 | default_extension_(default_extension) {} |
| 116 | virtual ~BaseGenerator() {} |
| 117 | |
| 118 | // No copy/assign. |
| 119 | BaseGenerator &operator=(const BaseGenerator &); |
| 120 | BaseGenerator(const BaseGenerator &); |
| 121 | |
| 122 | std::string NamespaceDir(const Namespace &ns, |
| 123 | const bool dasherize = false) const; |
| 124 | |
| 125 | static const char *FlatBuffersGeneratedWarning(); |
| 126 | |
| 127 | static std::string FullNamespace(const char *separator, const Namespace &ns); |
| 128 | |
| 129 | static std::string LastNamespacePart(const Namespace &ns); |
| 130 | |
| 131 | // tracks the current namespace for early exit in WrapInNameSpace |
| 132 | // c++, java and csharp returns a different namespace from |
| 133 | // the following default (no early exit, always fully qualify), |
| 134 | // which works for js and php |
| 135 | virtual const Namespace *CurrentNameSpace() const { return nullptr; } |
| 136 | |
| 137 | // Ensure that a type is prefixed with its namespace even within |
| 138 | // its own namespace to avoid conflict between generated method |
| 139 | // names and similarly named classes or structs |
| 140 | std::string WrapInNameSpace(const Namespace *ns, |
| 141 | const std::string &name) const; |
| 142 | |
| 143 | std::string WrapInNameSpace(const Definition &def) const; |
| 144 | |
| 145 | std::string GetNameSpace(const Definition &def) const; |
| 146 | |
| 147 | const Parser &parser_; |
| 148 | const std::string &path_; |
| 149 | const std::string &file_name_; |
nothing calls this directly
no outgoing calls
no test coverage detected