added userdata to hastable to be able to do stuff in the iterator function callback
This commit is contained in:
parent
d79f9bb2ec
commit
7316f7c779
5 changed files with 80 additions and 25 deletions
|
|
@ -39,16 +39,6 @@ extern "C" {
|
|||
<whitespace> -> SPACE <whitespace> | TAB <whitespace> | NEWLINE <whitespace> | LAMBDA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief TODO: write this
|
||||
*/
|
||||
typedef void (* ARC_ChemicalData_CopyToTypeFn)(void **data, ARC_ParserTagToken *parsedData);
|
||||
|
||||
/**
|
||||
* @brief TODO: write this
|
||||
*/
|
||||
typedef void (* ARC_ParserCSV_DestroyTypeFn)(void *data);
|
||||
|
||||
/**
|
||||
* @brief a function to read a key from string to a ARC_ConfigTypeTemplate
|
||||
*
|
||||
|
|
@ -79,6 +69,24 @@ typedef void (* ARC_ParserCSV_DestroyTypeFn)(void *data);
|
|||
*/
|
||||
typedef struct ARC_Chemical ARC_Chemical;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
typedef void (* ARC_ChemicalType_CopyFn)(void **type, ARC_ParserTagToken *parsedData, ARC_Chemical *chemical);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
typedef void (* ARC_ChemicalType_DestroyFn)(void *type);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
typedef struct ARC_ChemicalType {
|
||||
ARC_ChemicalType_CopyFn copyFn;
|
||||
ARC_ChemicalType_DestroyFn destroyFn;
|
||||
} ARC_ChemicalType;
|
||||
|
||||
/**
|
||||
* @brief TODO: write this
|
||||
*/
|
||||
|
|
@ -92,7 +100,12 @@ void ARC_Chemical_Destroy(ARC_Chemical *chemical);
|
|||
/**
|
||||
* @brief TODO: write this
|
||||
*/
|
||||
void ARC_Chemical_RegisterType(ARC_Chemical *chemical, ARC_String *typeName, ARC_ChemicalData_CopyToTypeFn *copyToTypeFn, ARC_ParserCSV_DestroyTypeFn destroyTypeFn);
|
||||
void ARC_Chemical_RegisterType(ARC_Chemical *chemical, ARC_String *typeName, ARC_ChemicalType type);
|
||||
|
||||
/**
|
||||
* @brief TODO: write this
|
||||
*/
|
||||
void ARC_Chemical_RegisterTypeWithCStr(ARC_Chemical *chemical, const char *typeNameCStr, ARC_ChemicalType type);
|
||||
|
||||
/**
|
||||
* @brief sets current group in config
|
||||
|
|
|
|||
|
|
@ -38,10 +38,11 @@ typedef void (* ARC_Hashtable_DestroyKeyValueFn)(void *key, void *value);
|
|||
/**
|
||||
* @brief a callback to be used by ARC_Hashtable_RunIteration
|
||||
*
|
||||
* @param[in] key a key at the current iteration
|
||||
* @param[in] value a value that matches the key at the current iteration
|
||||
* @param[in] key a key at the current iteration
|
||||
* @param[in] value a value that matches the key at the current iteration
|
||||
* @param[in] userData any data passed into the function that uses this callback to be used in this callback
|
||||
*/
|
||||
typedef void (* ARC_Hashtable_IteratorFn)(void *key, void *value);
|
||||
typedef void (* ARC_Hashtable_IteratorFn)(void *key, void *value, void *userData);
|
||||
|
||||
/**
|
||||
* @brief a resizable hashtable data type (will find next open slot before resizing)
|
||||
|
|
@ -109,8 +110,9 @@ void *ARC_Hashtable_Get(ARC_Hashtable *hashtable, void *key);
|
|||
*
|
||||
* @param[in] hashtable the hashtable to iterate through
|
||||
* @param[in] iteratorFn the callback which will can use the iterated key value pairs
|
||||
* @patam[in] userData anything to be used within the ARC_Hashtable_IteratorFn callback, can be NULL
|
||||
*/
|
||||
void ARC_Hashtable_RunIteration(ARC_Hashtable *hashtable, ARC_Hashtable_IteratorFn iteratorFn);
|
||||
void ARC_Hashtable_RunIteration(ARC_Hashtable *hashtable, ARC_Hashtable_IteratorFn iteratorFn, void *userData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue