/** * Copyright (c) 2021 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "../libs.h" /** * Retrieve the index of a given key from a dictionary. * * @param keys Array of strings. * @param name Key to search for. * @param count How long the array is. * @return The index of the key within the dictionary (or -1 if not found). */ int32_t dictionaryGetIndex(char **keys, char *name, int32_t *count); /** * Retrieves or adds a key to the dictionary. Note that we take in the count as * a pointer to an integer because this will automatically be incremented if the * dictionary does not contain the string. * * @param keys Array of strings. * @param name Key to add/get. * @param count Pointer to an int32 that contains the count of items. * @param stride How many elements between each key within the char buffer. * @param buffer Char buffer where the key will be copied. * @return The index where the item was added. */ int32_t dictionaryGetOrAdd( char **keys, char *name, int32_t *count, int32_t stride, char *buffer ); /** * Removes a key from the dictionary. * * @param keys Array of strings. * @param i Index to remove. */ void dictionaryRemoveByIndex(char **keys, int32_t i); /** * Remove an item from the dictionary by its key. * * @param keys Array of strings. * @param name Key to remove. * @param count Count of items within the dictionary. */ void dictionaryRemove(char **keys, char *name, int32_t count);