Data Structures | Typedefs | Functions
Generic Value Hash management

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. More...
 

Functions

EAPI Eina_Valueeina_value_hash_new (const Eina_Value_Type *subtype, unsigned int buckets_power_size)
 Creates generic value storage of type hash. More...
 
static Eina_Bool eina_value_hash_setup (Eina_Value *value, const Eina_Value_Type *subtype, unsigned int buckets_power_size)
 Initializes generic value storage of type hash. More...
 
static unsigned int eina_value_hash_population (const Eina_Value *value)
 Queries number of elements in value of hash type. More...
 
static Eina_Bool eina_value_hash_del (Eina_Value *value, const char *key)
 Removes element at given position in value of hash type. More...
 
static Eina_Bool eina_value_hash_set (Eina_Value *value, const char *key,...)
 Sets the generic value in an hash member. More...
 
static Eina_Bool eina_value_hash_get (const Eina_Value *value, const char *key,...)
 Gets the generic value from an hash member. More...
 
static Eina_Bool eina_value_hash_vset (Eina_Value *value, const char *key, va_list args)
 Sets the generic value in an hash member. More...
 
static Eina_Bool eina_value_hash_vget (const Eina_Value *value, const char *key, va_list args)
 Gets the generic value from an hash member. More...
 
static Eina_Bool eina_value_hash_pset (Eina_Value *value, const char *key, const void *ptr)
 Sets the generic value in an hash member from pointer. More...
 
static Eina_Bool eina_value_hash_pget (const Eina_Value *value, const char *key, void *ptr)
 Gets the generic value to pointer from an hash member. More...
 

Detailed Description

Typedef Documentation

◆ Eina_Value_Hash

Value type for EINA_VALUE_TYPE_HASH.

See also
_Eina_Value_Hash explains fields.
Since
1.2

Function Documentation

◆ eina_value_hash_new()

EAPI Eina_Value* eina_value_hash_new ( const Eina_Value_Type subtype,
unsigned int  buckets_power_size 
)

Creates generic value storage of type hash.

Parameters
[in]subtypeHow to manage this hash members.
[in]buckets_power_sizeHow to allocate hash buckets (2 ^ buckets_power_size), if zero then a sane value is chosen.
Returns
The new value, or NULL on failure.

Creates a new generic value storage of type hash. The members are managed using the description specified by subtype.

On failure, NULL is returned.

Note
this creates from mempool and then uses eina_value_hash_setup().
See also
eina_value_free()
eina_value_hash_setup()
Since
1.2

References eina_mempool_free(), eina_mempool_malloc(), EINA_SAFETY_ON_FALSE_RETURN_VAL, eina_value_hash_setup(), and eina_value_type_check().

◆ eina_value_hash_setup()

static Eina_Bool eina_value_hash_setup ( Eina_Value value,
const Eina_Value_Type subtype,
unsigned int  buckets_power_size 
)
inlinestatic

Initializes generic value storage of type hash.

Parameters
[in]valueValue object
[in]subtypeHow to manage this hash members.
[in]buckets_power_sizeHow to allocate hash buckets (2 ^ buckets_power_size), if zero then a sane value is chosen.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

Initializes new generic value storage of type hash with the given subtype.

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.

On failure, EINA_FALSE is returned.

See also
eina_value_flush()
Since
1.2

Referenced by eina_value_hash_new().

◆ eina_value_hash_population()

static unsigned int eina_value_hash_population ( const Eina_Value value)
inlinestatic

Queries number of elements in value of hash type.

Parameters
[in]valuevalue object.
Returns
number of child elements.
Since
1.2

◆ eina_value_hash_del()

static Eina_Bool eina_value_hash_del ( Eina_Value value,
const char *  key 
)
inlinestatic

Removes element at given position in value of hash type.

Parameters
[in,out]valuevalue object.
[in]keykey to find the member
Returns
EINA_TRUE on success, EINA_FALSE otherwise.
Since
1.2

◆ eina_value_hash_set()

static Eina_Bool eina_value_hash_set ( Eina_Value value,
const char *  key,
  ... 
)
inlinestatic

Sets the generic value in an hash member.

Parameters
[in,out]valueSource value object
[in]keyKey to find the member
[in]...Variable arguments of data to set
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

The variable argument is dependent on chosen subtype. The list for basic types:

  • EINA_VALUE_TYPE_VALUE: Eina_Value
  • EINA_VALUE_TYPE_ERROR: Eina_Error
  • 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_TYPE_TM: struct tm*
int x;
eina_value_hash_set(value, "abc", 5678);
eina_value_hash_get(value, "abc", &x);
See also
eina_value_hash_get()
eina_value_hash_vset()
eina_value_hash_pset()
eina_value_hash_del()
Since
1.2

◆ eina_value_hash_get()

static Eina_Bool eina_value_hash_get ( const Eina_Value value,
const char *  key,
  ... 
)
inlinestatic

Gets the generic value from an hash member.

Parameters
[in]valueSource value object
[in]keyKey to find the member
[out]...
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

The value is returned in the variable argument parameter, the actual value is type-dependent, but usually it will be what is stored inside the object. There shouldn't be any memory allocation, thus the contents should not be freed.

The variable argument is dependent on chosen subtype. The list for basic types:

  • EINA_VALUE_TYPE_VALUE: Eina_Value*
  • EINA_VALUE_TYPE_ERROR: Eina_Error*
  • 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_TYPE_TM: struct tm*
int x;
eina_value_hash_set(value, "abc", 1234);
eina_value_hash_get(value, "abc", &x);
See also
eina_value_hash_set()
eina_value_hash_vset()
eina_value_hash_pset()
Since
1.2

◆ eina_value_hash_vset()

static Eina_Bool eina_value_hash_vset ( Eina_Value value,
const char *  key,
va_list  args 
)
inlinestatic

Sets the generic value in an hash member.

Parameters
[in,out]valueSource value object
[in]keyKey to find the member
[in]argsVariable argument
Returns
EINA_TRUE on success, EINA_FALSE otherwise.
See also
eina_value_hash_set()
eina_value_hash_get()
eina_value_hash_pset()
Since
1.2

◆ eina_value_hash_vget()

static Eina_Bool eina_value_hash_vget ( const Eina_Value value,
const char *  key,
va_list  args 
)
inlinestatic

Gets the generic value from an hash member.

Parameters
[in]valueSource value object
[in]keyKey to find the member
[out]argsVariable argument
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

The value is returned in the variable argument parameter, the actual value is type-dependent, but usually it will be what is stored inside the object. There shouldn't be any memory allocation, thus the contents should not be freed.

See also
eina_value_hash_vset()
eina_value_hash_get()
eina_value_hash_pget()
Since
1.2

◆ eina_value_hash_pset()

static Eina_Bool eina_value_hash_pset ( Eina_Value value,
const char *  key,
const void *  ptr 
)
inlinestatic

Sets the generic value in an hash member from pointer.

Parameters
[in,out]valueSource value object
[in]keyKey to find the member
[in]ptrPointer to specify 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_VALUE: Eina_Value*
  • EINA_VALUE_TYPE_ERROR: Eina_Error*
  • 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_TYPE_TM: struct tm*
Note
the pointer contents are written using the size defined by type. It can be larger than void* or uint64_t.
int x = 1234;
eina_value_hash_pset(value, "abc", &x);
eina_value_hash_pget(value, "abc", &x);
See also
eina_value_hash_set()
eina_value_hash_get()
eina_value_hash_vset()
Since
1.2

◆ eina_value_hash_pget()

static Eina_Bool eina_value_hash_pget ( const Eina_Value value,
const char *  key,
void *  ptr 
)
inlinestatic

Gets the generic value to pointer from an hash member.

Parameters
[in]valueSource value object
[in]keyKey to find the member
[out]ptrPointer to receive the contents.
Returns
EINA_TRUE on success, EINA_FALSE otherwise.

The value is returned in pointer contents, the actual value is type-dependent, but usually it will be what is stored inside the object. There shouldn't be any memory allocation, thus the contents should not be freed.

The pointer type is dependent on chosen value type. The list for basic types:

  • EINA_VALUE_TYPE_VALUE: Eina_Value*
  • EINA_VALUE_TYPE_ERROR: Eina_Error*
  • 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_TYPE_TM: struct tm*
int x;
eina_value_hash_set(value, "abc", 1234);
eina_value_hash_pget(value, "abc", &x);
See also
eina_value_hash_set()
eina_value_hash_vset()
eina_value_hash_pset()
Since
1.2