MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / constantDecodeAsInt64

Function constantDecodeAsInt64

pj_datastore/src/encoding.cpp:103–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103int64_t constantDecodeAsInt64(const ConstantEncoded& enc) {
104 const uint8_t* ptr = enc.value_bytes.data();
105 switch (enc.value_kind) {
106 case StorageKind::kInt32: {
107 int32_t v{};
108 std::memcpy(&v, ptr, sizeof(v));
109 return static_cast<int64_t>(v);
110 }
111 case StorageKind::kInt64: {
112 int64_t v{};
113 std::memcpy(&v, ptr, sizeof(v));
114 return v;
115 }
116 case StorageKind::kUint64: {
117 uint64_t v{};
118 std::memcpy(&v, ptr, sizeof(v));
119 return static_cast<int64_t>(v);
120 }
121 case StorageKind::kFloat32: {
122 float v{};
123 std::memcpy(&v, ptr, sizeof(v));
124 return static_cast<int64_t>(v);
125 }
126 case StorageKind::kFloat64: {
127 double v{};
128 std::memcpy(&v, ptr, sizeof(v));
129 return static_cast<int64_t>(v);
130 }
131 default:
132 return 0;
133 }
134}
135
136uint64_t constantDecodeAsUint64(const ConstantEncoded& enc) {
137 const uint8_t* ptr = enc.value_bytes.data();

Callers 1

readNumericAsInt64Method · 0.85

Calls 1

dataMethod · 0.45

Tested by

no test coverage detected