I don't have any experience with MPI, but I would recommend using SerializeToString() instead of SerializeToArray(). SerializeToString() is simpler and easier because you don't have to worry about creating an array of the correct size. Once you have serialized to a std::string, you can just call data() and size() on that to get access to the backing array and size. Note that the serialized data might contain null characters within it.
On Tue, Sep 18, 2018 at 1:10 PM Oliver Wang <[email protected]> wrote: > > mainly, I need to pass serialized array to MPI to transfer - MPI needs > type information and size information, MPI_CHAR will treat the buffer as > char*, MPI_BYTE will treat the buffer as byte stream. I am a bit fuzzy on > which type I should use? Also, if it is a c-string, maybe I don't have to > pass "size" information along with it. Given your earlier reply, this is > not the case. > > Thanks > Oliver > > > > > On Monday, September 17, 2018 at 4:13:44 PM UTC-4, Adam Cozzette wrote: >> >> That method will serialize the message into the provided array in the >> data argument. It will not really generate a C-style string, because the >> output will not be delimited by a null character. What are you trying to do >> exactly? >> >> On Mon, Sep 17, 2018 at 12:18 PM Oliver Wang <[email protected]> wrote: >> >>> hi, >>> >>> It wasn't clear to me, if this following call will generate a c-string? >>> if not, is there a way to do that? >>> >>> >>> https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.message_lite?csw=1#MessageLite.SerializeToArray.details >>> >>> thanks >>> >>> oliver >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Protocol Buffers" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/protobuf. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
