|  |  |  | Redland RDF Library Manual |  | 
|---|---|---|---|---|
| Top | Description | ||||
typedef librdf_hash; typedef librdf_hash_cursor; librdf_hash * librdf_new_hash (librdf_world *world,const char *name); librdf_hash * librdf_new_hash_from_string (librdf_world *world,const char *name,const char *string); librdf_hash * librdf_new_hash_from_array_of_strings (librdf_world *world,const char *name,const char **array); librdf_hash * librdf_new_hash_from_hash (librdf_hash *old_hash); void librdf_free_hash (librdf_hash *hash); char * librdf_hash_get (librdf_hash *hash,const char *key); int librdf_hash_get_as_boolean (librdf_hash *hash,const char *key); long librdf_hash_get_as_long (librdf_hash *hash,const char *key); char * librdf_hash_get_del (librdf_hash *hash,const char *key); int librdf_hash_put_strings (librdf_hash *hash,const char *key,const char *value); void librdf_hash_print (librdf_hash *hash,FILE *fh); void librdf_hash_print_keys (librdf_hash *hash,FILE *fh); void librdf_hash_print_values (librdf_hash *hash,const char *key_string,FILE *fh); unsigned char * librdf_hash_interpret_template (const unsigned char *template_string,librdf_hash *dictionary,const unsigned char *prefix,const unsigned char *suffix); int librdf_hash_from_string (librdf_hash *hash,const char *string); char * librdf_hash_to_string (librdf_hash *hash,const char *filter[]);
Interface to implementations of key:value hashes either in memory, on disk and with persistence. Keys may have multiple and duplicate values.
typedef struct librdf_hash_cursor_s librdf_hash_cursor;
Redland hash cursor class.
librdf_hash * librdf_new_hash (librdf_world *world,const char *name);
Constructor - create a new librdf_hash object.
| 
 | redland world object | 
| 
 | factory name | 
| Returns : | a new librdf_hash object or NULL on failure | 
librdf_hash * librdf_new_hash_from_string (librdf_world *world,const char *name,const char *string);
Constructor - create a new librdf_hash object from a string.
See librdf_hash_from_string for the string format.
| 
 | redland world object | 
| 
 | hash name | 
| 
 | hash encoded as a string | 
| Returns : | a new librdf_hash object or NULL on failure | 
librdf_hash * librdf_new_hash_from_array_of_strings (librdf_world *world,const char *name,const char **array);
Constructor - create a new librdf_hash object from an array of strings.
| 
 | redland world object | 
| 
 | hash name | 
| 
 | address of the start of the array of char* pointers | 
| Returns : | a new librdf_hash object or NULL on failure | 
librdf_hash *       librdf_new_hash_from_hash           (librdf_hash *old_hash);
Copy Constructor - create a new librdf_hash object from an existing one.
| 
 | the hash to use to construct the hash | 
| Returns : | a new librdf_hash object or NULL on failure | 
void                librdf_free_hash                    (librdf_hash *hash);
Destructor - destroy a librdf_hash object.
| 
 | hash object | 
char * librdf_hash_get (librdf_hash *hash,const char *key);
Retrieve one value from hash for a given key as string.
The value returned is from newly allocated memory which the caller must free.
| 
 | hash object | 
| 
 | pointer to key | 
| Returns : | the value or NULL on failure | 
int librdf_hash_get_as_boolean (librdf_hash *hash,const char *key);
Lookup a hash key and decode value as a boolean.
False values: "no", "false" True values: "yes", "true"
| 
 | librdf_hash object | 
| 
 | key string to look up | 
| Returns : | >0 (for true), 0 (for false) or <0 (for key not found or not known boolean value) | 
long librdf_hash_get_as_long (librdf_hash *hash,const char *key);
Lookup a hash key and decode value as a long.
| 
 | librdf_hash object | 
| 
 | key string to look up | 
| Returns : | >0 (for success), <0 (for key not found or not known boolean value) | 
char * librdf_hash_get_del (librdf_hash *hash,const char *key);
Retrieve one value from hash for a given key as string and remove all values with that key.
The value returned is from newly allocated memory which the caller must free.
| 
 | hash object | 
| 
 | pointer to key | 
| Returns : | the value or NULL on failure | 
int librdf_hash_put_strings (librdf_hash *hash,const char *key,const char *value);
Insert key/value pairs into the hash as strings.
The key and values are copied into the hash, no sharing i s done.
| 
 | hash object | 
| 
 | key | 
| 
 | value | 
| Returns : | non 0 on failure | 
void librdf_hash_print (librdf_hash *hash,FILE *fh);
Pretty print the hash to a file descriptor.
| 
 | the hash | 
| 
 | file handle | 
void librdf_hash_print_keys (librdf_hash *hash,FILE *fh);
Pretty print the keys to a file descriptor.
| 
 | the hash | 
| 
 | file handle | 
void librdf_hash_print_values (librdf_hash *hash,const char *key_string,FILE *fh);
Pretty print the values of one key to a file descriptor.
| 
 | the hash | 
| 
 | the key as a string | 
| 
 | file handle | 
unsigned char * librdf_hash_interpret_template (const unsigned char *template_string,librdf_hash *dictionary,const unsigned char *prefix,const unsigned char *suffix);
Interpret keys in a template string to their value in a dictionary.
Can be used to do variable substitution for a string where
the syntax that marks the variable is defined by the prefix
and suffix strings, and the variables are stored in the dictionary
hash table.
| 
 | template string to interprate | 
| 
 | dictionary of key/values to substitute | 
| 
 | prefix to mark a key in the template | 
| 
 | suffix to mark a key in the template | 
| Returns : | Newly allocated string, or NULL on failure | 
int librdf_hash_from_string (librdf_hash *hash,const char *string);
Initialise a hash from a string.
The string format is something like: key1='value1',key2='value2', key3='\'quoted value\''
The 's are required and whitespace can appear around the = and ,s
| 
 | hash object | 
| 
 | hash encoded as a string | 
| Returns : | non 0 on failure | 
char * librdf_hash_to_string (librdf_hash *hash,const char *filter[]);
Format the hash as a string, suitable for parsing by librdf_hash_from_string.
Note: this method allocates a new string since this is a _to_ method
and the caller must call librdf_free_memory() to free the resulting memory.
| 
 | librdf_hash object | 
| 
 | NULL terminated list of keys to ignore | 
| Returns : | string representation of the hash or NULL on failure |