mruby/c VM Source Code release 3.4
Loading...
Searching...
No Matches
keyvalue.c File Reference

mruby/c Key(Symbol) - Value store. More...

#include "mrubyc.h"
Include dependency graph for keyvalue.c:

Go to the source code of this file.

Macros

#define MRBC_KV_SIZE_INIT   2
#define MRBC_KV_SIZE_INCREMENT   5

Functions

static int binary_search (mrbc_kv_handle *kvh, mrbc_sym sym_id)
mrbc_kv_handlemrbc_kv_new (struct VM *vm, int size)
int mrbc_kv_init_handle (struct VM *vm, mrbc_kv_handle *kvh, int size)
void mrbc_kv_delete (mrbc_kv_handle *kvh)
void mrbc_kv_delete_data (mrbc_kv_handle *kvh)
int mrbc_kv_resize (mrbc_kv_handle *kvh, int size)
int mrbc_kv_set (mrbc_kv_handle *kvh, mrbc_sym sym_id, mrbc_value *set_val)
mrbc_valuemrbc_kv_get (mrbc_kv_handle *kvh, mrbc_sym sym_id)
int mrbc_kv_remove (mrbc_kv_handle *kvh, mrbc_sym sym_id)
void mrbc_kv_clear (mrbc_kv_handle *kvh)
void mrbc_kv_dup (const mrbc_kv_handle *src, mrbc_kv_handle *dst)

Detailed Description

mruby/c Key(Symbol) - Value store.

 Copyright (C) 2015- Kyushu Institute of Technology.
 Copyright (C) 2015- Shimane IT Open-Innovation Center.

 This file is distributed under BSD 3-Clause License.


Function summary

(constructor)
   mrbc_kv_new()

(destructor)
   mrbc_kv_delete()
   mrbc_kv_delete_data()

(initializer)
   mrbc_kv_init_handle()

(setter)
 --[name]-------------[arg]---[ret]---[note]----------------------------------
   mrbc_kv_set()        *V      int

(getter)
 --[name]-------------[arg]---[ret]---[note]----------------------------------
   mrbc_kv_get()        SymID   *V

(others)
   mrbc_kv_resize()
   mrbc_kv_remove()
   mrbc_kv_clear()
   mrbc_kv_dup()
   mrbc_kv_size()

 (iterator)
   mrbc_kv_iterator_new()
   mrbc_kv_i_is_first()
   mrbc_kv_i_has_next()
   mrbc_kv_i_get()
   mrbc_kv_i_next()
 

Definition in file keyvalue.c.

Macro Definition Documentation

◆ MRBC_KV_SIZE_INCREMENT

#define MRBC_KV_SIZE_INCREMENT   5

Definition at line 64 of file keyvalue.c.

◆ MRBC_KV_SIZE_INIT

#define MRBC_KV_SIZE_INIT   2

Definition at line 61 of file keyvalue.c.

Function Documentation

◆ binary_search()

int binary_search ( mrbc_kv_handle * kvh,
mrbc_sym sym_id )
static

binary search

Parameters
kvhpointer to key-value handle.
sym_idsymbol ID.
Returns
result. It's not necessarily found.

Definition at line 81 of file keyvalue.c.

Here is the caller graph for this function:

◆ mrbc_kv_clear()

void mrbc_kv_clear ( mrbc_kv_handle * kvh)

clear all

Parameters
kvhpointer to key-value handle.

Definition at line 389 of file keyvalue.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_kv_delete()

void mrbc_kv_delete ( mrbc_kv_handle * kvh)

destructor

Parameters
kvhpointer to key-value handle.

Definition at line 159 of file keyvalue.c.

Here is the call graph for this function:

◆ mrbc_kv_delete_data()

void mrbc_kv_delete_data ( mrbc_kv_handle * kvh)

delete all datas and free data memory.

Parameters
kvhpointer to key-value handle.

Definition at line 171 of file keyvalue.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_kv_dup()

void mrbc_kv_dup ( const mrbc_kv_handle * src,
mrbc_kv_handle * dst )

duplicate

Parameters
srcpointer to key-value handle source.
dstpointer to key-value handle destination.

Definition at line 408 of file keyvalue.c.

Here is the call graph for this function:

◆ mrbc_kv_get()

mrbc_value * mrbc_kv_get ( mrbc_kv_handle * kvh,
mrbc_sym sym_id )

getter

Parameters
kvhpointer to key-value handle.
sym_idsymbol ID.
Returns
pointer to mrbc_value or NULL.

Definition at line 292 of file keyvalue.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_kv_init_handle()

int mrbc_kv_init_handle ( struct VM * vm,
mrbc_kv_handle * kvh,
int size )

initialize handle

Parameters
vmPointer to VM.
kvhPointer to Key-Value handle.
sizeInitial size of data.
Returns
0 if no error.

Definition at line 131 of file keyvalue.c.

Here is the caller graph for this function:

◆ mrbc_kv_new()

mrbc_kv_handle * mrbc_kv_new ( struct VM * vm,
int size )

constructor

Parameters
vmPointer to VM.
sizeInitial size of data.
Returns
Key-Value handle.

Definition at line 109 of file keyvalue.c.

Here is the call graph for this function:

◆ mrbc_kv_remove()

int mrbc_kv_remove ( mrbc_kv_handle * kvh,
mrbc_sym sym_id )

remove a data

Parameters
kvhpointer to key-value handle.
sym_idsymbol ID.
Returns
mrbc_error_code.

Definition at line 368 of file keyvalue.c.

Here is the call graph for this function:

◆ mrbc_kv_resize()

int mrbc_kv_resize ( mrbc_kv_handle * kvh,
int size )

resize buffer

Parameters
kvhpointer to key-value handle.
sizesize.
Returns
mrbc_error_code.

Definition at line 211 of file keyvalue.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_kv_set()

int mrbc_kv_set ( mrbc_kv_handle * kvh,
mrbc_sym sym_id,
mrbc_value * set_val )

setter

Parameters
kvhpointer to key-value handle.
sym_idsymbol ID.
set_valset value.
Returns
mrbc_error_code.

Definition at line 233 of file keyvalue.c.

Here is the call graph for this function:
Here is the caller graph for this function: