fixed deSerialize

This commit is contained in:
Robin Müller 2020-08-25 13:14:13 +02:00
parent 26b63d63b9
commit 825bf62d79

View File

@ -20,9 +20,9 @@ template<typename count_t>
SerialBufferAdapter<count_t>::~SerialBufferAdapter() {
}
template<typename T>
ReturnValue_t SerialBufferAdapter<T>::serialize(uint8_t** buffer, size_t* size,
size_t maxSize, Endianness streamEndianness) const {
template<typename count_t>
ReturnValue_t SerialBufferAdapter<count_t>::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<T>::serialize(uint8_t** buffer, size_t* size,
}
}
template<typename T>
size_t SerialBufferAdapter<T>::getSerializedSize() const {
template<typename count_t>
size_t SerialBufferAdapter<count_t>::getSerializedSize() const {
if (serializeLength) {
return bufferLength + SerializeAdapter::getSerializedSize(&bufferLength);
} else {
@ -62,20 +62,16 @@ size_t SerialBufferAdapter<T>::getSerializedSize() const {
}
}
template<typename T>
ReturnValue_t SerialBufferAdapter<T>::deSerialize(const uint8_t** buffer,
template<typename count_t>
ReturnValue_t SerialBufferAdapter<count_t>::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