Qualify uses of std::string within protobuf/compiler/ruby/...

pull/7741/head
Mark Barolak 4 years ago committed by Adam Cozzette
parent 8c91d71f69
commit 711db1d764
  1. 20
      src/google/protobuf/compiler/ruby/ruby_generator.cc
  2. 5
      src/google/protobuf/compiler/ruby/ruby_generator.h

@ -113,7 +113,7 @@ std::string TypeName(const FieldDescriptor* field) {
}
}
string StringifySyntax(FileDescriptor::Syntax syntax) {
std::string StringifySyntax(FileDescriptor::Syntax syntax) {
switch (syntax) {
case FileDescriptor::SYNTAX_PROTO2:
return "proto2";
@ -147,7 +147,7 @@ std::string DefaultValueForField(const FieldDescriptor* field) {
return NumberToString(field->default_value_enum()->number());
case FieldDescriptor::CPPTYPE_STRING: {
std::ostringstream os;
string default_str = field->default_value_string();
std::string default_str = field->default_value_string();
if (field->type() == FieldDescriptor::TYPE_STRING) {
os << "\"" << default_str << "\"";
@ -426,14 +426,14 @@ int GeneratePackageModules(const FileDescriptor* file, io::Printer* printer) {
}
// Use the appropriate delimiter
string delimiter = need_change_to_module ? "." : "::";
std::string delimiter = need_change_to_module ? "." : "::";
int delimiter_size = need_change_to_module ? 1 : 2;
// Extract each module name and indent
while (!package_name.empty()) {
size_t dot_index = package_name.find(delimiter);
string component;
if (dot_index == string::npos) {
std::string component;
if (dot_index == std::string::npos) {
component = package_name;
package_name = "";
} else {
@ -462,7 +462,7 @@ void EndPackageModules(int levels, io::Printer* printer) {
}
bool UsesTypeFromFile(const Descriptor* message, const FileDescriptor* file,
string* error) {
std::string* error) {
for (int i = 0; i < message->field_count(); i++) {
const FieldDescriptor* field = message->field(i);
if ((field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&
@ -499,7 +499,7 @@ bool UsesTypeFromFile(const Descriptor* message, const FileDescriptor* file,
bool MaybeEmitDependency(const FileDescriptor* import,
const FileDescriptor* from,
io::Printer* printer,
string* error) {
std::string* error) {
if (from->syntax() == FileDescriptor::SYNTAX_PROTO3 &&
import->syntax() == FileDescriptor::SYNTAX_PROTO2) {
for (int i = 0; i < from->message_type_count(); i++) {
@ -524,7 +524,7 @@ bool MaybeEmitDependency(const FileDescriptor* import,
}
bool GenerateFile(const FileDescriptor* file, io::Printer* printer,
string* error) {
std::string* error) {
printer->Print(
"# Generated by the protocol buffer compiler. DO NOT EDIT!\n"
"# source: $filename$\n"
@ -580,9 +580,9 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer,
bool Generator::Generate(
const FileDescriptor* file,
const string& parameter,
const std::string& parameter,
GeneratorContext* generator_context,
string* error) const {
std::string* error) const {
if (file->syntax() != FileDescriptor::SYNTAX_PROTO3 &&
file->syntax() != FileDescriptor::SYNTAX_PROTO2) {

@ -49,9 +49,9 @@ namespace ruby {
// Ruby output, you can do so by registering an instance of this
// CodeGenerator with the CommandLineInterface in your main() function.
class PROTOC_EXPORT Generator : public CodeGenerator {
bool Generate(const FileDescriptor* file, const string& parameter,
bool Generate(const FileDescriptor* file, const std::string& parameter,
GeneratorContext* generator_context,
string* error) const override;
std::string* error) const override;
uint64_t GetSupportedFeatures() const override {
return FEATURE_PROTO3_OPTIONAL;
}
@ -65,4 +65,3 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__

Loading…
Cancel
Save