mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 09:41:29 -05:00
switch GxsComment item to new serialization
This commit is contained in:
parent
9c610a736d
commit
fb34fa19c0
@ -28,9 +28,25 @@
|
||||
#include "rsgxscommentitems.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialization/rstypeserializer.h"
|
||||
|
||||
//#define GXSCOMMENT_DEBUG 1
|
||||
|
||||
RsItem *RsGxsCommentSerialiser::create_item(uint16_t service_id,uint8_t item_subtype) const
|
||||
{
|
||||
if(service_id != getRsItemService(PacketId()))
|
||||
return NULL ;
|
||||
|
||||
switch(item_subtype)
|
||||
{
|
||||
case RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM: return new RsGxsCommentItem(getRsItemService(PacketId())) ;
|
||||
case RS_PKT_SUBTYPE_GXSCOMMENT_VOTE_ITEM: return new RsGxsVoteItem(getRsItemService(PacketId()));
|
||||
default:
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
|
||||
uint32_t RsGxsCommentSerialiser::size(RsItem *item)
|
||||
{
|
||||
@ -152,7 +168,15 @@ uint32_t RsGxsCommentSerialiser::sizeGxsCommentItem(RsGxsCommentItem *item)
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void RsGxsCommentItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx,1,mMsg.mComment,"mMsg.mComment") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool RsGxsCommentSerialiser::serialiseGxsCommentItem(RsGxsCommentItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
@ -297,7 +321,14 @@ uint32_t RsGxsCommentSerialiser::sizeGxsVoteItem(RsGxsVoteItem */*item*/)
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RsGxsVoteItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,mMsg.mVoteType,"mMsg.mVoteType") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool RsGxsCommentSerialiser::serialiseGxsVoteItem(RsGxsVoteItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
@ -414,3 +445,4 @@ RsGxsVoteItem* RsGxsCommentSerialiser::deserialiseGxsVoteItem(void *data, uint32
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
||||
#endif
|
||||
|
@ -43,54 +43,36 @@ class RsGxsCommentItem : public RsGxsMsgItem
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsCommentItem(uint16_t service_type): RsGxsMsgItem(service_type,
|
||||
RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM) {return; }
|
||||
virtual ~RsGxsCommentItem() { return;}
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
RsGxsCommentItem(uint16_t service_type): RsGxsMsgItem(service_type, RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM) {}
|
||||
virtual ~RsGxsCommentItem() {}
|
||||
void clear(){}
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob /* j */,RsGenericSerializer::SerializeContext& /* ctx */);
|
||||
|
||||
RsGxsComment mMsg;
|
||||
};
|
||||
|
||||
|
||||
class RsGxsVoteItem : public RsGxsMsgItem
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsVoteItem(uint16_t service_type): RsGxsMsgItem(service_type,
|
||||
RS_PKT_SUBTYPE_GXSCOMMENT_VOTE_ITEM) {return; }
|
||||
virtual ~RsGxsVoteItem() { return;}
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
RsGxsVoteItem(uint16_t service_type): RsGxsMsgItem(service_type, RS_PKT_SUBTYPE_GXSCOMMENT_VOTE_ITEM) {}
|
||||
virtual ~RsGxsVoteItem() {}
|
||||
void clear(){}
|
||||
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob /* j */,RsGenericSerializer::SerializeContext& /* ctx */);
|
||||
|
||||
RsGxsVote mMsg;
|
||||
};
|
||||
|
||||
|
||||
class RsGxsCommentSerialiser : public RsSerialType
|
||||
class RsGxsCommentSerialiser : public RsServiceSerializer
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsCommentSerialiser(uint16_t service_type)
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, service_type)
|
||||
{ return; }
|
||||
virtual ~RsGxsCommentSerialiser() { return; }
|
||||
|
||||
uint32_t size(RsItem *item);
|
||||
bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
private:
|
||||
|
||||
uint32_t sizeGxsCommentItem(RsGxsCommentItem *item);
|
||||
bool serialiseGxsCommentItem (RsGxsCommentItem *item, void *data, uint32_t *size);
|
||||
RsGxsCommentItem * deserialiseGxsCommentItem(void *data, uint32_t *size);
|
||||
|
||||
|
||||
uint32_t sizeGxsVoteItem(RsGxsVoteItem *item);
|
||||
bool serialiseGxsVoteItem (RsGxsVoteItem *item, void *data, uint32_t *size);
|
||||
RsGxsVoteItem * deserialiseGxsVoteItem(void *data, uint32_t *size);
|
||||
RsGxsCommentSerialiser(uint16_t service_type) :RsServiceSerializer(service_type) {}
|
||||
virtual ~RsGxsCommentSerialiser() {}
|
||||
|
||||
RsItem *create_item(uint16_t service_id,uint8_t item_subtype) const ;
|
||||
};
|
||||
|
||||
#endif /* RS_GXS_COMMENT_ITEMS_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user