AM263Px MCU+ SDK  10.01.00
simpledb.h File Reference

Go to the source code of this file.

Data Structures

struct  simpledb_keydata_t
 
struct  key_range_t
 

Macros

#define MAX_NUM_DBLIST   20
 
#define SIMPLEDB_FLAG_CREATE   (1u<<0u)
 put data into the db. More...
 
#define SIMPLEDB_FLAG_APPEND   (1u<<1u)
 
#define SIMPLEDB_FORWARD   1
 get key or value in the range More...
 
#define SIMPLEDB_BACKWARD   -1
 
#define SIMPLEDB_NOMOVE   0
 

Typedefs

typedef struct simpledb_data simpledb_data_t
 
typedef struct simpledb_range simpledb_range_t
 

Functions

simpledb_data_tsimpledb_open (const char *pfname)
 open the db. if pfname is set, the config(rw) data is restored from the file. More...
 
void simpledb_close (simpledb_data_t *sdbd)
 close the db. if pfname is set at the open, the config(rw) data is saved. More...
 
int simpledb_savedata (simpledb_data_t *sdbd, key_range_t **keyranges)
 save data to a file More...
 
int simpledb_put (simpledb_data_t *sdbd, simpledb_keydata_t *kd, void *value, uint32_t vlen, uint8_t flags)
 
int simpledb_get (simpledb_data_t *sdbd, simpledb_keydata_t *kd, void **value, uint32_t *vlen)
 get data from the db More...
 
int simpledb_get_release (simpledb_data_t *sdbd, simpledb_keydata_t *kd)
 
int simpledb_del (simpledb_data_t *sdbd, simpledb_keydata_t *kd)
 delete the key item. need to be unlocked status. More...
 
simpledb_range_tsimpledb_get_range (simpledb_data_t *sdbd, key_range_t *krange)
 get datarange pointer which the keys are between (key1, key2) More...
 
void simpledb_get_range_release (simpledb_data_t *sdbd, simpledb_range_t *rangedp)
 
int simpledb_get_from_range (simpledb_data_t *sdbd, simpledb_range_t *rangedp, void **kdata, uint32_t *ksize, void **vdata, uint32_t *vsize, int direction)
 
void simpledb_move_top_range (simpledb_data_t *sdbd, simpledb_range_t *rangedp)
 
void simpledb_move_bottom_range (simpledb_data_t *sdbd, simpledb_range_t *rangedp)
 
int simpledb_move_in_range (simpledb_data_t *sdbd, simpledb_range_t *rangedp, int direction)
 
int simpledb_del_in_range (simpledb_data_t *sdbd, simpledb_range_t *rangedp, int direction)
 
int simpledb_wait_release (simpledb_data_t *sdbd, int toutms)
 

Macro Definition Documentation

◆ MAX_NUM_DBLIST

#define MAX_NUM_DBLIST   20

◆ SIMPLEDB_FLAG_CREATE

#define SIMPLEDB_FLAG_CREATE   (1u<<0u)

put data into the db.

Note
if it has CREATE flag, a new item is added. if it has APPEND flag, data is added at the bottom when the key exist

◆ SIMPLEDB_FLAG_APPEND

#define SIMPLEDB_FLAG_APPEND   (1u<<1u)

◆ SIMPLEDB_FORWARD

#define SIMPLEDB_FORWARD   1

get key or value in the range

Note
directon set pointer move, 1:forward, 0:stay, -1:backward

◆ SIMPLEDB_BACKWARD

#define SIMPLEDB_BACKWARD   -1

◆ SIMPLEDB_NOMOVE

#define SIMPLEDB_NOMOVE   0

Typedef Documentation

◆ simpledb_data_t

typedef struct simpledb_data simpledb_data_t

◆ simpledb_range_t

typedef struct simpledb_range simpledb_range_t

Function Documentation

◆ simpledb_open()

simpledb_data_t* simpledb_open ( const char *  pfname)

open the db. if pfname is set, the config(rw) data is restored from the file.

◆ simpledb_close()

void simpledb_close ( simpledb_data_t sdbd)

close the db. if pfname is set at the open, the config(rw) data is saved.

◆ simpledb_savedata()

int simpledb_savedata ( simpledb_data_t sdbd,
key_range_t **  keyranges 
)

save data to a file

Note
keyranges must be terminated by NULL

◆ simpledb_put()

int simpledb_put ( simpledb_data_t sdbd,
simpledb_keydata_t kd,
void *  value,
uint32_t  vlen,
uint8_t  flags 
)

◆ simpledb_get()

int simpledb_get ( simpledb_data_t sdbd,
simpledb_keydata_t kd,
void **  value,
uint32_t *  vlen 
)

get data from the db

Note
untill simpledb_get_release is called, the item becomes readonly.

◆ simpledb_get_release()

int simpledb_get_release ( simpledb_data_t sdbd,
simpledb_keydata_t kd 
)

◆ simpledb_del()

int simpledb_del ( simpledb_data_t sdbd,
simpledb_keydata_t kd 
)

delete the key item. need to be unlocked status.

◆ simpledb_get_range()

simpledb_range_t* simpledb_get_range ( simpledb_data_t sdbd,
key_range_t krange 
)

get datarange pointer which the keys are between (key1, key2)

Note
untill 'simpledb_keylist_release' is called, all items in the range are locked and become readonly

◆ simpledb_get_range_release()

void simpledb_get_range_release ( simpledb_data_t sdbd,
simpledb_range_t rangedp 
)

◆ simpledb_get_from_range()

int simpledb_get_from_range ( simpledb_data_t sdbd,
simpledb_range_t rangedp,
void **  kdata,
uint32_t *  ksize,
void **  vdata,
uint32_t *  vsize,
int  direction 
)

◆ simpledb_move_top_range()

void simpledb_move_top_range ( simpledb_data_t sdbd,
simpledb_range_t rangedp 
)

◆ simpledb_move_bottom_range()

void simpledb_move_bottom_range ( simpledb_data_t sdbd,
simpledb_range_t rangedp 
)

◆ simpledb_move_in_range()

int simpledb_move_in_range ( simpledb_data_t sdbd,
simpledb_range_t rangedp,
int  direction 
)

◆ simpledb_del_in_range()

int simpledb_del_in_range ( simpledb_data_t sdbd,
simpledb_range_t rangedp,
int  direction 
)

◆ simpledb_wait_release()

int simpledb_wait_release ( simpledb_data_t sdbd,
int  toutms 
)