MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / readFlxBytes

Function readFlxBytes

lib/external/flx.cc:7–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include "lib/external/flx.h"
6
7std::unique_ptr<Fluxmap> readFlxBytes(const Bytes& bytes)
8{
9 ByteReader br(bytes);
10
11 /* Skip header. */
12
13 for (;;)
14 {
15 if (br.eof())
16 error("malformed FLX stream");
17 uint8_t b = br.read_8();
18 if (b == 0)
19 break;
20 }
21
22 auto fluxmap = std::make_unique<Fluxmap>();
23 while (!br.eof())
24 {
25 uint8_t b = br.read_8();
26 switch (b)
27 {
28 case FLX_INDEX:
29 fluxmap->appendIndex();
30 continue;
31
32 case FLX_STOP:
33 goto stop;
34
35 default:
36 {
37 if (b < 32)
38 error("unknown FLX opcode 0x{:2x}", b);
39 nanoseconds_t interval = b * FLX_TICK_NS;
40 fluxmap->appendInterval(interval / NS_PER_TICK);
41 fluxmap->appendPulse();
42 break;
43 }
44 }
45 }
46stop:
47
48 return fluxmap;
49}

Callers 2

readSingleFluxMethod · 0.85
test_convertFunction · 0.85

Calls 3

errorFunction · 0.85
read_8Method · 0.80
eofMethod · 0.45

Tested by 1

test_convertFunction · 0.68