0

I am creating a CAP'N PROTO builder object like this:

::capnp::MallocMessageBuilder message;
InjectorRequestMsg::Builder injectorRequestMsg = message.initRoot<InjectorRequestMsg>();  

/Then setting all data members of injectorRequestMsg/
After that I am trying to write the object to a file like this:

writePackedMessageToFd(fd, message); 

This works perfectly. But, I am not able to figure out how to write this object to an output stream object using the method:

void writePackedMessage(kj::BufferedOutputStream& output, MessageBuilder& builder);

Actually, I am having issues with creating a kj::BufferedOutputStream object.
Any idea or a simple example on this regard will be greatly helpful for me.
Thanks!

Biswojit
  • 1
  • 3

1 Answers1

0

I needed to do something similar. I needed to output my data to a memory space. I was able to do so by doing:

kj::VectorOutputStream stream;
::capnp::writePackedMessage(stream, message);
/* then use stream.getArray() to get access to the data */
John Tyner
  • 1,181
  • 1
  • 12
  • 15