From 294a5aca8f7d84c0bf982c0bf59ffee08acc7ff9 Mon Sep 17 00:00:00 2001 From: MaximeBF Date: Tue, 6 Mar 2018 11:17:04 -0500 Subject: [PATCH] Support long and unsined long as int and unsigned on Microsft platforms --- include/rapidjson/document.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index f28d8ca..a6acc24 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -451,6 +451,26 @@ struct TypeHelper { static ValueType& Set(ValueType& v, unsigned data, typename ValueType::AllocatorType&) { return v.SetUint(data); } }; +#ifdef _MSC_VER +RAPIDJSON_STATIC_ASSERT(sizeof(long) == sizeof(int)); +template +struct TypeHelper { + static bool Is(const ValueType& v) { return v.IsInt(); } + static long Get(const ValueType& v) { return v.GetInt(); } + static ValueType& Set(ValueType& v, long data) { return v.SetInt(data); } + static ValueType& Set(ValueType& v, long data, typename ValueType::AllocatorType&) { return v.SetInt(data); } +}; + +RAPIDJSON_STATIC_ASSERT(sizeof(unsigned long) == sizeof(unsigned)); +template +struct TypeHelper { + static bool Is(const ValueType& v) { return v.IsUint(); } + static unsigned long Get(const ValueType& v) { return v.GetUint(); } + static ValueType& Set(ValueType& v, unsigned long data) { return v.SetUint(data); } + static ValueType& Set(ValueType& v, unsigned long data, typename ValueType::AllocatorType&) { return v.SetUint(data); } +}; +#endif + template struct TypeHelper { static bool Is(const ValueType& v) { return v.IsInt64(); }