[protobuf] How to find the number of messages in a protobuf file?

2018-09-18 Thread David Yu
Hi, I am currently writing the java code to check the number of messages in a protocol buffer file *.pb I would like to know if there is meta-data or header that contains the information of number of messages in the protobuf file? I am looping through the whole file, and I think there should

Re: [protobuf] is SerializeToArray()'s buffer c-string?

2018-09-18 Thread 'Adam Cozzette' via Protocol Buffers
That is true that std::string will make sure to put a null character right after the end of your string, so if you have a string s then s.data()[s.size()] will be '\0'. However, there is nothing preventing null characters from also appearing inside the string itself. So if you're working with

Re: [protobuf] is SerializeToArray()'s buffer c-string?

2018-09-18 Thread Oliver Wang
actually, this is also the part that confuses me some: suppose I serialize it to string. string.data() will return me a c-string according to c++ reference (I read it somewhere that since c++11, string.c_str() and string.data() both will return null-terminated string). Even protocolbuf

Re: [protobuf] is SerializeToArray()'s buffer c-string?

2018-09-18 Thread 'Adam Cozzette' via Protocol Buffers
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

Re: [protobuf] Protobuf 3 - using c++11 version

2018-09-18 Thread 'Adam Cozzette' via Protocol Buffers
Starting from version 3.6 we require C++11. You shouldn't have to manually edit any makefiles, though--could you provide some more details on the problem and what version you're using? On Tue, Sep 18, 2018 at 12:18 PM wrote: > I am wondering if it is needed the c++11 version to compile protobuf

Re: [protobuf] is SerializeToArray()'s buffer c-string?

2018-09-18 Thread Oliver Wang
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

[protobuf] Protobuf 3 - using c++11 version

2018-09-18 Thread alex1 . alvarez . trejo
I am wondering if it is needed the c++11 version to compile protobuf 3 because when I run the make file it is asking me to change the line in it and write -std=c++11 -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this