at work
This commit is contained in:
60
clib/jblock.h
Normal file
60
clib/jblock.h
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
#ifndef JKEYVAL_H_QWERTY
|
||||
#define JKEYVAL_H_QWERTY
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct {
|
||||
char* data;
|
||||
int capa;
|
||||
int size;
|
||||
} jstring_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
char* key;
|
||||
int type;
|
||||
union {
|
||||
int64_t num;
|
||||
bool flag;
|
||||
char* str;
|
||||
double flt;
|
||||
int64_t* numarr;
|
||||
char** strarr;
|
||||
double* fltarr;
|
||||
bool* flagarr;
|
||||
};
|
||||
int arrsize;
|
||||
int arrcapa;
|
||||
} jkeyval_t;
|
||||
|
||||
typedef struct {
|
||||
jkeyval_t* kvarr;
|
||||
int kvsize;
|
||||
int kvcapa;
|
||||
} jblock_t;
|
||||
|
||||
#define JKVTYPE_INT 0x01
|
||||
#define JKVTYPE_STR 0x02
|
||||
#define JKVTYPE_BOOL 0x03
|
||||
#define JKVTYPE_FLT 0x04
|
||||
#define JKVTYPE_INTARR 0x11
|
||||
#define JKVTYPE_STRARR 0x12
|
||||
#define JKVTYPE_BOOLARR 0x13
|
||||
#define JKVTYPE_FLTARR 0x14
|
||||
|
||||
#define JB_MALLOCERR -1
|
||||
#define JB_KEYEXISTS -2
|
||||
|
||||
|
||||
void jblock_init(jblock_t* kv);
|
||||
void jblock_outjson(jblock_t* kv, char** res);
|
||||
void jblock_destroy(jblock_t* kv);
|
||||
|
||||
int jblock_addint(jblock_t* kv, char* key, int64_t val);
|
||||
int jblock_addfloat(jblock_t* kv, char* key, double val);
|
||||
int jblock_addstr(jblock_t* kv, char* key, char* val);
|
||||
int jblock_addbool(jblock_t* kv, char* key, bool val);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user