36 lines
874 B
C
Raw Normal View History

2017-03-25 19:01:32 +01:00
#pragma once
#include <stdint.h>
#include <string.h>
#include <iostream>
#include <string>
#include "serialiser/rsserial.h"
#define SERIALIZE_ERROR() std::cerr << __PRETTY_FUNCTION__ << " : "
2017-03-25 19:01:32 +01:00
class RsSerializer: public RsSerialType
2017-03-25 19:01:32 +01:00
{
public:
RsSerializer(uint16_t service_id) : RsSerialType(service_id) {}
2017-03-25 19:01:32 +01:00
/*! create_item
* should be overloaded to create the correct type of item depending on the data
*/
2017-04-05 16:53:20 +02:00
virtual RsItem *create_item(uint16_t /* service */, uint8_t /* item_sub_id */)
2017-03-25 19:01:32 +01:00
{
return NULL ;
}
// The following functions *should not* be overloaded.
// They are kept public in order to allow them to be called if needed.
2017-04-02 14:48:17 +02:00
RsItem *deserialise(const uint8_t *data,uint32_t size) ;
bool serialise(RsItem *item,uint8_t *const data,uint32_t size) ;
uint32_t size(RsItem *item) ;
void print(RsItem *item) ;
2017-03-25 19:01:32 +01:00
};