MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / get

Method get

proto/fbe_models.cpp:51–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void FieldModel<decimal_t>::get(decimal_t& value, decimal_t defaults) const noexcept
52{
53 if ((_buffer.offset() + fbe_offset() + fbe_size()) > _buffer.size())
54 {
55 value = defaults;
56 return;
57 }
58
59 // Value taken via reverse engineering the double that corresponds to 2^64
60 const double ds2to64 = 1.8446744073709552e+019;
61
62 // Read decimal parts
63 uint64_t low = *((const uint64_t*)(_buffer.data() + _buffer.offset() + fbe_offset()));
64 uint32_t high = *((const uint32_t*)(_buffer.data() + _buffer.offset() + fbe_offset() + 8));
65 uint32_t flags = *((const uint32_t*)(_buffer.data() + _buffer.offset() + fbe_offset() + 12));
66
67 // Calculate decimal value
68 double dValue = ((double)low + (double)high * ds2to64) / pow(10.0, (uint8_t)(flags >> 16));
69 if (flags & 0x80000000)
70 dValue = -dValue;
71
72 value = dValue;
73}
74
75void FieldModel<decimal_t>::set(decimal_t value) noexcept
76{

Callers 11

AddValueMethod · 0.45
AddFieldMethod · 0.45
AddRejectMethod · 0.45
AddEnumMethod · 0.45
AddFlagsMethod · 0.45
AddStructMethod · 0.45
AddImportMethod · 0.45
initializeMethod · 0.45
test_create.cppFile · 0.45
VerifyDecimalFunction · 0.45
mainFunction · 0.45

Calls 6

minFunction · 0.85
clearMethod · 0.80
assignMethod · 0.80
offsetMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by 1

VerifyDecimalFunction · 0.36