how to do serialization and deserialization of the structures sent from the c++ socket to qt udp socket
Actually iam trying out this logic for serialization and deserailization like this
struct stCardInfo
{
unsigned short nsCardType;
unsigned short nsNoOfSignals;
unsigned short nsStatus;
};
struct stErrorInfo
{
unsigned short nsErrorType;
char ErrorInfo[8];
};
struct stInitHealthCheck
{
unsigned short nsNoOfCards;
stCardInfo* lsCardInfo;
};
stInitHealthCheck stHealthCheck;
unsigned short *q = (unsigned short *)data;
stHealthCheck.nsNoOfCards = *q; q++;
stHealthCheck.lsCardInfo = new stCardInfo;
stHealthCheck.lsCardInfo->nsCardType = *q; q++;
stHealthCheck.lsCardInfo->nsNoOfSignals = *q; q++;
stHealthCheck.lsCardInfo->nsStatus= *q; q++;
But if the structure is more then my decoding everytime to particular datatype will become complex and time consuming so iam asking is there any efficient way of doing the serialization and deserialization so that my decoding and encoding the udp packet sent and received can be done very fast