Hi there,
I run into a problem with serializing a list of buffers corresponding to field "repeated bytes" in my proto file. I was getting this hard exception:
[libprotobuf FATAL google/protobuf/generated_message_reflection.cc:83] Protocol Buffer reflection usage error:
Method : google::protobuf::Reflection::SetString
Message type: sherlock.frontier.PostRequest
Field : sherlock.frontier.PostRequest.metric_id
Problem : Field is repeated; the method requires a singular field.
I was able to fix it with the following 3 extra lines of code at the bottom of SerializeField:
case FieldDescriptor::CPPTYPE_STRING:
if( Buffer::HasInstance(val)){
Local<Object> buf = val->ToObject();
String::Utf8Value temp(val->ToString());
std::string value = std::string(*temp);
if (repeated)
r->AddString(message, field, value);
else
r->SetString(message, field, value);
Please incorporate this simple fix into your code.
Btw, cudos for nice and elegant library. With the exception of this little problem everything worked really well and I have just about every proto type in my schema.
Hi there, I run into a problem with serializing a list of buffers corresponding to field "repeated bytes" in my proto file. I was getting this hard exception:
[libprotobuf FATAL google/protobuf/generated_message_reflection.cc:83] Protocol Buffer reflection usage error: Method : google::protobuf::Reflection::SetString Message type: sherlock.frontier.PostRequest Field : sherlock.frontier.PostRequest.metric_id Problem : Field is repeated; the method requires a singular field.
I was able to fix it with the following 3 extra lines of code at the bottom of SerializeField:
// -- fix start---- if (field->is_repeated()) r->AddString( message, field, std::string(Buffer::Data(buf), Buffer::Length(buf))); else // -- fix end---- r->SetString( message, field, std::string(Buffer::Data(buf), Buffer::Length(buf))); break; }
Please incorporate this simple fix into your code. Btw, cudos for nice and elegant library. With the exception of this little problem everything worked really well and I have just about every proto type in my schema.