first commit
This commit is contained in:
commit
7dd9dd689e
40 changed files with 4100 additions and 0 deletions
32
ProtoGen/ProtoUtil.h
Normal file
32
ProtoGen/ProtoUtil.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
const uint8_t bytes_i32[4] = {0, 0, 0, 1};
|
||||
const uint8_t bytes_i64[8] = {0, 0, 0, 0, 0, 0, 0, 1};
|
||||
|
||||
const std::vector<uint8_t> VECTOR_ONE = {1};
|
||||
const std::vector<uint8_t> VECTOR_ZERO = {0};
|
||||
const std::vector<uint8_t> VECTOR_COLLECTION = {1, 0};
|
||||
|
||||
const std::vector<std::vector<uint8_t>> LENGTH_PREFIXED_SAMPLES = {
|
||||
{1, 0, 0, 0, 0},
|
||||
{1, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{5, 0x08, 0x01, 0x33, 0x01, 0x00},
|
||||
{5, 0x10, 0x01, 0x33, 0x10, 0x00},
|
||||
};
|
||||
|
||||
const std::vector<uint8_t> LENGTH_I32 = {bytes_i32, bytes_i32 + 4};
|
||||
const std::vector<uint8_t> LENGTH_I64 = {bytes_i64, bytes_i64 + 8};
|
||||
|
||||
// Constantes wire types
|
||||
constexpr uint8_t WIRE_TYPE_VAR_INT = 0;
|
||||
constexpr uint8_t WIRE_TYPE_I64 = 1;
|
||||
constexpr uint8_t WIRE_TYPE_LENGTH_PREFIXED = 2;
|
||||
constexpr uint8_t WIRE_TYPE_I32 = 5;
|
||||
|
||||
// Prototipos de funciones
|
||||
size_t varint_length(uint32_t v);
|
||||
size_t encode_varint(std::vector<uint8_t>& dst, uint32_t value);
|
||||
uint32_t pack_wire_tag(uint32_t field_id, uint8_t wire_type);
|
||||
Loading…
Add table
Add a link
Reference in a new issue