unleashed-firmware/lib/lfrfid/tools/varint_pair.h
hedger ffa3996a5e
[FL-3867] Code formatting update (#3765)
* clang-format: AllowShortEnumsOnASingleLine: false
* clang-format: InsertNewlineAtEOF: true
* clang-format: Standard:        c++20
* clang-format: AlignConsecutiveBitFields
* clang-format: AlignConsecutiveMacros
* clang-format: RemoveParentheses: ReturnStatement
* clang-format: RemoveSemicolon: true
* Restored RemoveParentheses: Leave, retained general changes for it
* formatting: fixed logging TAGs
* Formatting update for dev

Co-authored-by: あく <alleteam@gmail.com>
2024-07-15 13:38:49 +09:00

80 lines
1.4 KiB
C

#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct VarintPair VarintPair;
/**
* @brief Allocate a new VarintPair instance
*
* VarintPair is a buffer that holds pair of varint values
* @return VarintPair*
*/
VarintPair* varint_pair_alloc(void);
/**
* @brief Free a VarintPair instance
*
* @param pair
*/
void varint_pair_free(VarintPair* pair);
/**
* @brief Write varint pair to buffer
*
* @param pair
* @param first
* @param value
* @return bool pair complete and needs to be written
*/
bool varint_pair_pack(VarintPair* pair, bool first, uint32_t value);
/**
* @brief Get pointer to varint pair buffer
*
* @param pair
* @return uint8_t*
*/
uint8_t* varint_pair_get_data(VarintPair* pair);
/**
* @brief Get size of varint pair buffer
*
* @param pair
* @return size_t
*/
size_t varint_pair_get_size(VarintPair* pair);
/**
* @brief Reset varint pair buffer
*
* @param pair
*/
void varint_pair_reset(VarintPair* pair);
/**
* @brief Unpack varint pair to uint32_t pair from buffer
*
* @param data
* @param data_length
* @param value_1
* @param value_2
* @param length
* @return bool
*/
bool varint_pair_unpack(
uint8_t* data,
size_t data_length,
uint32_t* value_1,
uint32_t* value_2,
size_t* length);
#ifdef __cplusplus
}
#endif