I have a very specific requirement. I have a java application, where I have to convert byte array in to message having java types like int, String. The structure of the message is defined in c++ as below -
struct SMSMessage{
int id;
std::string name;
std::string source;
std::string destination;
std::string timestamp;
int type;
int status;
std::string message;
int mesg_type;
int mesg_sub_type; };
What I receive in my java application is the byte array. I don't know wheather c++ application is using proto buffers or any other way to convert in to a byte array. But, if I parse the array using byte by byte, I could get the values. For example -
ByteBuffer.wrap(Arrays.copyOfRange(byteArray, 0, 4)).getInt();
//byteArray -- reference to the incoming byte array
// 0, 4-- range of bytes for integer type
This line will return correct id value (First property in structure is int).
My question are - If I write the proto for this structure, could I be able to parse this message in to java ?
Is there any other way to convert the byte array to java types ?(not using library like google protobuf )