The Value Definition Structure
[Miscellaneous]


Data Structures

struct  Cmaid_Value
 The value structure. More...

Defines

#define FALSE   (1 == 0)
 If not available define FALSE.
#define TRUE   (1 == 1)
 If not available define TRUE.
#define CMAID_VALUE_COMPARE_CB(func)   ((Cmaid_Value_Compare_Cb)(func))
 Casts a callback to Cmaid_Value_Compare_Cb.
#define CMAID_VALUE_HASH_CB(func)   ((Cmaid_Value_Hash_Cb)(func))
 Casts a callback to Cmaid_Value_Hash_Cb.
#define CMAID_VALUE_SIZE_CB(func)   ((Cmaid_Value_Size_Cb)(func))
 Casts a callback to Cmaid_Value_Size_Cb.
#define CMAID_VALUE_COPY_CB(func)   ((Cmaid_Value_Copy_Cb)(func))
 Casts a callback to Cmaid_Value_Copy_Cb.
#define CMAID_VALUE_CLONE_CB(func)   ((Cmaid_Value_Clone_Cb)(func))
 Casts a callback to Cmaid_Value_Clone_Cb.
#define CMAID_VALUE_FREE_CB(func)   ((Cmaid_Value_Free_Cb)(func))
 Casts a callback to Cmaid_Value_Free_Cb.

Typedefs

typedef int(* Cmaid_Value_Compare_Cb )(const void *v1, const void *v2)
 Type definition of the compare callback.
typedef unsigned int(* Cmaid_Value_Hash_Cb )(const void *v1, unsigned int *nbytes)
 Type definition of the hash callback.
typedef unsigned int(* Cmaid_Value_Size_Cb )(const void *v)
 Type definition of the aize callback.
typedef void(* Cmaid_Value_Copy_Cb )(void *dest, const void *src, unsigned int nbytes)
 Type definition of the copy callback.
typedef void *(* Cmaid_Value_Clone_Cb )(const void *v)
 Type definition of the clone callback.
typedef void(* Cmaid_Value_Free_Cb )(void *v)
 Type definition of the free callback.
typedef struct Cmaid_Value Cmaid_Value

Functions

EAPI unsigned int cmaid_value_pointer_hash (const void *key, unsigned int *size)
 Calculate a hash value for the given pointer.
EAPI unsigned int cmaid_value_string_hash (const void *key, unsigned int *size)
 Calculate a hash value for the given string.
EAPI int cmaid_value_pointer_compare (const void *key1, const void *key2)
 Compares the two pointer.
EAPI int cmaid_value_string_compare (const void *key1, const void *key2)
 Compares the two strings.
EAPI unsigned int cmaid_value_string_size (const void *key)
 Retrieve the size of a string.
void * cmaid_value_string_dup (const void *key)
void cmaid_value_string_free (void *key)

Variables

EAPI const Cmaid_Value cmaid_value_pointer
 The value structure for a pointer.
EAPI const Cmaid_Value cmaid_value_inline_string
 The value for inline strings.
EAPI const Cmaid_Value cmaid_value_const_string
 The value for const strings.

Detailed Description

The value structure and the related functions are describing how to treat the data added to a container. It's like a interface for the data, with the difference that it is not bundled with the data directly.

Typedef Documentation

typedef struct Cmaid_Value Cmaid_Value

Type definition of the Cmaid_Value structure


Function Documentation

EAPI int cmaid_value_pointer_compare ( const void *  key1,
const void *  key2 
)

Compares the two pointer.

Parameters:
key1 The first pointer
key2 The second pointer
Returns:
0 if both are equal, < 0 if key1 is smaller then key2 else > 0 This function returns a negative value if key1 is smaller then key2, if both are equal zero will be returned, else a positive number.

EAPI unsigned int cmaid_value_pointer_hash ( const void *  key,
unsigned int *  size 
)

Calculate a hash value for the given pointer.

Parameters:
key The value to generate a hash value for it
size A pointer to store the size of the data in This functions calculates the hash value of a pointer and stores 0 in size.

EAPI int cmaid_value_string_compare ( const void *  key1,
const void *  key2 
)

Compares the two strings.

Parameters:
key1 The first string
key2 The second string
Returns:
0 if both are equal, < 0 if key1 is smaller then key2 else > 0 This function returns a negative value if key1 is smaller then key2, if both are equal zero will be returned, else a positive number.

EAPI unsigned int cmaid_value_string_hash ( const void *  key,
unsigned int *  len 
)

Calculate a hash value for the given string.

Parameters:
key the string to generate a hash value for
len the place to store the length (including the '\0') This functions calculates the hash value of a string and stores the length, including the terminating NUL, in size.

EAPI unsigned int cmaid_value_string_size ( const void *  key  ) 

Retrieve the size of a string.

Parameters:
key The string to get the size
Returns:
Returns the size needed to store the string Unlike strlen() this function is returning the length needed to store a string, i.e. the length plus 1 for the NUL-termination.


Variable Documentation

The value for const strings.

This value can be used for strings. the string will not be saved nor freed, anywhere, thus the strings need to be const or at least valid for the time they are used in cmaid.

The value for inline strings.

This value can be used for strings the string will be saved inside of the node memory and thus will only need one allocation.

The value structure for a pointer.

This value can be used for simple pointers, the data of the pointer doesn't matter. It will not touch it.


Generated on Wed Aug 5 00:20:50 2009 for Cmaid by  doxygen 1.5.8