mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed compilation in new serialization test code
This commit is contained in:
parent
ddbe2ef9a1
commit
75a3cf0f3b
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/rsprint.h"
|
||||
#include "serialization/rsserializer.h"
|
||||
|
||||
RsItem *RsSerializer::deserialise(const uint8_t *data,uint32_t size)
|
||||
@ -11,6 +12,7 @@ RsItem *RsSerializer::deserialise(const uint8_t *data,uint32_t size)
|
||||
if(!item)
|
||||
{
|
||||
std::cerr << "(EE) cannot deserialise: unknown item type " << std::hex << rstype << std::dec << std::endl;
|
||||
std::cerr << "(EE) Data is: " << RsUtil::BinToHex(data,std::min(50u,size)) << ((size>50)?"...":"") << std::endl;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,10 @@
|
||||
class RsTypeSerializer
|
||||
{
|
||||
public:
|
||||
// This type should be used to pass a parameter to drive the serialisation if needed.
|
||||
|
||||
typedef std::pair<std::string&,uint16_t> TlvString;
|
||||
|
||||
template<typename T>
|
||||
static void serial_process(RsItem::SerializeJob j,SerializeContext& ctx,T& member)
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ class RsTestItem: public RsItem
|
||||
//
|
||||
virtual void serial_process(RsItem::SerializeJob j, SerializeContext& ctx)
|
||||
{
|
||||
TlvString tt(str,TLV_TYPE_STR_DESCR) ;
|
||||
RsTypeSerializer::TlvString tt(str,TLV_TYPE_STR_DESCR) ;
|
||||
|
||||
RsTypeSerializer::serial_process(j,ctx,ts ) ;
|
||||
RsTypeSerializer::serial_process(j,ctx,tt ) ;
|
||||
@ -121,8 +121,11 @@ class RsTestSerializer: public RsSerializer
|
||||
public:
|
||||
RsTestSerializer() : RsSerializer(RS_SERVICE_TYPE_TEST) {}
|
||||
|
||||
virtual RsItem *create_item(uint8_t subtype)
|
||||
virtual RsItem *create_item(uint16_t service_id,uint8_t subtype)
|
||||
{
|
||||
if(service_id != RS_SERVICE_TYPE_TEST)
|
||||
return NULL ;
|
||||
|
||||
switch(subtype)
|
||||
{
|
||||
case RS_ITEM_SUBTYPE_TEST1: return new RsTestItem();
|
||||
|
Loading…
Reference in New Issue
Block a user