mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 17:51:26 -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 "rsgxscommentitems.h"
|
||||||
#include "serialiser/rstlvbase.h"
|
#include "serialiser/rstlvbase.h"
|
||||||
#include "serialiser/rsbaseserial.h"
|
#include "serialiser/rsbaseserial.h"
|
||||||
|
#include "serialization/rstypeserializer.h"
|
||||||
|
|
||||||
//#define GXSCOMMENT_DEBUG 1
|
//#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)
|
uint32_t RsGxsCommentSerialiser::size(RsItem *item)
|
||||||
{
|
{
|
||||||
@ -152,7 +168,15 @@ uint32_t RsGxsCommentSerialiser::sizeGxsCommentItem(RsGxsCommentItem *item)
|
|||||||
|
|
||||||
return s;
|
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)
|
bool RsGxsCommentSerialiser::serialiseGxsCommentItem(RsGxsCommentItem *item, void *data, uint32_t *size)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -297,7 +321,14 @@ uint32_t RsGxsCommentSerialiser::sizeGxsVoteItem(RsGxsVoteItem */*item*/)
|
|||||||
|
|
||||||
return s;
|
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)
|
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:
|
public:
|
||||||
|
|
||||||
RsGxsCommentItem(uint16_t service_type): RsGxsMsgItem(service_type,
|
RsGxsCommentItem(uint16_t service_type): RsGxsMsgItem(service_type, RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM) {}
|
||||||
RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM) {return; }
|
virtual ~RsGxsCommentItem() {}
|
||||||
virtual ~RsGxsCommentItem() { return;}
|
void clear(){}
|
||||||
void clear();
|
|
||||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
virtual void serial_process(RsGenericSerializer::SerializeJob /* j */,RsGenericSerializer::SerializeContext& /* ctx */);
|
||||||
|
|
||||||
RsGxsComment mMsg;
|
RsGxsComment mMsg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class RsGxsVoteItem : public RsGxsMsgItem
|
class RsGxsVoteItem : public RsGxsMsgItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsGxsVoteItem(uint16_t service_type): RsGxsMsgItem(service_type,
|
RsGxsVoteItem(uint16_t service_type): RsGxsMsgItem(service_type, RS_PKT_SUBTYPE_GXSCOMMENT_VOTE_ITEM) {}
|
||||||
RS_PKT_SUBTYPE_GXSCOMMENT_VOTE_ITEM) {return; }
|
virtual ~RsGxsVoteItem() {}
|
||||||
virtual ~RsGxsVoteItem() { return;}
|
void clear(){}
|
||||||
void clear();
|
|
||||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
virtual void serial_process(RsGenericSerializer::SerializeJob /* j */,RsGenericSerializer::SerializeContext& /* ctx */);
|
||||||
|
|
||||||
RsGxsVote mMsg;
|
RsGxsVote mMsg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RsGxsCommentSerialiser : public RsServiceSerializer
|
||||||
class RsGxsCommentSerialiser : public RsSerialType
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsGxsCommentSerialiser(uint16_t service_type)
|
RsGxsCommentSerialiser(uint16_t service_type) :RsServiceSerializer(service_type) {}
|
||||||
:RsSerialType(RS_PKT_VERSION_SERVICE, service_type)
|
virtual ~RsGxsCommentSerialiser() {}
|
||||||
{ 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);
|
|
||||||
|
|
||||||
|
RsItem *create_item(uint16_t service_id,uint8_t item_subtype) const ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* RS_GXS_COMMENT_ITEMS_H */
|
#endif /* RS_GXS_COMMENT_ITEMS_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user