The map class structure.
It inherits from SContainer so that it supports different map implementations.
Protected Attributes
- SContainerClass _inherit
Inherit from SContainerClass.
- const SObject *(*const val_get)(const SMap *self, const char *key, s_erc *error)
ValGet function pointer.
Get the SObject of the named key.
Parameters:
- self –
The key-value map.
- key –
The string key of the object to get.
- error –
Error code.
Return: - void(*const val_set)(SMap *self, const char *key, const SObject *val, s_erc *error)
ValSet function pointer.
Set the value of the named key as an SObject. If the named key already exists then it’s SObject will be deleted (if not referenced) and replaced.
Parameters:
- self –
The key-value map.
- key –
The string key of the object to set.
- object –
Pointer to the SObject of the named key.
- error –
Error code.
- void(*const val_delete)(SMap *self, const char *key, s_erc *error)
ValDelete function pointer.
Delete named key-value pair from the map. Key is removed (freed) from list and value deleted if it doesn’t have any references.
Parameters:
- self –
The key-value map.
- key –
The string key of the object to delete.
- error –
Error code.
- SObject *(*const val_unlink)(SMap *self, const char *key, s_erc *error)
ValUnlink function pointer.
Remove named key-value pair from the map. Key is removed (freed) from list and value object is returned.
Parameters:
- self –
The key-value map.
- key –
The string key of the object to unlink.
- error –
Error code.
Return: SObject of named key.
- s_bool (*const val_present)(const SMap *self, const char *key, s_erc *error)
ValPresent function pointer.
Query the presence of a named key-value pair in the map.
Parameters:
- self –
The key-value map.
- key –
The string key of the object’s presence to query.
- error –
Error code.
Return: - SList *(*const val_keys)(const SMap *self, s_erc *error)
ValKeys function pointer.
Get a list of the keys in the map container.
Parameters:
- self –
The key-value map.
- error –
Error code.
Return: SList of keys in container, or NULL if the container is empty. The list objects (keys) are string objects and are accessed with SObjectGetString.
Note: The caller is responsible for the memory of the returned SList object.
- size_t(*const size)(const SMap *self, s_erc *error)
Size function pointer.
Get the number of key-value pairs in the map.
Parameters:
- self –
The key-value map.
- error –
Error code.
Return: The number of key-value pairs in the map.
- SMap *(*const copy)(SMap *dst, const SMap *src, s_erc *error)
Copy (shallow) function pointer.
Copy the key-value pairs from src to dst. If dst does not exist a new one will be created.
Parameters:
- dst –
Pointer to destination key-value map.
- src –
Pointer to source key-value map.
- error –
Error code.
Return: Pointer to destination key-value map.
Note: Values in dst with the same named keys as in src will be overwritten with the values in src.