Merge pull request #1401 from G10h4ck/forum_api

0.6.5 Safer forum API
This commit is contained in:
csoler 2018-11-20 21:45:45 +01:00 committed by GitHub
commit a802e494f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 453 additions and 102 deletions

View file

@ -0,0 +1,31 @@
/*******************************************************************************
* libretroshare: retroshare core library *
* *
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#include "serialiser/rsserializable.h"
#include <iostream>
std::ostream& operator<<(std::ostream& out, const RsSerializable& serializable)
{
RsGenericSerializer::SerializeContext ctx;
const_cast<RsSerializable&>(serializable) // safe with TO_JSON
.serial_process(RsGenericSerializer::TO_JSON, ctx);
return out << ctx.mJson;
}

View file

@ -20,8 +20,11 @@
* *
*******************************************************************************/
#pragma once
#include "serialiser/rsserializer.h"
#include <iosfwd>
/** @brief Minimal ancestor for all serializable structs in RetroShare.
* If you want your struct to be easly serializable you should inherit from this
@ -49,3 +52,5 @@ struct RsSerializable
#define RS_SERIAL_PROCESS(I) do { \
RsTypeSerializer::serial_process(j, ctx, I, #I ); \
} while(0)
std::ostream &operator<<(std::ostream& out, const RsSerializable& serializable);

View file

@ -28,13 +28,15 @@
#include "serialiser/rstlvbase.h"
#include "serialiser/rstlvitem.h"
#include "util/rsdeprecate.h"
#include <retroshare/rstypes.h>
#include <retroshare/rsgxsifacetypes.h>
#include <list>
template<class ID_CLASS,uint32_t TLV_TYPE> class t_RsTlvIdSet: public RsTlvItem
/// @deprecated use plain std::set<> instead
template<class ID_CLASS,uint32_t TLV_TYPE> class RS_DEPRECATED_FOR(std::set<>) t_RsTlvIdSet
: public RsTlvItem
{
public:
t_RsTlvIdSet() {}
@ -122,7 +124,7 @@ typedef t_RsTlvIdSet<RsGxsMessageId,TLV_TYPE_GXSMSGIDSET> RsTlvGxsMsgIdSet
typedef t_RsTlvIdSet<RsGxsCircleId, TLV_TYPE_GXSCIRCLEIDSET> RsTlvGxsCircleIdSet ;
typedef t_RsTlvIdSet<RsNodeGroupId, TLV_TYPE_NODEGROUPIDSET> RsTlvNodeGroupIdSet ;
class RsTlvServiceIdSet: public RsTlvItem
class RS_DEPRECATED RsTlvServiceIdSet: public RsTlvItem
{
public:
RsTlvServiceIdSet() { return; }

View file

@ -26,15 +26,18 @@
*
******************************************************************/
#include "util/rsdeprecate.h"
#include <iosfwd>
#include <string>
#include <inttypes.h>
//! A base class for all tlv items
/*! This class is provided to allow the serialisation and deserialization of compund
tlv items
*/
class RsTlvItem
/*! A base class for all tlv items
* This class is provided to allow the serialisation and deserialization of
* compund tlv items
* @deprecated TLV serialization system is deprecated!
*/
class RS_DEPRECATED_FOR(RsSerializable) RsTlvItem
{
public:
RsTlvItem() { return; }
@ -51,8 +54,7 @@ std::ostream &printEnd(std::ostream &out, std::string clsName, uint16_t indent)
std::ostream &printIndent(std::ostream &out, uint16_t indent);
class RsTlvUnit: public RsTlvItem
class RS_DEPRECATED_FOR(RsSerializable) RsTlvUnit: public RsTlvItem
{
public:
RsTlvUnit(uint16_t tlv_type);