aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/cpp/cpp_string_field.cc
diff options
context:
space:
mode:
authorGravatar Bo Yang <teboring@google.com>2017-06-22 15:39:19 -0700
committerGravatar Bo Yang <teboring@google.com>2017-06-23 11:58:05 -0700
commit9c0b35cf620c4904a18e25733f50c9c0474fefa6 (patch)
treed0010edbebaf6af9c4b6d1b0c5a8daa7b5102c03 /src/google/protobuf/compiler/cpp/cpp_string_field.cc
parentf752d816b780fff2a6af80f330a808874e63621f (diff)
Enusre public header and generated code have no implicit converion.
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_string_field.cc')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_string_field.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_string_field.cc b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
index 7a849e2e..6a710888 100644
--- a/src/google/protobuf/compiler/cpp/cpp_string_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_string_field.cc
@@ -477,7 +477,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(
descriptor_, options_, true, variables_,
- "this->$name$().data(), this->$name$().length(),\n", printer);
+ "this->$name$().data(), static_cast<int>(this->$name$().length()),\n",
+ printer);
}
}
@@ -486,7 +487,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(
descriptor_, options_, false, variables_,
- "this->$name$().data(), this->$name$().length(),\n", printer);
+ "this->$name$().data(), static_cast<int>(this->$name$().length()),\n",
+ printer);
}
printer->Print(variables_,
"::google::protobuf::internal::WireFormatLite::Write$declared_type$MaybeAliased(\n"
@@ -498,7 +500,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(
descriptor_, options_, false, variables_,
- "this->$name$().data(), this->$name$().length(),\n", printer);
+ "this->$name$().data(), static_cast<int>(this->$name$().length()),\n",
+ printer);
}
printer->Print(variables_,
"target =\n"
@@ -797,7 +800,8 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(
descriptor_, options_, true, variables_,
- "this->$name$().data(), this->$name$().length(),\n", printer);
+ "this->$name$().data(), static_cast<int>(this->$name$().length()),\n",
+ printer);
}
}
@@ -969,7 +973,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
GenerateUtf8CheckCodeForString(
descriptor_, options_, true, variables_,
"this->$name$(this->$name$_size() - 1).data(),\n"
- "this->$name$(this->$name$_size() - 1).length(),\n",
+ "static_cast<int>(this->$name$(this->$name$_size() - 1).length()),\n",
printer);
}
}
@@ -982,7 +986,8 @@ GenerateSerializeWithCachedSizes(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(
descriptor_, options_, false, variables_,
- "this->$name$(i).data(), this->$name$(i).length(),\n", printer);
+ "this->$name$(i).data(), static_cast<int>(this->$name$(i).length()),\n",
+ printer);
}
printer->Outdent();
printer->Print(variables_,
@@ -999,7 +1004,8 @@ GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {
GenerateUtf8CheckCodeForString(
descriptor_, options_, false, variables_,
- "this->$name$(i).data(), this->$name$(i).length(),\n", printer);
+ "this->$name$(i).data(), static_cast<int>(this->$name$(i).length()),\n",
+ printer);
}
printer->Outdent();
printer->Print(variables_,