SerialBufferAdapter can process uint32_t * buffers now
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
#include <framework/serialize/SerialBufferAdapter.h>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
|
||||
template<typename T>
|
||||
SerialBufferAdapter<T>::SerialBufferAdapter(const uint8_t* buffer,
|
||||
T bufferLength, bool serializeLength) :
|
||||
@ -17,6 +15,13 @@ SerialBufferAdapter<T>::SerialBufferAdapter(uint8_t* buffer, T bufferLength,
|
||||
bufferLength) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
SerialBufferAdapter<T>::SerialBufferAdapter(uint32_t* buffer,
|
||||
T bufferLength, bool serializeLength) :
|
||||
serializeLength(serializeLength), constBuffer(NULL), buffer(reinterpret_cast<uint8_t *>(buffer)),
|
||||
bufferLength(bufferLength*4) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
SerialBufferAdapter<T>::~SerialBufferAdapter() {
|
||||
}
|
||||
@ -86,6 +91,10 @@ ReturnValue_t SerialBufferAdapter<T>::deSerialize(const uint8_t** buffer,
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
uint8_t * SerialBufferAdapter<T>::getBuffer() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
//forward Template declaration for linker
|
||||
template class SerialBufferAdapter<uint8_t>;
|
||||
|
@ -11,16 +11,39 @@
|
||||
* Additionally, the buffer length can be serialized too and will be put in front of the serialized buffer.
|
||||
*
|
||||
* Can be used with SerialLinkedListAdapter by declaring a SerializeElement with
|
||||
* SerialElement<SerialBufferAdapter<T(will be uint8_t mostly)>> serialBufferElement
|
||||
* SerialElement<SerialBufferAdapter<bufferLengthType(will be uint8_t mostly)>> serialBufferElement
|
||||
*
|
||||
* \ingroup serialize
|
||||
*/
|
||||
template<typename T>
|
||||
class SerialBufferAdapter: public SerializeIF {
|
||||
public:
|
||||
SerialBufferAdapter(const uint8_t * buffer, T bufferLength, bool serializeLenght = false);
|
||||
SerialBufferAdapter(uint8_t* buffer, T bufferLength,
|
||||
bool serializeLenght = false);
|
||||
/**
|
||||
* Constructor for constant uint8_t buffer. Length field can be serialized optionally.
|
||||
* Type of length can be supplied as template type.
|
||||
* @param buffer
|
||||
* @param bufferLength
|
||||
* @param serializeLength
|
||||
*/
|
||||
SerialBufferAdapter(const uint8_t * buffer, T bufferLength, bool serializeLength = false);
|
||||
|
||||
/**
|
||||
* Constructoor for non-constant uint8_t buffer. Length field can be serialized optionally.
|
||||
* Type of length can be supplied as template type.
|
||||
* @param buffer
|
||||
* @param bufferLength
|
||||
* @param serializeLength
|
||||
*/
|
||||
SerialBufferAdapter(uint8_t* buffer, T bufferLength, bool serializeLength = false);
|
||||
|
||||
/**
|
||||
* Constructoor for non-constant uint32_t buffer. Length field can be serialized optionally.
|
||||
* Type of length can be supplied as template type.
|
||||
* @param buffer
|
||||
* @param bufferLength
|
||||
* @param serializeLength
|
||||
*/
|
||||
SerialBufferAdapter(uint32_t* buffer,T bufferLength, bool serializeLength = false);
|
||||
|
||||
virtual ~SerialBufferAdapter();
|
||||
|
||||
@ -31,6 +54,8 @@ public:
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian);
|
||||
|
||||
uint8_t * getBuffer();
|
||||
private:
|
||||
bool serializeLength;
|
||||
const uint8_t *constBuffer;
|
||||
|
Reference in New Issue
Block a user