mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-20 04:14:27 -04:00
switched rshistoryitems to new serialization
This commit is contained in:
parent
8ae6541ceb
commit
af4fcf7679
4 changed files with 85 additions and 27 deletions
|
@ -6,7 +6,7 @@ const SerializationFlags RsGenericSerializer::SERIALIZATION_FLAG_NONE ( 0x0
|
|||
const SerializationFlags RsGenericSerializer::SERIALIZATION_FLAG_CONFIG ( 0x0001 );
|
||||
const SerializationFlags RsGenericSerializer::SERIALIZATION_FLAG_SIGNATURE ( 0x0002 );
|
||||
|
||||
RsItem *RsGenericSerializer::deserialise(void *data, uint32_t *size)
|
||||
RsItem *RsServiceSerializer::deserialise(void *data, uint32_t *size)
|
||||
{
|
||||
uint32_t rstype = getRsItemId(const_cast<void*>((const void*)data)) ;
|
||||
|
||||
|
@ -36,7 +36,36 @@ RsItem *RsGenericSerializer::deserialise(void *data, uint32_t *size)
|
|||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
RsItem *RsConfigSerializer::deserialise(void *data, uint32_t *size)
|
||||
{
|
||||
uint32_t rstype = getRsItemId(const_cast<void*>((const void*)data)) ;
|
||||
|
||||
RsItem *item = create_item(getRsItemClass(rstype),getRsItemSubType(rstype)) ;
|
||||
|
||||
if(!item)
|
||||
{
|
||||
std::cerr << "(EE) cannot deserialise: unknown item type " << std::hex << rstype << std::dec << std::endl;
|
||||
std::cerr << "(EE) Data is: " << RsUtil::BinToHex(static_cast<uint8_t*>(data),std::min(50u,*size)) << ((*size>50)?"...":"") << std::endl;
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
SerializeContext ctx(const_cast<uint8_t*>(static_cast<uint8_t*>(data)),*size,mFormat,mFlags);
|
||||
ctx.mOffset = 8 ;
|
||||
|
||||
item->serial_process(RsItem::DESERIALIZE, ctx) ;
|
||||
|
||||
if(ctx.mSize != ctx.mOffset)
|
||||
{
|
||||
std::cerr << "RsSerializer::deserialise(): ERROR. offset does not match expected size!" << std::endl;
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
if(ctx.mOk)
|
||||
return item ;
|
||||
|
||||
delete item ;
|
||||
return NULL ;
|
||||
}
|
||||
bool RsGenericSerializer::serialise(RsItem *item,void *data,uint32_t *size)
|
||||
{
|
||||
SerializeContext ctx(static_cast<uint8_t*>(data),0,mFormat,mFlags);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue