Skip to content

Commit 294a5ac

Browse files
committed
Support long and unsined long as int and unsigned on Microsft platforms
1 parent 8bf4f7b commit 294a5ac

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

include/rapidjson/document.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,26 @@ struct TypeHelper<ValueType, unsigned> {
451451
static ValueType& Set(ValueType& v, unsigned data, typename ValueType::AllocatorType&) { return v.SetUint(data); }
452452
};
453453

454+
#ifdef _MSC_VER
455+
RAPIDJSON_STATIC_ASSERT(sizeof(long) == sizeof(int));
456+
template<typename ValueType>
457+
struct TypeHelper<ValueType, long> {
458+
static bool Is(const ValueType& v) { return v.IsInt(); }
459+
static long Get(const ValueType& v) { return v.GetInt(); }
460+
static ValueType& Set(ValueType& v, long data) { return v.SetInt(data); }
461+
static ValueType& Set(ValueType& v, long data, typename ValueType::AllocatorType&) { return v.SetInt(data); }
462+
};
463+
464+
RAPIDJSON_STATIC_ASSERT(sizeof(unsigned long) == sizeof(unsigned));
465+
template<typename ValueType>
466+
struct TypeHelper<ValueType, unsigned long> {
467+
static bool Is(const ValueType& v) { return v.IsUint(); }
468+
static unsigned long Get(const ValueType& v) { return v.GetUint(); }
469+
static ValueType& Set(ValueType& v, unsigned long data) { return v.SetUint(data); }
470+
static ValueType& Set(ValueType& v, unsigned long data, typename ValueType::AllocatorType&) { return v.SetUint(data); }
471+
};
472+
#endif
473+
454474
template<typename ValueType>
455475
struct TypeHelper<ValueType, int64_t> {
456476
static bool Is(const ValueType& v) { return v.IsInt64(); }

0 commit comments

Comments
 (0)