Set of functions for working with an associative array type data structure. Values can be stored and retrieved using strings as the index into the data structure instead of numbers. The hash data structure provided in this file allows you to store values into fields of a table. The 'hash_put' function takes the name of the table, a field name in the table, and the value to be stored in the table. The 'hash_get' function retrieves a value from the table given the table and field name.
To store a value into a field of a table, use hash_put: hash_put "myTable" "aField" "theValue" The value stored in the table can be retrieved with hash_get: hash_get "myTable" "aField" In this example, the hash_get function would echo "theValue". hash_get_ref can also be used here and has the benefit of being forkless.
IMPLEMENTATION NOTE
Copyright 2002 by the Source Mage Team
Private
Given a table and field name, bulds the name of the variable into which a value will be stored. Also changes '+', '-', and '.' in the table name into text since bash doesn't like variable names with those characters.
Private
most likely reverses hash_build_field_name
Saves the value in the specified table/field.
Value stored in table/field
Echos the value stored in the table/field. If no value was previously stored in the table/field, this function echos an empty string.
none
Returns the value stored in the table/field through the upvar variable name. If no value was previously stored in the table/field, then an empty string is returned.
Appends the value to the specified table/field.
'export' all the values in the table. This is useful for getting hash table data from cast's pass_one/two into pass_three/pass_four which are run through make. Essentially exporting lets us pass the variables through make.
Unsets field. Deletes value.
The reverse of hash_append, it removes an item from the field's value.
Unsets all fields in a table.
table data
Outputs the entire table data, with fields separated by the optional delimiter. If no delimiter is give, n will be used.
Fields in table
Outputs all of the fields in the table , with fields separated by the optional delimiter. If no delimiter is give, n wil be used.
Print the table in some reasonably readable form
As the name would imply, this is mainly for development use and is not intended for regular use.