Commit 39eec2ee authored by Matthias Wittgen's avatar Matthias Wittgen
Browse files

support dummy 64 bit types

parent 22d10df2
......@@ -161,8 +161,8 @@ public:
variant(Type t) {
switch(t) {
case Type::null: value=nullptr; break;
case Type::uint64: value=uint64_t(0); break;
case Type::int64: value=int64_t(0); break;
case Type::uint64: value=U64(0); break;
case Type::int64: value=I64(0); break;
case Type::uint32: value=uint32_t(0); break;
case Type::int32: value=int32_t(0);break;
case Type::uint16: value=uint16_t(0);break;
......@@ -170,13 +170,13 @@ public:
case Type::uint8: value=uint8_t(0); break;
case Type::int8: value=int8_t(0);break;
case Type::float32: value=float(0.);break;
case Type::float64: value=double(0.); break;
case Type::float64: value=DBL(0.); break;
case Type::boolean: value=bool(false);break;
case Type::array: value=ArrayPtr();break;
case Type::object: value= ObjPtr();break;
case Type::string: value= StrPtr();break;
case Type::array_uint64: value=ValPtr<uint64_t>(); break;
case Type::array_int64: value=ValPtr<int64_t>(); break;
case Type::array_uint64: value=ValPtr<U64>(); break;
case Type::array_int64: value=ValPtr<I64>(); break;
case Type::array_uint32: value=ValPtr<uint32_t>(); break;
case Type::array_int32: value=ValPtr<int32_t>(); break;
case Type::array_uint16: value=ValPtr<uint16_t>(); break;
......@@ -184,7 +184,7 @@ public:
case Type::array_uint8: value=ValPtr<uint8_t>(); break;
case Type::array_int8: value=ValPtr<int8_t>();break;
case Type::array_float: value=ValPtr<float>();break;
case Type::array_double: value=ValPtr<double>();break;
case Type::array_double: value=ValPtr<DBL>();break;
case Type::array_bool: value=ValPtr<bool>(); break;
}
}
......@@ -233,22 +233,22 @@ public:
}
}
uint64_t getUint() const {
if(index()==Type::uint64) return get_v<uint64_t>(value);
U64 getUint() const {
if(index()==Type::uint64) return get_v<U64>(value);
if(index()==Type::uint32) return get_v<uint32_t>(value);
if(index()==Type::uint16) return get_v<uint16_t>(value);
if(index()==Type::uint8) return get_v<uint8_t>(value);
throw;
}
int64_t getInt() const {
if(index()==Type::int64) return get_v<int64_t>(value);
I64 getInt() const {
if(index()==Type::int64) return get_v<I64>(value);
if(index()==Type::int32) return get_v<int32_t>(value);
if(index()==Type::int16) return get_v<int16_t>(value);
if(index()==Type::int8) return get_v<int8_t>(value);
throw;
}
double getFloat() const {
if(index()==Type::float64) return get_v<double>(value);
DBL getFloat() const {
if(index()==Type::float64) return get_v<DBL>(value);
if(index()==Type::float32) return get_v<float>(value);
throw;
}
......@@ -851,10 +851,11 @@ struct MsgPackHandler {
//using namespace rapidjson;
#endif
struct dummy_uint64_t { uint32_t val; };
struct dummy_int64_t { int32_t val; };
struct dummy_double { float val; };
typedef struct du_ { du_(uint32_t v):_v(v) {}; uint32_t _v;} dummy_uint64_t;
typedef struct di_ { di_(int32_t v):_v(v) {}; int32_t _v;} dummy_int64_t;
typedef struct dbl_ { dbl_(float v):_v(v) {}; float _v;} dummy_double;
using variant=variant_impl::variant<>;
using variant64=variant;
using variant32=variant_impl::variant<dummy_uint64_t,dummy_int64_t,dummy_double>;
using variant32= variant_impl::variant<dummy_uint64_t,dummy_int64_t,dummy_double>;
#endif
#include <variant.hpp>
const char json[] = " { \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3, 4] } ";
int main(int argc,char *argv[]){
variant v,w;
variant32 v,w;
v["test"]= {
{"a",20} , {"b",40}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment