sl@0: /* Copyright (c) 2009 The Khronos Group Inc. sl@0: * sl@0: * Permission is hereby granted, free of charge, to any person obtaining a sl@0: * copy of this software and/or associated documentation files (the sl@0: * "Materials"), to deal in the Materials without restriction, including sl@0: * without limitation the rights to use, copy, modify, merge, publish, sl@0: * distribute, sublicense, and/or sell copies of the Materials, and to sl@0: * permit persons to whom the Materials are furnished to do so, subject to sl@0: * the following conditions: sl@0: * sl@0: * The above copyright notice and this permission notice shall be included sl@0: * in all copies or substantial portions of the Materials. sl@0: * sl@0: * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, sl@0: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF sl@0: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. sl@0: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY sl@0: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, sl@0: * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE sl@0: * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. sl@0: */ sl@0: #ifndef OWFARRAY_H_ sl@0: #define OWFARRAY_H_ sl@0: sl@0: #include "owftypes.h" sl@0: sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" sl@0: { sl@0: #endif sl@0: sl@0: sl@0: typedef void* OWF_ARRAY_ITEM; sl@0: sl@0: typedef struct { sl@0: OWF_ARRAY_ITEM* items; sl@0: OWFint capacity; sl@0: OWFint length; sl@0: } OWF_ARRAY; sl@0: sl@0: /*! sl@0: * Initialize array object sl@0: * sl@0: * \param array Array object sl@0: */ sl@0: OWF_API_CALL void sl@0: OWF_Array_Initialize(OWF_ARRAY* array); sl@0: sl@0: /*! sl@0: * Reset array. Frees resources allocated by the array. sl@0: * Doesn't destroy the actual contents (managed sl@0: * by the array user). The array can be safely reused afterwards. sl@0: * sl@0: * \param array Array object sl@0: */ sl@0: OWF_API_CALL void sl@0: OWF_Array_Reset(OWF_ARRAY* array); sl@0: sl@0: /*! sl@0: * Destroy array. Free all resources allocated sl@0: * by the array. sl@0: * sl@0: * \param array Array object sl@0: */ sl@0: OWF_API_CALL void sl@0: OWF_Array_Destroy(OWF_ARRAY* array); sl@0: sl@0: /*! sl@0: * Append item to array sl@0: * sl@0: * \param array Array object sl@0: * \param item Item to add sl@0: * sl@0: * \return OWF_TRUE if the operation succeeded, OWF_FALSE otherwise sl@0: */ sl@0: OWF_API_CALL OWFboolean sl@0: OWF_Array_AppendItem(OWF_ARRAY* array, sl@0: OWF_ARRAY_ITEM item); sl@0: sl@0: /*! sl@0: * Insert item into the array sl@0: * sl@0: * \param array Array object sl@0: * \param position Where the item should be inserted at sl@0: * \param item Item to insert sl@0: * sl@0: * \return OWF_TRUE if the operation succeeded, OWF_FALSE otherwise sl@0: */ sl@0: OWF_API_CALL OWFboolean sl@0: OWF_Array_InsertItem(OWF_ARRAY* array, sl@0: OWFint position, sl@0: OWF_ARRAY_ITEM item); sl@0: sl@0: /*! sl@0: * Remove item (by value) from the array sl@0: * sl@0: * \param array Array object sl@0: * \param item Item to remove sl@0: * sl@0: * \return Removed item or NULL if the item is invalid. sl@0: * sl@0: */ sl@0: OWF_API_CALL OWF_ARRAY_ITEM sl@0: OWF_Array_RemoveItem(OWF_ARRAY* array, sl@0: OWF_ARRAY_ITEM item); sl@0: sl@0: /*! sl@0: * Remove item (by index) from the array sl@0: * sl@0: * \param array Array object sl@0: * \param position Index of the item to remove sl@0: * sl@0: * \return Removed item or NULL if the index is out of bounds. sl@0: */ sl@0: OWF_API_CALL OWF_ARRAY_ITEM sl@0: OWF_Array_RemoveItemAt(OWF_ARRAY* array, sl@0: OWFint position); sl@0: sl@0: /*! sl@0: * Get item from array sl@0: * sl@0: * \param array Array object sl@0: * \param position Index of the item to fetch (0..array.length-1) sl@0: * sl@0: * \return Item or NULL, if the position argument is out of bounds. sl@0: * sl@0: */ sl@0: OWF_API_CALL OWF_ARRAY_ITEM sl@0: OWF_Array_GetItemAt(OWF_ARRAY* array, sl@0: OWFint position); sl@0: sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: sl@0: #endif