|
|
|
@ -292,7 +292,8 @@ string DefaultValue(const FieldDescriptor* field) { |
|
|
|
|
ClassName(field->enum_type(), true), |
|
|
|
|
field->default_value_enum()->number()); |
|
|
|
|
case FieldDescriptor::CPPTYPE_STRING: |
|
|
|
|
return "\"" + CEscape(field->default_value_string()) + "\""; |
|
|
|
|
return "\"" + EscapeTrigraphs(CEscape(field->default_value_string())) + |
|
|
|
|
"\""; |
|
|
|
|
case FieldDescriptor::CPPTYPE_MESSAGE: |
|
|
|
|
return FieldMessageTypeName(field) + "::default_instance()"; |
|
|
|
|
} |
|
|
|
@ -335,6 +336,11 @@ string GlobalShutdownFileName(const string& filename) { |
|
|
|
|
return "protobuf_ShutdownFile_" + FilenameIdentifier(filename); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Escape C++ trigraphs by escaping question marks to \?
|
|
|
|
|
string EscapeTrigraphs(const string& to_escape) { |
|
|
|
|
return StringReplace(to_escape, "?", "\\?", true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace cpp
|
|
|
|
|
} // namespace compiler
|
|
|
|
|
} // namespace protobuf
|
|
|
|
|