mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-14 01:15:38 -04:00
More messagepack
This commit is contained in:
parent
61fdb57b8f
commit
e959d9a8ec
7 changed files with 277 additions and 89 deletions
|
@ -25,40 +25,70 @@
|
|||
|
||||
#include "ui.hpp"
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
#define MSGPACK_TYPE_U16 0xcd
|
||||
#define MSGPACK_TYPE_U32 0xce
|
||||
#define MSGPACK_TYPE_S32 0xd2
|
||||
#define MSGPACK_TYPE_S64 0xd3
|
||||
#define MSGPACK_TYPE_STR8 0xd9
|
||||
#define MSGPACK_TYPE_STR16 0xda
|
||||
#define MSGPACK_NIL 0xC0
|
||||
|
||||
#define MSGPACK_TYPE_MAP16 0xde
|
||||
#define MSGPACK_FALSE 0xC2
|
||||
#define MSGPACK_TRUE 0xC3
|
||||
|
||||
#define MSGPACK_FALSE 0xc2
|
||||
#define MSGPACK_TRUE 0xc3
|
||||
#define MSGPACK_TYPE_F32 0xCA
|
||||
#define MSGPACK_TYPE_F64 0xCB
|
||||
|
||||
#define MSGPACK_TYPE_U8 0xCC
|
||||
#define MSGPACK_TYPE_U16 0xCD
|
||||
#define MSGPACK_TYPE_U32 0xCE
|
||||
#define MSGPACK_TYPE_U64 0xCF
|
||||
|
||||
#define MSGPACK_TYPE_S8 0xD0
|
||||
#define MSGPACK_TYPE_S16 0xD1
|
||||
#define MSGPACK_TYPE_S32 0xD2
|
||||
#define MSGPACK_TYPE_S64 0xD3
|
||||
|
||||
#define MSGPACK_TYPE_STR8 0xD9
|
||||
#define MSGPACK_TYPE_STR16 0xDA
|
||||
#define MSGPACK_TYPE_STR32 0xDB
|
||||
|
||||
#define MSGPACK_TYPE_ARR16 0xDC
|
||||
#define MSGPACK_TYPE_ARR32 0xDD
|
||||
|
||||
#define MSGPACK_TYPE_MAP16 0xDE
|
||||
#define MSGPACK_TYPE_MAP32 0xDF
|
||||
|
||||
class MsgPack {
|
||||
public:
|
||||
|
||||
enum RecID {
|
||||
FrequencyList = 0,
|
||||
TestList = 1
|
||||
TestListA = 0,
|
||||
TestListB = 1,
|
||||
TestListC = 2,
|
||||
TestListD = 3,
|
||||
TestListE = 4
|
||||
};
|
||||
|
||||
bool msgpack_get(const void * buffer, const size_t size, const MsgPack::RecID record_id, bool * value);
|
||||
bool msgpack_get(const void * buffer, const size_t size, const RecID record_id, int32_t * value);
|
||||
// Read
|
||||
bool msgpack_get(const void * buffer, const size_t size, const RecID record_id, bool * value);
|
||||
bool msgpack_get(const void * buffer, const size_t size, const RecID record_id, uint8_t * value);
|
||||
bool msgpack_get(const void * buffer, const size_t size, const RecID record_id, int64_t * value);
|
||||
bool msgpack_get(const void * buffer, const size_t size, const RecID record_id, char * value);
|
||||
bool msgpack_get(const void * buffer, const size_t size, const RecID record_id, std::string& value);
|
||||
|
||||
// Write
|
||||
void msgpack_init(const void * buffer, size_t * ptr);
|
||||
void msgpack_add(const void * buffer, size_t * ptr, const RecID record_id, bool value);
|
||||
void msgpack_add(const void * buffer, size_t * ptr, const RecID record_id, uint8_t value);
|
||||
void msgpack_add(const void * buffer, size_t * ptr, const RecID record_id, int64_t value);
|
||||
bool msgpack_add(const void * buffer, size_t * ptr, const RecID record_id, std::string value);
|
||||
|
||||
private:
|
||||
bool get_raw_byte(const void * buffer, const bool inc, uint8_t * byte);
|
||||
bool get_raw_word(const void * buffer, const bool inc, uint16_t * word);
|
||||
bool get_bool(const void * buffer, const bool inc, bool * value);
|
||||
bool get_u8(const void * buffer, const bool inc, uint8_t * value);
|
||||
bool get_u16(const void * buffer, const bool inc, uint16_t * value);
|
||||
bool get_s32(const void * buffer, const bool inc, int32_t * value);
|
||||
bool get_s64(const void * buffer, const bool inc, int64_t * value);
|
||||
bool get_chars(const void * buffer, const bool inc, char * value);
|
||||
bool get_string(const void * buffer, const bool inc, std::string& value);
|
||||
|
||||
void add_key(const void * buffer, size_t * ptr, const RecID record_id);
|
||||
|
||||
bool init_search(const void * buffer, const size_t size);
|
||||
bool search_key(const void * buffer, const RecID record_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue