adaption for SerializeIF

- Returns serialized and deserialized size now
This commit is contained in:
Robin Müller 2022-07-27 21:31:09 +02:00
parent e7d9979078
commit dc31358d52
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -125,22 +125,26 @@ class SerializeIF {
* @param streamEndianness * @param streamEndianness
* @return * @return
*/ */
[[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize, [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t &serLen, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
size_t tmpSize = 0; size_t tmpSize = 0;
return serialize(&buffer, &tmpSize, maxSize, streamEndianness); ReturnValue_t result = serialize(&buffer, &tmpSize, maxSize, streamEndianness);
serLen = tmpSize;
return result;
} }
/** /**
* Forwards to regular @serialize call with big (network) endianness * Forwards to regular @serialize call with big (network) endianness
*/ */
[[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t maxSize) const { [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t &serLen,
return serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); size_t maxSize) const {
return serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK);
} }
/** /**
* If endianness is not explicitly specified, use machine endianness * If endianness is not explicitly specified, use machine endianness
*/ */
[[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const { [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t &serLen,
return serialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); size_t maxSize) const {
return serialize(buffer, serLen, maxSize, SerializeIF::Endianness::MACHINE);
} }
/** /**
@ -151,21 +155,24 @@ class SerializeIF {
* @param streamEndianness * @param streamEndianness
* @return * @return
*/ */
virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t maxSize, virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t &deserSize, size_t maxSize,
Endianness streamEndianness) { Endianness streamEndianness) {
return deSerialize(&buffer, &maxSize, streamEndianness); size_t deserLen = maxSize;
ReturnValue_t result = deSerialize(&buffer, &deserLen, streamEndianness);
deserSize = maxSize - deserLen;
return result;
} }
/** /**
* Forwards to regular @serialize call with big (network) endianness * Forwards to regular @serialize call with big (network) endianness
*/ */
virtual ReturnValue_t deSerializeBe(const uint8_t *buffer, size_t maxSize) { virtual ReturnValue_t deSerializeBe(const uint8_t *buffer, size_t &deserSize, size_t maxSize) {
return deSerialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); return deSerialize(buffer, deserSize, maxSize, SerializeIF::Endianness::NETWORK);
} }
/** /**
* If endianness is not explicitly specified, use machine endianness * If endianness is not explicitly specified, use machine endianness
*/ */
virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t maxSize) { virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t &deserSize, size_t maxSize) {
return deSerialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); return deSerialize(buffer, deserSize, maxSize, SerializeIF::Endianness::MACHINE);
} }
}; };