#ifndef	V_HASH_H
#define	V_HASH_H

/*
 * Value types
 */
typedef enum
{
	hash_type_int,
	hash_type_real,
	hash_type_string,
	hash_type_binary,
	/*
	 * FIXME: pointers and callbacks can't be saved in file
	 */
	hash_type_pointer,
	hash_type_callback,
	hash_type_max
}	hash_type_t;

#ifdef __cplusplus
extern "C" {
#endif	/* __cplusplus */
	vhandle_t	V_GLOBAL	hashCreateEx(u32_t hashsize);
	vhandle_t	V_GLOBAL	hashCreate(void);
	
	/*
	 * All hashSetXXX() functions make a copy of both value _and_ key string.
	 */
	vboolean	V_GLOBAL	hashSetInt(vhandle_t handle,char *key,s32_t value);
	vboolean	V_GLOBAL	hashSetPointer(vhandle_t handle,char *key,void_p value);
	vboolean	V_GLOBAL	hashSetReal(vhandle_t handle,char *key,vec_t value);
	vboolean	V_GLOBAL	hashSetString(vhandle_t handle,char *key,char *value);
	vboolean	V_GLOBAL	hashSetBinary(vhandle_t handle,char *key,void *value,u32_t len);
	vboolean	V_GLOBAL	hashSetCallback(vhandle_t handle,char *key,void (V_CALL *callback)(void *arg));
	
	vboolean	V_GLOBAL	hashGetKeyType(vhandle_t handle,char *key,hash_type_t *type_ret);
	
	vboolean	V_GLOBAL	hashRemoveKey(vhandle_t handle,char *key);
	
	vboolean	V_GLOBAL	hashGetString(vhandle_t handle,char *key,char *dest,u32_t dest_len);
	char_p		V_GLOBAL	hashStringForKey(vhandle_t handle,char *key,char *def);
	vboolean	V_GLOBAL	hashGetInt(vhandle_t handle,char *key,s32_t *dest);
	s32_t		V_GLOBAL	hashIntForKey(vhandle_t handle,char *key,s32_t def);
	vboolean	V_GLOBAL	hashGetPointer(vhandle_t handle,char *key,void_p *dest);
	void_p		V_GLOBAL	hashPointerForKey(vhandle_t handle,char *key,void_p def);
	vboolean	V_GLOBAL	hashGetReal(vhandle_t handle,char *key,vec_t *dest);
	vec_t		V_GLOBAL	hashRealForKey(vhandle_t handle,char *key,vec_t def);
	
	void_p		V_GLOBAL	hashBinaryForKey(vhandle_t handle,char *key,void_p def,u32_t *len_ret);
	vboolean	V_GLOBAL	hashCall(vhandle_t handle,char *key,void *arg);
	void		V_GLOBAL	hashDestroy(vhandle_t handle);
	vboolean	V_GLOBAL	hashSaveToStream(vhandle_t handle,vhandle_t outstream);
	vboolean	V_GLOBAL	hashSave(vhandle_t handle,char *filename);
	vboolean	V_GLOBAL	hashLoadFromStream(vhandle_t dest_map,vhandle_t stream);
	vhandle_t	V_GLOBAL	hashLoad(char *filename);
#ifdef __cplusplus
}
#endif	/* __cplusplus */

#endif	/* V_HASH_H */
