Generic Value Hash management
[Generic Value Storage]
Data Structures | |
struct | _Eina_Value_Hash |
Used to store the hash and its subtype. More... | |
Typedefs | |
typedef struct _Eina_Value_Hash | Eina_Value_Hash |
Value type for EINA_VALUE_TYPE_HASH. | |
Functions | |
Eina_Value * | eina_value_hash_new (const Eina_Value_Type *subtype, unsigned int buckets_power_size) |
Create generic value storage of type hash. | |
static Eina_Bool | eina_value_hash_setup (Eina_Value *value, const Eina_Value_Type *subtype, unsigned int buckets_power_size) |
Initialize generic value storage of type hash. | |
static unsigned int | eina_value_hash_population (const Eina_Value *value) |
Query number of elements in value of hash type. | |
static Eina_Bool | eina_value_hash_del (Eina_Value *value, const char *key) |
Remove element at given position in value of hash type. | |
static Eina_Bool | eina_value_hash_set (Eina_Value *value, const char *key,...) |
Set the generic value in an hash member. | |
static Eina_Bool | eina_value_hash_get (const Eina_Value *value, const char *key,...) |
Get the generic value from an hash member. | |
static Eina_Bool | eina_value_hash_vset (Eina_Value *value, const char *key, va_list args) |
Set the generic value in an hash member. | |
static Eina_Bool | eina_value_hash_vget (const Eina_Value *value, const char *key, va_list args) |
Get the generic value from an hash member. | |
static Eina_Bool | eina_value_hash_pset (Eina_Value *value, const char *key, const void *ptr) |
Set the generic value in an hash member from pointer. | |
static Eina_Bool | eina_value_hash_pget (const Eina_Value *value, const char *key, void *ptr) |
Get the generic value to pointer from an hash member. |
Typedef Documentation
Function Documentation
Eina_Value* eina_value_hash_new | ( | const Eina_Value_Type * | subtype, | |
unsigned int | buckets_power_size | |||
) |
Create generic value storage of type hash.
- Parameters:
-
subtype how to manage this hash members. buckets_power_size how to allocate hash buckets (2 ^ buckets_power_size), if zero then a sane value is chosen.
- Returns:
- The new value or
NULL
on failure.
On failure, NULL
is returned and EINA_ERROR_OUT_OF_MEMORY or EINA_ERROR_VALUE_FAILED is set.
- Note:
- this creates from mempool and then uses eina_value_hash_setup().
- See also:
- eina_value_free()
- Since:
- 1.2
References EINA_FALSE, eina_mempool_free(), eina_mempool_malloc(), eina_value_hash_setup(), and eina_value_type_check().
static Eina_Bool eina_value_hash_setup | ( | Eina_Value * | value, | |
const Eina_Value_Type * | subtype, | |||
unsigned int | buckets_power_size | |||
) | [inline, static] |
Initialize generic value storage of type hash.
- Parameters:
-
value value object subtype how to manage this hash members. buckets_power_size how to allocate hash buckets (2 ^ buckets_power_size), if zero then a sane value is chosen.
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
This is the same as calling eina_value_set() with EINA_VALUE_TYPE_HASH followed by eina_value_pset() with the Eina_Value_Hash description configured.
- Note:
- Existing contents are ignored! If the value was previously used, then use eina_value_flush() first.
- See also:
- eina_value_flush()
- Since:
- 1.2
Referenced by eina_value_hash_new().
static unsigned int eina_value_hash_population | ( | const Eina_Value * | value | ) | [inline, static] |
Query number of elements in value of hash type.
- Parameters:
-
value value object.
- Returns:
- number of child elements.
- Since:
- 1.2
static Eina_Bool eina_value_hash_del | ( | Eina_Value * | value, | |
const char * | key | |||
) | [inline, static] |
Remove element at given position in value of hash type.
- Parameters:
-
value value object. key key to find the member
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
- Since:
- 1.2
static Eina_Bool eina_value_hash_set | ( | Eina_Value * | value, | |
const char * | key, | |||
... | ||||
) | [inline, static] |
Set the generic value in an hash member.
- Parameters:
-
value source value object key key to find the member
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
- EINA_VALUE_TYPE_UCHAR: unsigned char
- EINA_VALUE_TYPE_USHORT: unsigned short
- EINA_VALUE_TYPE_UINT: unsigned int
- EINA_VALUE_TYPE_ULONG: unsigned long
- EINA_VALUE_TYPE_UINT64: uint64_t
- EINA_VALUE_TYPE_CHAR: char
- EINA_VALUE_TYPE_SHORT: short
- EINA_VALUE_TYPE_INT: int
- EINA_VALUE_TYPE_LONG: long
- EINA_VALUE_TYPE_INT64: int64_t
- EINA_VALUE_TYPE_FLOAT: float
- EINA_VALUE_TYPE_DOUBLE: double
- EINA_VALUE_TYPE_STRINGSHARE: const char *
- EINA_VALUE_TYPE_STRING: const char *
- EINA_VALUE_TYPE_HASH: Eina_Value_Hash
- EINA_VALUE_TYPE_TIMEVAL: struct timeval*
- EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
- EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); int x; eina_value_hash_set(value, "abc", 5678); eina_value_hash_get(value, "abc", &x); eina_value_free(value);
- Since:
- 1.2
static Eina_Bool eina_value_hash_get | ( | const Eina_Value * | value, | |
const char * | key, | |||
... | ||||
) | [inline, static] |
Get the generic value from an hash member.
- Parameters:
-
value source value object key key to find the member
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
The variable argument is dependent on chosen subtype. The list for basic types:
- EINA_VALUE_TYPE_UCHAR: unsigned char*
- EINA_VALUE_TYPE_USHORT: unsigned short*
- EINA_VALUE_TYPE_UINT: unsigned int*
- EINA_VALUE_TYPE_ULONG: unsigned long*
- EINA_VALUE_TYPE_UINT64: uint64_t*
- EINA_VALUE_TYPE_CHAR: char*
- EINA_VALUE_TYPE_SHORT: short*
- EINA_VALUE_TYPE_INT: int*
- EINA_VALUE_TYPE_LONG: long*
- EINA_VALUE_TYPE_INT64: int64_t*
- EINA_VALUE_TYPE_FLOAT: float*
- EINA_VALUE_TYPE_DOUBLE: double*
- EINA_VALUE_TYPE_STRINGSHARE: const char **
- EINA_VALUE_TYPE_STRING: const char **
- EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
- EINA_VALUE_TYPE_TIMEVAL: struct timeval*
- EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
- EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); int x; eina_value_hash_set(value, "abc", 1234); eina_value_hash_get(value, "abc", &x); eina_value_free(value);
- Since:
- 1.2
static Eina_Bool eina_value_hash_vset | ( | Eina_Value * | value, | |
const char * | key, | |||
va_list | args | |||
) | [inline, static] |
Set the generic value in an hash member.
- Parameters:
-
value source value object key key to find the member args variable argument
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
- Since:
- 1.2
static Eina_Bool eina_value_hash_vget | ( | const Eina_Value * | value, | |
const char * | key, | |||
va_list | args | |||
) | [inline, static] |
Get the generic value from an hash member.
- Parameters:
-
value source value object key key to find the member args variable argument
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
- Since:
- 1.2
static Eina_Bool eina_value_hash_pset | ( | Eina_Value * | value, | |
const char * | key, | |||
const void * | ptr | |||
) | [inline, static] |
Set the generic value in an hash member from pointer.
- Parameters:
-
value source value object key key to find the member ptr pointer to specify the contents.
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
- EINA_VALUE_TYPE_UCHAR: unsigned char*
- EINA_VALUE_TYPE_USHORT: unsigned short*
- EINA_VALUE_TYPE_UINT: unsigned int*
- EINA_VALUE_TYPE_ULONG: unsigned long*
- EINA_VALUE_TYPE_UINT64: uint64_t*
- EINA_VALUE_TYPE_CHAR: char*
- EINA_VALUE_TYPE_SHORT: short*
- EINA_VALUE_TYPE_INT: int*
- EINA_VALUE_TYPE_LONG: long*
- EINA_VALUE_TYPE_INT64: int64_t*
- EINA_VALUE_TYPE_FLOAT: float*
- EINA_VALUE_TYPE_DOUBLE: double*
- EINA_VALUE_TYPE_STRINGSHARE: const char **
- EINA_VALUE_TYPE_STRING: const char **
- EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
- EINA_VALUE_TYPE_TIMEVAL: struct timeval*
- EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
- EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
- Note:
- the pointer contents are written using the size defined by type. It can be larger than void* or uint64_t.
Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); int x = 1234; eina_value_hash_pset(value, "abc", &x); eina_value_hash_pget(value, "abc", &x); eina_value_free(value);
- Since:
- 1.2
static Eina_Bool eina_value_hash_pget | ( | const Eina_Value * | value, | |
const char * | key, | |||
void * | ptr | |||
) | [inline, static] |
Get the generic value to pointer from an hash member.
- Parameters:
-
value source value object key key to find the member ptr pointer to receive the contents.
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
The pointer type is dependent on chosen value type. The list for basic types:
- EINA_VALUE_TYPE_UCHAR: unsigned char*
- EINA_VALUE_TYPE_USHORT: unsigned short*
- EINA_VALUE_TYPE_UINT: unsigned int*
- EINA_VALUE_TYPE_ULONG: unsigned long*
- EINA_VALUE_TYPE_UINT64: uint64_t*
- EINA_VALUE_TYPE_CHAR: char*
- EINA_VALUE_TYPE_SHORT: short*
- EINA_VALUE_TYPE_INT: int*
- EINA_VALUE_TYPE_LONG: long*
- EINA_VALUE_TYPE_INT64: int64_t*
- EINA_VALUE_TYPE_FLOAT: float*
- EINA_VALUE_TYPE_DOUBLE: double*
- EINA_VALUE_TYPE_STRINGSHARE: const char **
- EINA_VALUE_TYPE_STRING: const char **
- EINA_VALUE_TYPE_HASH: Eina_Value_Hash*
- EINA_VALUE_TYPE_TIMEVAL: struct timeval*
- EINA_VALUE_TYPE_BLOB: Eina_Value_Blob*
- EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct*
Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); int x; eina_value_hash_set(value, "abc", 1234); eina_value_hash_pget(value, "abc", &x); eina_value_free(value);
- Since:
- 1.2