Mstdlib-1.24.0

Typedefs

typedef struct M_hash_multi M_hash_multi_t
 
typedef void(* M_hash_multi_free_func) (void *)
 

Enumerations

enum  M_hash_multi_flags_t {
  M_HASH_MULTI_NONE = 0 ,
  M_HASH_MULTI_STR_CASECMP = 1 << 0
}
 
enum  M_hash_multi_val_type_t {
  M_HASH_MULTI_VAL_TYPE_UNKNOWN = 0 ,
  M_HASH_MULTI_VAL_TYPE_BOOL ,
  M_HASH_MULTI_VAL_TYPE_INT ,
  M_HASH_MULTI_VAL_TYPE_STR ,
  M_HASH_MULTI_VAL_TYPE_BIN ,
  M_HASH_MULTI_VAL_TYPE_VP
}
 

Functions

M_hash_multi_tM_hash_multi_create (M_uint32 flags) M_MALLOC
 
void M_hash_multi_destroy (M_hash_multi_t *h) M_FREE(1)
 
M_bool M_hash_multi_u64_insert_bool (M_hash_multi_t *h, M_uint64 key, M_bool val)
 
M_bool M_hash_multi_u64_insert_int (M_hash_multi_t *h, M_uint64 key, M_int64 val)
 
M_bool M_hash_multi_u64_insert_uint (M_hash_multi_t *h, M_uint64 key, M_uint64 val)
 
M_bool M_hash_multi_u64_insert_str (M_hash_multi_t *h, M_uint64 key, const char *val)
 
M_bool M_hash_multi_u64_insert_bin (M_hash_multi_t *h, M_uint64 key, const unsigned char *val, size_t len)
 
M_bool M_hash_multi_u64_insert_vp (M_hash_multi_t *h, M_uint64 key, void *val, M_hash_multi_free_func val_free)
 
M_bool M_hash_multi_u64_get_bool (const M_hash_multi_t *h, M_uint64 key, M_bool *val)
 
M_bool M_hash_multi_u64_get_int (const M_hash_multi_t *h, M_uint64 key, M_int64 *val)
 
M_bool M_hash_multi_u64_get_uint (const M_hash_multi_t *h, M_uint64 key, M_uint64 *val)
 
M_bool M_hash_multi_u64_get_str (const M_hash_multi_t *h, M_uint64 key, const char **val)
 
M_bool M_hash_multi_u64_get_bin (const M_hash_multi_t *h, M_uint64 key, const unsigned char **val, size_t *len)
 
M_bool M_hash_multi_u64_get_vp (const M_hash_multi_t *h, M_uint64 key, void **val)
 
M_bool M_hash_multi_u64_remove (M_hash_multi_t *h, M_uint64 key, M_bool destroy_vp)
 
M_hash_multi_val_type_t M_hash_multi_u64_type (const M_hash_multi_t *h, M_uint64 key)
 
M_bool M_hash_multi_str_insert_bool (M_hash_multi_t *h, const char *key, M_bool val)
 
M_bool M_hash_multi_str_insert_int (M_hash_multi_t *h, const char *key, M_int64 val)
 
M_bool M_hash_multi_str_insert_uint (M_hash_multi_t *h, const char *key, M_uint64 val)
 
M_bool M_hash_multi_str_insert_str (M_hash_multi_t *h, const char *key, const char *val)
 
M_bool M_hash_multi_str_insert_bin (M_hash_multi_t *h, const char *key, const unsigned char *val, size_t len)
 
M_bool M_hash_multi_str_insert_vp (M_hash_multi_t *h, const char *key, void *val, M_hash_multi_free_func val_free)
 
M_bool M_hash_multi_str_get_bool (const M_hash_multi_t *h, const char *key, M_bool *val)
 
M_bool M_hash_multi_str_get_int (const M_hash_multi_t *h, const char *key, M_int64 *val)
 
M_bool M_hash_multi_str_get_uint (const M_hash_multi_t *h, const char *key, M_uint64 *val)
 
M_bool M_hash_multi_str_get_str (const M_hash_multi_t *h, const char *key, const char **val)
 
M_bool M_hash_multi_str_get_bin (const M_hash_multi_t *h, const char *key, const unsigned char **val, size_t *len)
 
M_bool M_hash_multi_str_get_vp (const M_hash_multi_t *h, const char *key, void **val)
 
M_bool M_hash_multi_str_remove (M_hash_multi_t *h, const char *key, M_bool destroy_vp)
 
M_hash_multi_val_type_t M_hash_multi_str_type (const M_hash_multi_t *h, const char *key)
 

Detailed Description

Hashtable, meant for storing a variety of key and value types.

All data except void pointers will be duplicated.

Typedef Documentation

◆ M_hash_multi_t

typedef struct M_hash_multi M_hash_multi_t

◆ M_hash_multi_free_func

typedef void(* M_hash_multi_free_func) (void *)

Callback for freeing void pointer data.

Enumeration Type Documentation

◆ M_hash_multi_flags_t

Flags for controlling the behavior of the hash_multi.

Enumerator
M_HASH_MULTI_NONE 

String key compare is case sensitive.

M_HASH_MULTI_STR_CASECMP 

String key compare is case insensitive.

◆ M_hash_multi_val_type_t

Enumerator
M_HASH_MULTI_VAL_TYPE_UNKNOWN 

Unknown.

M_HASH_MULTI_VAL_TYPE_BOOL 

Boolean.

M_HASH_MULTI_VAL_TYPE_INT 

Integer.

M_HASH_MULTI_VAL_TYPE_STR 

String.

M_HASH_MULTI_VAL_TYPE_BIN 

Binary.

M_HASH_MULTI_VAL_TYPE_VP 

Void pointer. Could be any data.

Function Documentation

◆ M_hash_multi_create()

M_hash_multi_t * M_hash_multi_create ( M_uint32  flags)

Create a new multi hashtable.

Parameters
[in]flagsM_hash_multi_flags_t flags for modifying behavior.

return multi table.

◆ M_hash_multi_destroy()

void M_hash_multi_destroy ( M_hash_multi_t h)

Destroy the hashtable.

Parameters
[in]hHashtable to destroy.

◆ M_hash_multi_u64_insert_bool()

M_bool M_hash_multi_u64_insert_bool ( M_hash_multi_t h,
M_uint64  key,
M_bool  val 
)

Insert bool with an integer key.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in]valBoolean value.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_insert_int()

M_bool M_hash_multi_u64_insert_int ( M_hash_multi_t h,
M_uint64  key,
M_int64  val 
)

Insert signed integer with an integer key.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in]valSigned integer val.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_insert_uint()

M_bool M_hash_multi_u64_insert_uint ( M_hash_multi_t h,
M_uint64  key,
M_uint64  val 
)

Insert unsigned integer with an integer key.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in]valUnsigned integer val.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_insert_str()

M_bool M_hash_multi_u64_insert_str ( M_hash_multi_t h,
M_uint64  key,
const char *  val 
)

Insert string with an integer key.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in]valNULL terminated string.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_insert_bin()

M_bool M_hash_multi_u64_insert_bin ( M_hash_multi_t h,
M_uint64  key,
const unsigned char *  val,
size_t  len 
)

Insert binary data with an integer key.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in]valBinary data.
[in]lenLength of binary data.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_insert_vp()

M_bool M_hash_multi_u64_insert_vp ( M_hash_multi_t h,
M_uint64  key,
void *  val,
M_hash_multi_free_func  val_free 
)

Insert a void pointer with an integer key.

This will not duplicate the value. It only stores the memory address of the data. If a value exists at the given key, it will be destroyed if it was inserted with a value free function.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in]valThe memory location of the data.
[in]val_freeCallback for freeing the data.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_get_bool()

M_bool M_hash_multi_u64_get_bool ( const M_hash_multi_t h,
M_uint64  key,
M_bool *  val 
)

Get a bool value with a string key.

Parameters
[in]hHashtable.
[in]keyInteger key.
[in,out]valThe value to get.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_get_int()

M_bool M_hash_multi_u64_get_int ( const M_hash_multi_t h,
M_uint64  key,
M_int64 *  val 
)

Get a signed integer value with an integer key.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in,out]valThe value to get.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_get_uint()

M_bool M_hash_multi_u64_get_uint ( const M_hash_multi_t h,
M_uint64  key,
M_uint64 *  val 
)

Get an unsigned integer value with an integer key.

Parameters
[in]hHashtable.
[in]keyInteger key.
[in,out]valThe value to get.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_get_str()

M_bool M_hash_multi_u64_get_str ( const M_hash_multi_t h,
M_uint64  key,
const char **  val 
)

Get a string value with an integer key.

Parameters
[in]hHashtable.
[in]keyInteger key.
[in,out]valThe value to get.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_get_bin()

M_bool M_hash_multi_u64_get_bin ( const M_hash_multi_t h,
M_uint64  key,
const unsigned char **  val,
size_t *  len 
)

Get binary data with an integer key.

Parameters
[in]hHashtable.
[in]keyInteger key.
[in,out]valThe value to get.
[in,out]lenThe value length.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_get_vp()

M_bool M_hash_multi_u64_get_vp ( const M_hash_multi_t h,
M_uint64  key,
void **  val 
)

Get a void pointer value with an integer key.

Parameters
[in]hHashtable.
[in]keyInteger key.
[in,out]valThe value to get.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_remove()

M_bool M_hash_multi_u64_remove ( M_hash_multi_t h,
M_uint64  key,
M_bool  destroy_vp 
)

Remove a value with an integer key.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in]destroy_vpIf the value is a void pointer M_TRUE if the associated (if set) value free callback should be called.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_u64_type()

M_hash_multi_val_type_t M_hash_multi_u64_type ( const M_hash_multi_t h,
M_uint64  key 
)

Get the type of data stored in with an integer key.

Parameters
[in]hHashtable.
[in]keyInteger key.
Returns
The type.

◆ M_hash_multi_str_insert_bool()

M_bool M_hash_multi_str_insert_bool ( M_hash_multi_t h,
const char *  key,
M_bool  val 
)

Insert bool with an string key.

Parameters
[in,out]hHashtable.
[in]keyString key.
[in]valBoolean value.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_insert_int()

M_bool M_hash_multi_str_insert_int ( M_hash_multi_t h,
const char *  key,
M_int64  val 
)

Insert signed integer with a string key.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in]valSigned integer val
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_insert_uint()

M_bool M_hash_multi_str_insert_uint ( M_hash_multi_t h,
const char *  key,
M_uint64  val 
)

Insert unsigned integer with a string key.

Parameters
[in,out]hHashtable.
[in]keyString key.
[in]valUnsigned integer val.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_insert_str()

M_bool M_hash_multi_str_insert_str ( M_hash_multi_t h,
const char *  key,
const char *  val 
)

Insert string with a string key.

Parameters
[in,out]hHashtable.
[in]keyString key.
[in]valNULL terminated string.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_insert_bin()

M_bool M_hash_multi_str_insert_bin ( M_hash_multi_t h,
const char *  key,
const unsigned char *  val,
size_t  len 
)

Insert binary data with a string key.

Parameters
[in,out]hHashtable.
[in]keyString key.
[in]valBinary data.
[in]lenLength of binary data.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_insert_vp()

M_bool M_hash_multi_str_insert_vp ( M_hash_multi_t h,
const char *  key,
void *  val,
M_hash_multi_free_func  val_free 
)

Insert a void pointer with a string key.

This will not duplicate the value. It only stores the memory address of the data. The if a value exists at the given key it will be destroyed if it was inserted with a value free function.

Parameters
[in,out]hHashtable.
[in]keyString key.
[in]valThe memory location of the data.
[in]val_freeCallback for freeing the data.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_get_bool()

M_bool M_hash_multi_str_get_bool ( const M_hash_multi_t h,
const char *  key,
M_bool *  val 
)

Get a bool value with a string key.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in,out]valThe value to get.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_get_int()

M_bool M_hash_multi_str_get_int ( const M_hash_multi_t h,
const char *  key,
M_int64 *  val 
)

Get a signed integer value with a string key.

Parameters
[in,out]hHashtable.
[in]keyInteger key.
[in,out]valThe value to get.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_get_uint()

M_bool M_hash_multi_str_get_uint ( const M_hash_multi_t h,
const char *  key,
M_uint64 *  val 
)

Get an unsigned integer value with a string key.

Parameters
[in,out]hHashtable.
[in]keyString key.
[in,out]valThe value to get.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_get_str()

M_bool M_hash_multi_str_get_str ( const M_hash_multi_t h,
const char *  key,
const char **  val 
)

Get a string value with a string key.

Parameters
[in,out]hHashtable.
[in]keyString key.
[in,out]valThe value to get.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_get_bin()

M_bool M_hash_multi_str_get_bin ( const M_hash_multi_t h,
const char *  key,
const unsigned char **  val,
size_t *  len 
)

Get binary data with a string key.

Parameters
[in,out]hHashtable.
[in]keyString key.
[in,out]valThe value to get.
[in,out]lenThe value length.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_get_vp()

M_bool M_hash_multi_str_get_vp ( const M_hash_multi_t h,
const char *  key,
void **  val 
)

Get a void pointer value with a string key.

Parameters
[in,out]hHashtable.
[in]keyString key.
[in,out]valThe value to get.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_remove()

M_bool M_hash_multi_str_remove ( M_hash_multi_t h,
const char *  key,
M_bool  destroy_vp 
)

Remove a value with a string key.

Parameters
[in,out]hHashtable.
[in]keyString key.
[in]destroy_vpIf the value is a void pointer M_TRUE if the associated (if set) value free callback should be called.
Returns
M_TRUE if insert was successful. Otherwise M_FALSE.

◆ M_hash_multi_str_type()

M_hash_multi_val_type_t M_hash_multi_str_type ( const M_hash_multi_t h,
const char *  key 
)

Get the type of data stored in with a string key.

Parameters
[in]hHashtable.
[in]keyString key.
Returns
The type.