Browse Source

added simple values and floating points

cbor
Ludovic 'Archivist' Lagouardette 3 years ago
parent
commit
c82983cf55
1 changed files with 71 additions and 1 deletions
  1. +71
    -1
      include/gp/enveloppe/cbor.hpp

+ 71
- 1
include/gp/enveloppe/cbor.hpp View File

@ -243,7 +243,77 @@ namespace gp {
}
case cbor_type::oths: {
switch((cbor_oths)local) {
case cbor_oths::value_false: {
return {
cbor_value{
cbor_composite<cbor_value>(false),
alloc
},
src.begin()+1
};
}
case cbor_oths::value_true: {
return {
cbor_value{
cbor_composite<cbor_value>(true),
alloc
},
src.begin()+1
};
}
case cbor_oths::value_null: {
return {
cbor_value{
cbor_composite<cbor_value>(nullopt),
alloc
},
src.begin()+1
};
}
case cbor_oths::value_undefined: {
return {
cbor_value{
cbor_composite<cbor_value>(undefined_t{}),
alloc
},
src.begin()+1
};
}
case cbor_oths::word: {
if(src.size()<3) ERROR;
return {
cbor_value{
cbor_floating_point{(ieee754_hf)(*(gp::endian_wrapper<ieee754_hf, endian::big>*)(src.begin().data))},
alloc
},
src.begin()+3
};
}
case cbor_oths::dword: {
if(src.size()<5) ERROR;
return {
cbor_value{
cbor_floating_point{float(*(gp::endian_wrapper<float, endian::big>*)(src.begin().data))},
alloc
},
src.begin()+5
};
}
case cbor_oths::qword: {
if(src.size()<9) ERROR;
return {
cbor_value{
cbor_floating_point{double(*(gp::endian_wrapper<double, endian::big>*)(src.begin().data))},
alloc
},
src.begin()+9
};
}
default: {
ERROR;
}
}
}
}
ERROR;

Loading…
Cancel
Save