Skip to content

Commit

Permalink
Qualify uses of std::string within protobuf/compiler/ruby/...
Browse files Browse the repository at this point in the history
  • Loading branch information
mbxx authored and acozzette committed Jul 20, 2020
1 parent 4b7c9c2 commit 2254947
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/google/protobuf/compiler/ruby/ruby_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 << "\"";
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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++) {
Expand All @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions src/google/protobuf/compiler/ruby/ruby_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -65,4 +65,3 @@ class PROTOC_EXPORT Generator : public CodeGenerator {
#include <google/protobuf/port_undef.inc>

#endif // GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__

0 comments on commit 2254947

Please sign in to comment.