mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-19 22:40:36 -04:00
Added the first top-level serialiser test for rsfileitem.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@265 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8f63b77a57
commit
0a32122ada
6 changed files with 181 additions and 7 deletions
|
@ -29,6 +29,11 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
#define RSSERIAL_DEBUG 1
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
RsItem::RsItem(uint32_t t)
|
||||
:type(t)
|
||||
|
@ -152,7 +157,7 @@ RsSerialiser::~RsSerialiser()
|
|||
|
||||
bool RsSerialiser::addSerialType(RsSerialType *serialiser)
|
||||
{
|
||||
uint32_t type = serialiser->PacketId();
|
||||
uint32_t type = (serialiser->PacketId() & 0xFFFFFF00);
|
||||
std::map<uint32_t, RsSerialType *>::iterator it;
|
||||
if (serialisers.end() != (it = serialisers.find(type)))
|
||||
{
|
||||
|
@ -172,7 +177,7 @@ bool RsSerialiser::addSerialType(RsSerialType *serialiser)
|
|||
uint32_t RsSerialiser::size(RsItem *item)
|
||||
{
|
||||
/* find the type */
|
||||
uint32_t type = item->PacketId();
|
||||
uint32_t type = (item->PacketId() & 0xFFFFFF00);
|
||||
std::map<uint32_t, RsSerialType *>::iterator it;
|
||||
|
||||
if (serialisers.end() == (it = serialisers.find(type)))
|
||||
|
@ -184,6 +189,12 @@ uint32_t RsSerialiser::size(RsItem *item)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsSerialiser::serialise() Found type: " << type;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
return (it->second)->size(item);
|
||||
}
|
||||
|
||||
|
@ -202,6 +213,11 @@ bool RsSerialiser::serialise (RsItem *item, void *data, uint32_t *size)
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsSerialiser::serialise() Found type: " << type;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return (it->second)->serialise(item, data, size);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue