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

Function writeIndex

pj_datastore/src/encoding.cpp:17–34  ·  view source on GitHub ↗

Write an index in the given byte width

Source from the content-addressed store, hash-verified

15
16// Write an index in the given byte width
17void writeIndex(RawBuffer& buf, uint32_t index, uint8_t bytes) {
18 switch (bytes) {
19 case 1: {
20 auto v = static_cast<uint8_t>(index);
21 buf.append(&v, sizeof(v));
22 break;
23 }
24 case 2: {
25 auto v = static_cast<uint16_t>(index);
26 buf.append(&v, sizeof(v));
27 break;
28 }
29 default: {
30 buf.append(&index, sizeof(index));
31 break;
32 }
33 }
34}
35
36// Read an index at the given byte width
37[[nodiscard]] uint32_t readIndex(const uint8_t* data, std::size_t row, uint8_t bytes) {

Callers 1

dictionaryEncodeStringsFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected