MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / Encode

Method Encode

FEXCore/Source/Utils/variable_length_integer.h:66–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64 }
65
66 static size_t Encode(uint8_t* dst, int64_t Data) {
67 auto vl8_type = reinterpret_cast<vl8_enc*>(dst);
68 auto vl16_type = reinterpret_cast<vl16_enc*>(dst);
69 auto vl32_type = reinterpret_cast<vl32_enc*>(dst);
70 auto vl64_type = reinterpret_cast<vl64_enc*>(dst);
71
72 if (Data >= vl8_min && Data <= vl8_max) {
73 *vl8_type = {
74 .Integer = static_cast<int8_t>(Data),
75 .Type = vl8_type_header,
76 };
77 return sizeof(vl8_enc);
78 } else if (Data >= vl16_min && Data <= vl16_max) {
79 *vl16_type = {
80 .HighBits {
81 .Top = static_cast<int8_t>((Data >> 8) & 0xFF),
82 .Type = vl16_type_header,
83 },
84 .LowBits = static_cast<uint8_t>(Data & 0xFF),
85 };
86 return sizeof(vl16_enc);
87 } else if (Data >= vl32_min && Data <= vl32_max) {
88 *vl32_type = {
89 .Type = vl32_type_header,
90 .Integer = static_cast<int32_t>(Data),
91 };
92 return sizeof(vl32_enc);
93 }
94
95 *vl64_type = {
96 .Type = vl64_type_header,
97 .Integer = Data,
98 };
99 return sizeof(vl64_enc);
100 }
101
102private:
103

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected