group
group__libshare__memmap
Provides the ability to manage object-related information by a key token.

Meta Definition Hashmap

typedef
typedef struct shmap_t shmap_t
A hashmap table.
typedef
typedef struct shmap_index_t shmap_index_t
A hashmap index.
typedef
typedef unsigned int(* shmapfunc_t)(const char *key, ssize_t *klen)
Callback functions for calculating hash values.
Param
key
The key.
klen
The length of the key.
typedef
typedef struct shmap_entry_t shmap_entry_t
A hashmap entry.
typedef
typedef struct shmap_value_t shmap_value_t
Specifies a reference to the current version of a shmap hashmap entry value.
function
shmap_t* shmap_init
(void)
Create an instance of a meta definition hashmap.
Return Value
A meta definition hashmap.
shmap_t structshmap__t compound
function
void shmap_free
(shmap_t **meta_p)
Free an instance of a meta definition hashmap.
Param
meta_p
A reference to the meta definition hashmap to be free'd.
function
void shmap_set
(shmap_t *ht, shkey_t *key, const void *val)
Set a key to a particular allocated value in a map.
Param
ht
The meta definition hashmap to retrieve from.
sh_k
The key of the meta definition value.
val
The allocated value.
Note
Do not free the value passed in.
function
void shmap_set_str
(shmap_t *h, shkey_t *key, char *value)
Set a meta definition to a string value.
Param
h
The meta definition hash map.
name
A string name identifying the meta definition.
value
A string value to be assigned.
Note
An allocated copy of the string value is stored.
function
void shmap_set_astr
(shmap_t *h, shkey_t *key, char *value)
Set a map key to an allocated copy of a string value.
function
void shmap_unset_str
(shmap_t *h, shkey_t *name)
Unset a string value from a meta definition.
function
void shmap_set_void
(shmap_t *ht, shkey_t *key, void *data, size_t data_len)
Set an object value in a meta definition hash map.
Param
h
The meta definition hash map.
name
The name of the meta definition.
data
The binary data to assign.
data_len
The size of the bindary data.
function
char* shmap_get_str
(shmap_t *h, shkey_t *key)
Get a string meta from a meta definition.
Return Value
A string reference to the hashmap value.
function
void* shmap_get_void
(shmap_t *h, shkey_t *key)
Obtain a non-specific binary data segment from a meta definition hash map.
Param
h
The meta definition hash map.
name
The name of the meta definition.
function
void* shmap_get
(shmap_t *ht, shkey_t *key)
Get a meta definition value.
Param
ht
The meta definition hashmap to retrieve from.
sh_k
The key of the meta definition value.
Return Value
A containing the hashmap value.
shmap_value_t structshmap__value__t compound
function
void shmap_print
(shmap_t *h, shbuf_t *ret_buff)
Prints out a JSON representation of a meta definition hashmap.
Note
The text buffer must be allocated by first.
shbuf_init() group__libshare__membuf_1gafac914ba170c0f2a9bc8c2add3a63a41 member
Param
h
The meta map to print.
ret_buff
The text buffer to return the JSON string representation.
function
void shmap_load
(shmap_t *ht, shbuf_t *buff)
Loads data dumped by . shmap_print() group__libshare__memmap_1ga99be5185d0537a6c2f9fbcb0ca9cc83c member
function
unsigned int shmap_count
(shmap_t *ht)
function
void shmap_set_ptr
(shmap_t *ht, shkey_t *key, void *ptr)
function
void* shmap_get_ptr
(shmap_t *h, shkey_t *key)
function
void** shmap_get_ptr_list
(shmap_t *h)
function
void shmap_set_abin
(shmap_t *ht, shkey_t *key, void *data, size_t data_len)
function
void shmap_set_bin
(shmap_t *ht, shkey_t *key, void *data, size_t data_len)
function
void shmap_unset
(shmap_t *h, shkey_t *name)
function
void shmap_self
(shmap_index_t *hi, shkey_t **key_p, void **val_p, ssize_t *len_p, int *flag_p)
function
int shmap_set_ent
(shmap_t *ht, shkey_t *key, int map_flag, void *val, ssize_t val_size)
function
void shbuf_append
(shbuf_t *from_buff, shbuf_t *to_buff)
function
shbuf_t* shbuf_clone
(shbuf_t *buff)
function
int shbuf_sprintf
(shbuf_t *buff, char *fmt,...)
Return Value
the number of characters appended to the memory buffer.
Note
passes arguments through vsnprintf().
define
INITIAL_MAX
15
The initial number of hashmap indexes to create.
define
SHMETA_BIG_ENDIAN
0
Specifies that a machine has a big endian architecture.
See
SHMETA_VALUE_ENDIAN group__libshare__memmap_1gabbd81e29e6bbee43df50a9fda916caf5 member
define
SHMETA_SMALL_ENDIAN
1
Specifies that a machine has a small endian architecture.
See
SHMETA_VALUE_ENDIAN group__libshare__memmap_1gabbd81e29e6bbee43df50a9fda916caf5 member
define
SHMETA_VALUE_ENDIAN
(_val->magic == SHMEM_ENDIAN_MAGIC ? \ SHMETA_BIG_ENDIAN : SHMETA_SMALL_ENDIAN)
Determines whether the meta value originated from a big or small endian architecture.
Return Value
SHMETA_BIG_ENDIAN or SHMETA_SMALL_ENDIAN based on the meta value.
define
SHMAP_ALLOC
(1 << 0)
Indicates the underlying map value has been allocated.
define
SHMAP_STRING
(1 << 10)
A null-terminated string value.
define
SHMAP_NUMBER
(1 << 11)
A numeric value with decimal precision.
define
SHMAP_BINARY
(1 << 13)
A non-specific binary memory segment.