- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
static_cast<void>(memcpy(reinterpret_cast<U8INT*>(&this->someField), pBuffer , sizeof(someField)));
static_cast<void>(memcpy(reinterpret_cast<U8INT*>(&this->anotherField), pBuffer + sizeof(someField), sizeof(anotherField)));
static_cast<void>(memcpy(reinterpret_cast<U8INT*>(&this->yetAnotherField), pBuffer + sizeof(someField) + sizeof(anotherField), sizeof(yetAnotherField)));
static_cast<void>(memcpy(reinterpret_cast<U8INT*>(&this->moreOfTheSame), pBuffer + sizeof(someField) + sizeof(anotherField) + sizeof(yetAnotherField), sizeof(moreOfTheSame)));
static_cast<void>(memcpy(reinterpret_cast<U8INT*>(&this->iamTiredOfThis), pBuffer + sizeof(someField) + sizeof(anotherField) + sizeof(yetAnotherField) + sizeof(moreOfTheSame), sizeof(iamTiredOfThis)));
static_cast<void>(memcpy(reinterpret_cast<U8INT*>(&this->butItDoesntEnd), pBuffer + sizeof(someField) + sizeof(anotherField) + sizeof(yetAnotherField) + sizeof(moreOfTheSame) + sizeof(iamTiredOfThis), sizeof(butItDoesntEnd)));
static_cast<void>(memcpy(reinterpret_cast<U8INT*>(&this->itGoesOnAndOn), pBuffer + sizeof(someField) + sizeof(anotherField) + sizeof(yetAnotherField) + sizeof(moreOfTheSame) + sizeof(iamTiredOfThis) + sizeof(butItDoesntEnd), sizeof(itGoesOnAndOn)));
static_cast<void>(memcpy(reinterpret_cast<U8INT*>(&this->godHaveMercyOnMe), pBuffer + sizeof(someField) + sizeof(anotherField) + sizeof(yetAnotherField) + sizeof(moreOfTheSame) + sizeof(iamTiredOfThis) + sizeof(butItDoesntEnd) + sizeof(itGoesOnAndOn), sizeof(godHaveMercyOnMe)));
static_cast<void>(memcpy(reinterpret_cast<U8INT*>(&this->crcSum), pBuffer + sizeof(someField) + sizeof(anotherField) + sizeof(yetAnotherField) + sizeof(moreOfTheSame) + sizeof(iamTiredOfThis) + sizeof(butItDoesntEnd) + sizeof(itGoesOnAndOn) + sizeof(godHaveMercyOnMe), sizeof(crcSum)));
сериализация сообщения в С++, следуя best practices Скота Маерса. (имена полей класса анонимизированы, все остально как в оригинале.)
Я для подобной цели когда-то запилил
Опечатка в слове реквайрс.