diff --git a/core/generator/Generator.cc b/core/generator/Generator.cc index a4a64671..9c835242 100644 --- a/core/generator/Generator.cc +++ b/core/generator/Generator.cc @@ -43,21 +43,7 @@ #include "Generator.hh" -namespace google { -namespace protobuf { -namespace compiler { -namespace cpp { - -///////////////////////////////////////////////// -void replaceAll(std::string &_src, const std::string &_oldValue, - const std::string &_newValue) -{ - for (size_t i = 0; (i = _src.find(_oldValue, i)) != std::string::npos;) - { - _src.replace(i, _oldValue.length(), _newValue); - i += _newValue.length() - _oldValue.length() + 1; - } -} +namespace google::protobuf::compiler::cpp { ///////////////////////////////////////////////// std::vector getNamespaces(const std::string &_package) @@ -65,13 +51,12 @@ std::vector getNamespaces(const std::string &_package) std::vector result; std::stringstream ss(_package); std::string item; - while (getline (ss, item, '.')) { - result.push_back (item); + while(getline (ss, item, '.')) { + result.push_back(item); } return result; } - ///////////////////////////////////////////////// Generator::Generator(const std::string &/*_name*/) { @@ -102,16 +87,14 @@ bool Generator::Generate(const FileDescriptor *_file, std::string identifier; std::string headerFilename; std::string newHeaderFilename; - std::string sourceFilename; // Can't use pathJoin because protoc always expects forward slashes // regardless of platform - for (auto part : parent_path) + for (const auto &part : parent_path) { identifier += part.string() + "_"; headerFilename += part.string() + "/"; newHeaderFilename += part.string() + "/"; - sourceFilename += part.string() + "/"; } std::unique_ptr message_type_index( @@ -121,7 +104,6 @@ bool Generator::Generate(const FileDescriptor *_file, identifier += fileStem; headerFilename += fileStem + ".gz.h"; newHeaderFilename += "details/" + fileStem + ".pb.h"; - sourceFilename += fileStem + ".pb.cc"; std::map variables; variables["filename"] = _file->name(); @@ -154,7 +136,7 @@ bool Generator::Generate(const FileDescriptor *_file, for (auto i = 0; i < _file->message_type_count(); ++i) { - auto desc = _file->message_type(i); + const auto *desc = _file->message_type(i); std::string ptrTypes; indexPrinter.PrintRaw(desc->name()); @@ -195,7 +177,4 @@ bool Generator::Generate(const FileDescriptor *_file, return true; } -} -} -} -} +} // namespace google::protobuf::compiler::cpp