diff --git a/serialize/SerialBufferAdapter.cpp b/serialize/SerialBufferAdapter.cpp index 5528331d..dc721f0d 100644 --- a/serialize/SerialBufferAdapter.cpp +++ b/serialize/SerialBufferAdapter.cpp @@ -20,9 +20,9 @@ template SerialBufferAdapter::~SerialBufferAdapter() { } -template -ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* size, - size_t maxSize, Endianness streamEndianness) const { +template +ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, + size_t* size, size_t maxSize, Endianness streamEndianness) const { uint32_t serializedLength = bufferLength; if (serializeLength) { serializedLength += SerializeAdapter::getSerializedSize( @@ -53,8 +53,8 @@ ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* size, } } -template -size_t SerialBufferAdapter::getSerializedSize() const { +template +size_t SerialBufferAdapter::getSerializedSize() const { if (serializeLength) { return bufferLength + SerializeAdapter::getSerializedSize(&bufferLength); } else { @@ -62,20 +62,16 @@ size_t SerialBufferAdapter::getSerializedSize() const { } } -template -ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, +template +ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { //TODO Ignores Endian flag! - if (buffer != NULL) { + if (buffer != nullptr) { if(serializeLength){ - T serializedSize = SerializeAdapter::getSerializedSize( - &bufferLength); - if(bufferLength + serializedSize <= *size) { - *buffer += serializedSize; - *size -= serializedSize; - } - else { - return STREAM_TOO_SHORT; + ReturnValue_t result = SerializeAdapter::deSerialize(&bufferLength, + buffer, size, streamEndianness); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; } } //No Else If, go on with buffer