mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-27 15:47:30 -04:00
Implement JSON API generation for async API calls
Move JSON helpers to util/rsjson.* for better usability Implement JSON ostream manipulator to print compact and pretty JSON Use lambdas for API wrappers, integrate better and avoid namespace pollution Removed experimental JSON API for notify client wrapper, notifications can be implemented automatically with moderns async API calls Implement and automatically expose to JSON API RsGxsChannels::turtleSearchRequest( const std::string& matchString, const std::function<void (const RsGxsGroupSummary&)>& multiCallback, std::time_t maxWait )
This commit is contained in:
parent
b7f5d4286f
commit
4b6f751b09
15 changed files with 444 additions and 177 deletions
|
@ -151,15 +151,11 @@
|
|||
#include <string.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#ifdef HAS_RAPIDJSON
|
||||
#include <rapidjson/document.h>
|
||||
#else
|
||||
#include <rapid_json/document.h>
|
||||
#endif // HAS_RAPIDJSON
|
||||
|
||||
#include "retroshare/rsflags.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "util/rsdeprecate.h"
|
||||
#include "util/rsjson.h"
|
||||
|
||||
struct RsItem;
|
||||
|
||||
|
@ -198,8 +194,6 @@ class RsRawSerialiser: public RsSerialType
|
|||
virtual RsItem * deserialise(void *data, uint32_t *size);
|
||||
};
|
||||
|
||||
typedef rapidjson::Document RsJson;
|
||||
|
||||
/// Top class for all services and config serializers.
|
||||
struct RsGenericSerializer : RsSerialType
|
||||
{
|
||||
|
|
|
@ -660,16 +660,3 @@ bool RsTypeSerializer::from_JSON( const std::string& /*memberName*/,
|
|||
RsTypeSerializer::TlvMemBlock_proxy&,
|
||||
RsJson& /*jDoc*/)
|
||||
{ return true; }
|
||||
|
||||
|
||||
//============================================================================//
|
||||
// RsJson std:ostream support //
|
||||
//============================================================================//
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsJson &jDoc)
|
||||
{
|
||||
rapidjson::StringBuffer buffer; buffer.Clear();
|
||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
|
||||
jDoc.Accept(writer);
|
||||
return out << buffer.GetString();
|
||||
}
|
||||
|
|
|
@ -31,12 +31,8 @@
|
|||
|
||||
#include "serialiser/rsserializer.h"
|
||||
#include "serialiser/rsserializable.h"
|
||||
#include "util/rsjson.h"
|
||||
|
||||
#ifdef HAS_RAPIDJSON
|
||||
#include <rapidjson/document.h>
|
||||
#else
|
||||
#include <rapid_json/document.h>
|
||||
#endif // HAS_RAPIDJSON
|
||||
#include <typeinfo> // for typeid
|
||||
#include <type_traits>
|
||||
#include <errno.h>
|
||||
|
@ -116,7 +112,6 @@
|
|||
\
|
||||
} while(false)
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsJson &jDoc);
|
||||
|
||||
struct RsTypeSerializer
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue