Merge pull request #26596 from y-guyon:4.x_absl_str

Support string_view in caffe_importer
pull/26598/head
Alexander Smorkalov 5 months ago committed by GitHub
commit 0a2669daba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      modules/dnn/src/caffe/caffe_importer.cpp

@ -126,8 +126,8 @@ public:
const google::protobuf::UnknownField& field = unknownFields.field(i); const google::protobuf::UnknownField& field = unknownFields.field(i);
CV_Assert(field.type() == google::protobuf::UnknownField::TYPE_GROUP); CV_Assert(field.type() == google::protobuf::UnknownField::TYPE_GROUP);
CV_CheckGE(field.group().field_count(), 2, "UnknownField should have at least 2 items: name and value"); CV_CheckGE(field.group().field_count(), 2, "UnknownField should have at least 2 items: name and value");
std::string fieldName = field.group().field(0).length_delimited(); std::string fieldName(field.group().field(0).length_delimited());
std::string fieldValue = field.group().field(1).length_delimited(); std::string fieldValue(field.group().field(1).length_delimited());
params.set(fieldName, fieldValue); params.set(fieldName, fieldValue);
} }
} }
@ -137,7 +137,7 @@ public:
const Reflection *refl = msg.GetReflection(); const Reflection *refl = msg.GetReflection();
int type = field->cpp_type(); int type = field->cpp_type();
bool isRepeated = field->is_repeated(); bool isRepeated = field->is_repeated();
const std::string &name = field->name(); const std::string name(field->name());
#define SET_UP_FILED(getter, arrayConstr, gtype) \ #define SET_UP_FILED(getter, arrayConstr, gtype) \
if (isRepeated) { \ if (isRepeated) { \
@ -189,7 +189,7 @@ public:
params.set(name, DictValue::arrayString(buf.begin(), size)); params.set(name, DictValue::arrayString(buf.begin(), size));
} }
else { else {
params.set(name, refl->GetEnum(msg, field)->name()); params.set(name, std::string(refl->GetEnum(msg, field)->name()));
} }
break; break;
default: default:
@ -212,7 +212,7 @@ public:
{ {
const FieldDescriptor *fd = msgDesc->field(fieldId); const FieldDescriptor *fd = msgDesc->field(fieldId);
if (!isInternal && !ends_with_param(fd->name())) if (!isInternal && !ends_with_param(std::string(fd->name())))
continue; continue;
const google::protobuf::UnknownFieldSet& unknownFields = msgRefl->GetUnknownFields(msg); const google::protobuf::UnknownFieldSet& unknownFields = msgRefl->GetUnknownFields(msg);

Loading…
Cancel
Save