From b95e3380c0501fcaec9e488b08624c4081d43b16 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 22 Jan 2018 11:09:00 +0100 Subject: [PATCH] Fix Android compilation --- android-prepare-toolchain.sh | 9 +++++++++ .../src/serialiser/rstypeserializer.cc | 20 +++++++++++++++++++ .../src/serialiser/rstypeserializer.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/android-prepare-toolchain.sh b/android-prepare-toolchain.sh index d89e071e2..13c130c31 100755 --- a/android-prepare-toolchain.sh +++ b/android-prepare-toolchain.sh @@ -145,8 +145,17 @@ build_libmicrohttpd() cd .. } +build_rapidjson() +{ + B_dir="rapidjson-1.1.0" + [ -f $B_dir.tar.gz ] || wget -O $B_dir.tar.gz https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz + tar -xf $B_dir.tar.gz + cp -r rapidjson-1.1.0/include/rapidjson/ "${SYSROOT}/usr/include/rapidjson" +} + build_toolchain build_bzlib build_openssl build_sqlite build_libupnp +build_rapidjson diff --git a/libretroshare/src/serialiser/rstypeserializer.cc b/libretroshare/src/serialiser/rstypeserializer.cc index c2b0ba905..68c1cde37 100644 --- a/libretroshare/src/serialiser/rstypeserializer.cc +++ b/libretroshare/src/serialiser/rstypeserializer.cc @@ -199,7 +199,27 @@ template<> bool RsTypeSerializer::to_JSON( const std::string& memberName, \ SIMPLE_TO_JSON_DEF(bool) SIMPLE_TO_JSON_DEF(int32_t) + +#ifdef __ANDROID__ +template<> bool RsTypeSerializer::to_JSON( const std::string& memberName, + const time_t& member, RsJson& jDoc ) +{ + rapidjson::Document::AllocatorType& allocator = jDoc.GetAllocator(); + + rapidjson::Value key; + key.SetString(memberName.c_str(), memberName.length(), allocator); + + int64_t tValue = member; + rapidjson::Value value(tValue); + + jDoc.AddMember(key, value, allocator); + + return true; +} +#else SIMPLE_TO_JSON_DEF(time_t) +#endif + SIMPLE_TO_JSON_DEF(uint8_t) SIMPLE_TO_JSON_DEF(uint16_t) SIMPLE_TO_JSON_DEF(uint32_t) diff --git a/libretroshare/src/serialiser/rstypeserializer.h b/libretroshare/src/serialiser/rstypeserializer.h index 1de678d50..68adacaf7 100644 --- a/libretroshare/src/serialiser/rstypeserializer.h +++ b/libretroshare/src/serialiser/rstypeserializer.h @@ -36,6 +36,8 @@ #include "serialiser/rsserializable.h" #include +#include // for typeid + /** INTERNAL ONLY helper to avoid copy paste code for std::{vector,list,set} * Can't use a template function because T is needed for const_cast */