pool raw access modified so vectors are properly serialized now
Endian swapper can swap the entries of a uint16,uint32 buffers now. Some documentation for functions added. setter function for serial buffer adapter written but does not appear to compile, commented out
This commit is contained in:
@ -44,6 +44,27 @@ public:
|
||||
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
|
||||
memcpy(out, in, size);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void swap(T * out, const T * in, uint32_t size) {
|
||||
#ifndef BYTE_ORDER_SYSTEM
|
||||
#error BYTE_ORDER_SYSTEM not defined
|
||||
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
|
||||
const uint8_t * in_buffer = reinterpret_cast<const uint8_t *>(in);
|
||||
uint8_t * out_buffer = reinterpret_cast<uint8_t *>(out);
|
||||
for (uint8_t count = 0; count < size; count++) {
|
||||
for(uint8_t i = 0; i < sizeof(T);i++) {
|
||||
out_buffer[sizeof(T)* (count + 1) - i - 1] = in_buffer[count * sizeof(T) + i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
|
||||
memcpy(out, in, size*sizeof(T));
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
@ -96,6 +96,11 @@ uint8_t * SerialBufferAdapter<T>::getBuffer() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
//template<typename T>
|
||||
//void SerialBufferAdapter<T>::setBuffer(uint8_t * buffer_) {
|
||||
// buffer = buffer_;
|
||||
//}
|
||||
|
||||
//forward Template declaration for linker
|
||||
template class SerialBufferAdapter<uint8_t>;
|
||||
template class SerialBufferAdapter<uint16_t>;
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
bool bigEndian);
|
||||
|
||||
uint8_t * getBuffer();
|
||||
//void setBuffer(uint8_t * buffer_);
|
||||
private:
|
||||
bool serializeLength;
|
||||
const uint8_t *constBuffer;
|
||||
|
@ -76,6 +76,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize buffer into object
|
||||
* @param object [out] Object to be deserialized with buffer data
|
||||
* @param buffer buffer containing the data
|
||||
* @param size int32_t type to allow value to be values smaller than 0, needed for range/size checking
|
||||
* @param bigEndian Specify endianness
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
T tmp;
|
||||
|
Reference in New Issue
Block a user