Hi,

In my code, I have a PB message which encompass other PB messages.
For instance,

Protocol Buffer File
===============
message A {
  required int32 a = 1;
}

message B {
  required int32 b = 1;
}

message C {
  required A a = 1;
  required B b = 2;
}

C++ File
========
#include "PB File.pb.h"

using namespace <whatever>

int main ()
{
  C c;
   ...
  char buff[MAX_SIZE]
  int len = c.SerializeToArray(buff, MAX_SIZE);
  write(fd, buff, len);
  ...
}

As part of the logic, I need to write into separate files the
serialized equivalent of c.a and c.b.  Of course you can always call
c.a().SerializeToArray() but that requires additional CPU time which I
would like to avoid.  Is there a non-hackish way of getting the offset
of c.a in the serialized buffer?  Can I use the offset and
c.a().ByteSize() to write the message into the file descriptor?

Thanks,
Nader

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to