From b0a2b8bb15780f413549d25440d2f5d5e679bae1 Mon Sep 17 00:00:00 2001 From: herbglitch Date: Sat, 19 Aug 2023 23:07:15 +0000 Subject: [PATCH] moved some functions from graphics config to a new math config --- CMakeLists.txt | 1 + include/arc/math/config.h | 26 ++++ src/graphics/sdl/config.c | 290 +++----------------------------------- src/math/config.c | 274 +++++++++++++++++++++++++++++++++++ src/std/string.c | 1 - 5 files changed, 320 insertions(+), 272 deletions(-) create mode 100644 include/arc/math/config.h create mode 100644 src/math/config.c diff --git a/CMakeLists.txt b/CMakeLists.txt index adb1808..f1c6eab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,7 @@ set(ARCHEUS_STD_SOURCES src/std/defaults/config.c src/math/circle.c + src/math/config.c src/math/obround.c src/math/rectangle.c src/math/vector2.c diff --git a/include/arc/math/config.h b/include/arc/math/config.h new file mode 100644 index 0000000..c44eaad --- /dev/null +++ b/include/arc/math/config.h @@ -0,0 +1,26 @@ +#ifndef ARC_MATH_CONFIG_H_ +#define ARC_MATH_CONFIG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "arc/std/string.h" + +typedef struct ARC_Config ARC_Config; +void ARC_MathConfig_Init(ARC_Config *config); + +uint8_t ARC_Point_Read (ARC_Config *config, ARC_String *string, void **value); +uint8_t ARC_Rect_Read (ARC_Config *config, ARC_String *string, void **value); +uint8_t ARC_RectArray_Read(ARC_Config *config, ARC_String *string, void **value); + +void ARC_Point_Delete (ARC_Config *config, ARC_String *string, void *value); +void ARC_Rect_Delete (ARC_Config *config, ARC_String *string, void *value); +void ARC_RectArray_Delete(ARC_Config *config, ARC_String *string, void *value); + +#ifdef __cplusplus +} +#endif + +#endif //ARC_MATH_CONFIG_H_ \ No newline at end of file diff --git a/src/graphics/sdl/config.c b/src/graphics/sdl/config.c index 044da82..22c8f0f 100644 --- a/src/graphics/sdl/config.c +++ b/src/graphics/sdl/config.c @@ -11,6 +11,7 @@ #include "arc/graphics/sdl/sprite.h" #include "arc/graphics/spritesheet.h" #include "arc/graphics/sdl/spritesheet.h" +#include "arc/math/config.h" #include "arc/math/point.h" #include "arc/math/rectangle.h" @@ -19,30 +20,31 @@ SDL_Renderer *global_renderer; -uint8_t ARC_Point_Read (ARC_Config *config, ARC_String *string, void **value); -uint8_t ARC_Rect_Read (ARC_Config *config, ARC_String *string, void **value); -uint8_t ARC_RectArray_Read (ARC_Config *config, ARC_String *string, void **value); uint8_t ARC_SDL_Texture_Read(ARC_Config *config, ARC_String *string, void **value); uint8_t ARC_Spritesheet_Read(ARC_Config *config, ARC_String *string, void **value); uint8_t ARC_Sprite_Read (ARC_Config *config, ARC_String *string, void **value); -void ARC_Point_Delete (ARC_Config *config, ARC_String *string, void *value); -void ARC_Rect_Delete (ARC_Config *config, ARC_String *string, void *value); -void ARC_RectArray_Delete (ARC_Config *config, ARC_String *string, void *value); void ARC_SDL_Texture_Delete(ARC_Config *config, ARC_String *string, void *value); void ARC_Spritesheet_Delete(ARC_Config *config, ARC_String *string, void *value); void ARC_Sprite_Delete (ARC_Config *config, ARC_String *string, void *value); void ARC_GraphicsConfig_Init(ARC_Config *config, ARC_Renderer *renderer){ global_renderer = (SDL_Renderer *)renderer; - ARC_Config_AddKeyCString(config, (char *)"ARC_Point" , 9, ARC_Point_Read , ARC_Point_Delete ); - ARC_Config_AddKeyCString(config, (char *)"ARC_Rect" , 8, ARC_Rect_Read , ARC_Rect_Delete ); - ARC_Config_AddKeyCString(config, (char *)"ARC_Rect[]" , 10, ARC_RectArray_Read , ARC_RectArray_Delete ); ARC_Config_AddKeyCString(config, (char *)"SDL_Texture" , 11, ARC_SDL_Texture_Read, ARC_SDL_Texture_Delete); ARC_Config_AddKeyCString(config, (char *)"ARC_Spritesheet", 15, ARC_Spritesheet_Read, ARC_Spritesheet_Delete); ARC_Config_AddKeyCString(config, (char *)"ARC_Sprite" , 10, ARC_Sprite_Read , ARC_Sprite_Delete ); } +uint64_t ARC_GraphicsConfig_GetIndexAndErrorCheck(ARC_String *string, char *search, uint64_t searchLength){ + uint64_t separator = ARC_String_FindCString(string, ",", 1); + + if(separator == ~(uint64_t)0){ + arc_errno = ARC_ERRNO_DATA; + } + + return separator; +} + int32_t ARC_SDL_Texture_Load(const char *path, SDL_Texture **texture){ IMG_Init(IMG_INIT_PNG); SDL_Surface *surface = IMG_Load(path); @@ -59,251 +61,6 @@ int32_t ARC_SDL_Texture_Load(const char *path, SDL_Texture **texture){ return 0; } -uint64_t getIndexAndErrorCheck(ARC_String *string, char *search, uint64_t searchLength){ - uint64_t separator = ARC_String_FindCString(string, ",", 1); - - if(separator == ~(uint64_t)0){ - arc_errno = ARC_ERRNO_DATA; - } - - return separator; -} - -uint8_t ARC_Point_Read(ARC_Config *config, ARC_String *string, void **value){ - ARC_Config_Get(config, string, value); - if(*value){ - return 1; - } - - if(string->data[0] != '{' || string->data[string->length - 1] != '}'){ - ARC_DEBUG_LOG(arc_errno, "in ARC_Point_Read(config, string, value); no matching curly braces: %s", string->data); - arc_errno = ARC_ERRNO_DATA; - return 0; - } - - uint64_t separator = getIndexAndErrorCheck(string, ",", 1); - if(arc_errno){ - return 0; - } - - ARC_String *xString, *yString; - ARC_String_CopySubstring(&xString, string, 1 , separator - 1 ); - ARC_String_CopySubstring(&yString, string, separator + 1, string->length - (separator + 2)); - - SDL_Point *point = (SDL_Point *)malloc(sizeof(SDL_Point)); - point->x = (int32_t)ARC_String_ToInt64_t(xString); - point->y = (int32_t)ARC_String_ToInt64_t(yString); - - ARC_String_Destroy(xString); - ARC_String_Destroy(yString); - - *value = point; - return 0; -} - -uint8_t ARC_Rect_Read(ARC_Config *config, ARC_String *string, void **value){ - ARC_Config_Get(config, string, value); - if(*value){ - return 1; - } - - if(string->data[0] != '{' || string->data[string->length - 1] != '}'){ - arc_errno = ARC_ERRNO_DATA; - ARC_DEBUG_LOG(arc_errno, "in ARC_Rect_Read(config, string, value); no matching curly braces: %s", string->data); - return 0; - } - - ARC_String *current; - ARC_String_CopySubstring(¤t, string, 1, string->length - 2); - - ARC_String *temp, *tempStripped; - int32_t x, y, w, h; - int64_t separator; - - //x - separator = getIndexAndErrorCheck(current, ",", 1); - if(arc_errno){ - return 0; - } - - ARC_String_CopySubstring(&temp, current, 0, separator - 1); - ARC_String_StripEndsWhitespace(temp, &tempStripped); - x = ARC_String_ToInt64_t(tempStripped); - ARC_String_Destroy(temp); - ARC_String_Destroy(tempStripped); - - temp = current; - ARC_String_CopySubstring(¤t, temp, separator + 1, temp->length - (separator + 1)); - ARC_String_Destroy(temp); - - //y - separator = getIndexAndErrorCheck(current, ",", 1); - if(arc_errno){ - return 0; - } - - ARC_String_CopySubstring(&temp, current, 0, separator - 1); - ARC_String_StripEndsWhitespace(temp, &tempStripped); - y = ARC_String_ToInt64_t(tempStripped); - ARC_String_Destroy(temp); - ARC_String_Destroy(tempStripped); - - temp = current; - ARC_String_CopySubstring(¤t, temp, separator + 1, temp->length - (separator + 1)); - ARC_String_Destroy(temp); - - //w - separator = getIndexAndErrorCheck(current, ",", 1); - if(arc_errno){ - return 0; - } - - ARC_String_CopySubstring(&temp, current, 0, separator - 1); - ARC_String_StripEndsWhitespace(temp, &tempStripped); - w = ARC_String_ToInt64_t(tempStripped); - ARC_String_Destroy(temp); - ARC_String_Destroy(tempStripped); - - temp = current; - ARC_String_CopySubstring(¤t, temp, separator + 1, temp->length - (separator + 1)); - ARC_String_Destroy(temp); - - //h - separator = current->length; - if(arc_errno){ - return 0; - } - - ARC_String_CopySubstring(&temp, current, 0, separator); - ARC_String_StripEndsWhitespace(temp, &tempStripped); - h = ARC_String_ToInt64_t(tempStripped); - ARC_String_Destroy(temp); - ARC_String_Destroy(tempStripped); - ARC_String_Destroy(current); - - *value = malloc(sizeof(ARC_Rect)); - ((ARC_Rect *) *value)->x = x; - ((ARC_Rect *) *value)->y = y; - ((ARC_Rect *) *value)->w = w; - ((ARC_Rect *) *value)->h = h; - return 0; -} - -void ARC_RectArray_ReadRect(ARC_Config* config, ARC_String *stripped, uint64_t index, uint64_t length, uint64_t *arrayIndex, void **value){ - ARC_String *substr, *temp; - ARC_String_CopySubstring(&temp, stripped, index, length); - ARC_String_StripEndsWhitespace(temp, &substr); - ARC_String_Destroy(temp); - - // reading in reference - ARC_Rect *tempRect; - ARC_Config_Get(config, substr, (void **) &tempRect); - if(tempRect){ - ARC_String_Destroy(substr); - - ((ARC_Rect *)((ARC_Array *) *value)->data)[*arrayIndex] = *tempRect; - ++*arrayIndex; - - return; - } - - //reading in value - ARC_Rect_Read(config, substr, (void **) &tempRect); - if(arc_errno){ - ARC_DEBUG_LOG(arc_errno, "in ARC_RectArray_ReadRect(config, string, index, length, arrayIndex, value); failed to read rect: %s", substr->data); - ARC_String_Destroy(substr); - return; - } - - ((ARC_Rect *)((ARC_Array *) *value)->data)[*arrayIndex] = *tempRect; - ++*arrayIndex; - - ARC_Rect_Delete(config, substr, (void *)tempRect); - ARC_String_Destroy(substr); -} - -uint8_t ARC_RectArray_Read(ARC_Config* config, ARC_String *string, void **value){ - ARC_Config_Get(config, string, value); - if(*value){ - return 1; - } - - if(string->data[0] != '{' || string->data[string->length - 1] != '}'){ - arc_errno = ARC_ERRNO_DATA; - ARC_DEBUG_LOG(arc_errno, "in ARC_RectArray_Read(config, string, value); no matching curly braces: %s", string->data); - return 0; - } - - ARC_String *temp, *stripped; - ARC_String_CopySubstring(&temp, string, 1, string->length - 2); - ARC_String_StripEndsWhitespace(temp, &stripped); - ARC_String_Destroy(temp); - - uint64_t arraySize = 1; - int64_t encapsulated = 0; - for(uint64_t i = 0; i < stripped->length; i++){ - if(stripped->data[i] == '{'){ - encapsulated++; - continue; - } - - if(stripped->data[i] == '}'){ - encapsulated--; - continue; - } - - if(!encapsulated && stripped->data[i] == ','){ - arraySize++; - } - } - - if(encapsulated){ - arc_errno = ARC_ERRNO_DATA; - ARC_DEBUG_LOG(arc_errno, "in ARC_RectArray_Read(config, data, subdata, value); after looping encapsulated was %ld", encapsulated); - ARC_String_Destroy(stripped); - return 0; - } - - *value = malloc(sizeof(ARC_Array)); - ((ARC_Array *) *value)->data = malloc(sizeof(ARC_Rect) * arraySize); - ((ARC_Array *) *value)->size = arraySize; - - uint64_t index = 0; - arraySize = 0; - encapsulated = 0; - for(uint64_t i = 0; i < stripped->length; i++){ - if(stripped->data[i] == '{'){ - encapsulated++; - continue; - } - - if(stripped->data[i] == '}'){ - encapsulated--; - continue; - } - - if(!encapsulated && stripped->data[i] == ','){ - ARC_RectArray_ReadRect(config, stripped, index, i - index, &arraySize, value); - if(arc_errno){ - return 0; - } - - index = i + 1; - - if(arraySize == ((ARC_Array *) *value)->size){ - break; - } - } - } - - if(arraySize != ((ARC_Array *) *value)->size){ - ARC_RectArray_ReadRect(config, stripped, index, stripped->length - index, &arraySize, value); - } - ARC_String_Destroy(stripped); - return 0; -} - - uint8_t ARC_SDL_Texture_Read(ARC_Config* config, ARC_String *string, void **value){ ARC_Config_Get(config, string, value); if(*value){ @@ -358,7 +115,7 @@ uint8_t ARC_Spritesheet_Read(ARC_Config* config, ARC_String *string, void **valu return 0; } - uint64_t split = getIndexAndErrorCheck(string, ",", 1); + uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1); if(arc_errno){ return 0; } @@ -402,7 +159,7 @@ uint8_t ARC_Sprite_Read(ARC_Config* config, ARC_String *string, void **value){ return 0; } - uint64_t split = getIndexAndErrorCheck(string, ",", 1); + uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1); if(arc_errno){ return 0; } @@ -466,23 +223,10 @@ uint8_t ARC_Sprite_Read(ARC_Config* config, ARC_String *string, void **value){ return 0; } -void ARC_Point_Delete(ARC_Config* config, ARC_String *string, void *value){ - free((ARC_Point *)value); -} - -void ARC_Rect_Delete(ARC_Config* config, ARC_String *string, void *value){ - free((ARC_Rect *)value); -} - -void ARC_RectArray_Delete(ARC_Config* config, ARC_String *string, void *value){ - free((ARC_Array *)value); -} - void ARC_SDL_Texture_Delete(ARC_Config* config, ARC_String *string, void *value){ SDL_DestroyTexture((SDL_Texture *) value); } - void ARC_Spritesheet_Delete(ARC_Config* config, ARC_String *string, void *value){ ARC_Spritesheet *sheetValue = (ARC_Spritesheet *)value; @@ -495,7 +239,7 @@ void ARC_Spritesheet_Delete(ARC_Config* config, ARC_String *string, void *value) return; } - uint64_t split = getIndexAndErrorCheck(string, ",", 1); + uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1); if(arc_errno){ //TODO: test to make sure no edge cases // free(sheetValue); @@ -504,6 +248,10 @@ void ARC_Spritesheet_Delete(ARC_Config* config, ARC_String *string, void *value) return; } + if(split == ~0){ + + } + //check if texture and size are references ARC_String *tempStr, *textureStr, *sizeStr; ARC_String_CopySubstring(&tempStr, string, 1, split - 1); @@ -534,7 +282,7 @@ void ARC_Sprite_Delete(ARC_Config* config, ARC_String *string, void *value){ //check if read in as a Textrue reference void *temp; - uint64_t split = getIndexAndErrorCheck(string, ",", 1); + uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1); if(arc_errno){ free(spriteValue); return; diff --git a/src/math/config.c b/src/math/config.c new file mode 100644 index 0000000..0735391 --- /dev/null +++ b/src/math/config.c @@ -0,0 +1,274 @@ +#include "arc/math/config.h" +#include +#include +#include "arc/std/array.h" +#include "arc/std/string.h" +#include "arc/std/errno.h" +#include "arc/std/config.h" +#include "arc/math/point.h" +#include "arc/math/rectangle.h" + +// #define ARC_DEFAULT_CONFIG +#include "arc/std/defaults/config.h" + +void ARC_MathConfig_Init(ARC_Config *config){ + ARC_Config_AddKeyCString(config, (char *)"ARC_Point" , 9, ARC_Point_Read , ARC_Point_Delete ); + ARC_Config_AddKeyCString(config, (char *)"ARC_Rect" , 8, ARC_Rect_Read , ARC_Rect_Delete ); + ARC_Config_AddKeyCString(config, (char *)"ARC_Rect[]" , 10, ARC_RectArray_Read , ARC_RectArray_Delete ); +} + +uint64_t ARC_MathConfig_GetIndexAndErrorCheck(ARC_String *string, char *search, uint64_t searchLength){ + uint64_t separator = ARC_String_FindCString(string, ",", 1); + + if(separator == ~(uint64_t)0){ + arc_errno = ARC_ERRNO_DATA; + } + + return separator; +} + +uint8_t ARC_Point_Read(ARC_Config *config, ARC_String *string, void **value){ + ARC_Config_Get(config, string, value); + if(*value){ + return 1; + } + + if(string->data[0] != '{' || string->data[string->length - 1] != '}'){ + ARC_DEBUG_LOG(arc_errno, "in ARC_Point_Read(config, string, value); no matching curly braces: %s", string->data); + arc_errno = ARC_ERRNO_DATA; + return 0; + } + + uint64_t separator = ARC_MathConfig_GetIndexAndErrorCheck(string, ",", 1); + if(arc_errno){ + return 0; + } + + ARC_String *xString, *yString; + ARC_String_CopySubstring(&xString, string, 1 , separator - 1 ); + ARC_String_CopySubstring(&yString, string, separator + 1, string->length - (separator + 2)); + + ARC_Point *point = (ARC_Point *)malloc(sizeof(ARC_Point)); + point->x = (int32_t)ARC_String_ToInt64_t(xString); + point->y = (int32_t)ARC_String_ToInt64_t(yString); + + ARC_String_Destroy(xString); + ARC_String_Destroy(yString); + + *value = point; + return 0; +} + +uint8_t ARC_Rect_Read(ARC_Config *config, ARC_String *string, void **value){ + ARC_Config_Get(config, string, value); + if(*value){ + return 1; + } + + if(string->data[0] != '{' || string->data[string->length - 1] != '}'){ + arc_errno = ARC_ERRNO_DATA; + ARC_DEBUG_LOG(arc_errno, "in ARC_Rect_Read(config, string, value); no matching curly braces: %s", string->data); + return 0; + } + + ARC_String *current; + ARC_String_CopySubstring(¤t, string, 1, string->length - 2); + + ARC_String *temp, *tempStripped; + int32_t x, y, w, h; + int64_t separator; + + //x + separator = ARC_MathConfig_GetIndexAndErrorCheck(current, ",", 1); + if(arc_errno){ + return 0; + } + + ARC_String_CopySubstring(&temp, current, 0, separator - 1); + ARC_String_StripEndsWhitespace(temp, &tempStripped); + x = ARC_String_ToInt64_t(tempStripped); + ARC_String_Destroy(temp); + ARC_String_Destroy(tempStripped); + + temp = current; + ARC_String_CopySubstring(¤t, temp, separator + 1, temp->length - (separator + 1)); + ARC_String_Destroy(temp); + + //y + separator = ARC_MathConfig_GetIndexAndErrorCheck(current, ",", 1); + if(arc_errno){ + return 0; + } + + ARC_String_CopySubstring(&temp, current, 0, separator - 1); + ARC_String_StripEndsWhitespace(temp, &tempStripped); + y = ARC_String_ToInt64_t(tempStripped); + ARC_String_Destroy(temp); + ARC_String_Destroy(tempStripped); + + temp = current; + ARC_String_CopySubstring(¤t, temp, separator + 1, temp->length - (separator + 1)); + ARC_String_Destroy(temp); + + //w + separator = ARC_MathConfig_GetIndexAndErrorCheck(current, ",", 1); + if(arc_errno){ + return 0; + } + + ARC_String_CopySubstring(&temp, current, 0, separator - 1); + ARC_String_StripEndsWhitespace(temp, &tempStripped); + w = ARC_String_ToInt64_t(tempStripped); + ARC_String_Destroy(temp); + ARC_String_Destroy(tempStripped); + + temp = current; + ARC_String_CopySubstring(¤t, temp, separator + 1, temp->length - (separator + 1)); + ARC_String_Destroy(temp); + + //h + separator = current->length; + if(arc_errno){ + return 0; + } + + ARC_String_CopySubstring(&temp, current, 0, separator); + ARC_String_StripEndsWhitespace(temp, &tempStripped); + h = ARC_String_ToInt64_t(tempStripped); + ARC_String_Destroy(temp); + ARC_String_Destroy(tempStripped); + ARC_String_Destroy(current); + + *value = malloc(sizeof(ARC_Rect)); + ((ARC_Rect *) *value)->x = x; + ((ARC_Rect *) *value)->y = y; + ((ARC_Rect *) *value)->w = w; + ((ARC_Rect *) *value)->h = h; + return 0; +} + +void ARC_RectArray_ReadRect(ARC_Config* config, ARC_String *stripped, uint64_t index, uint64_t length, uint64_t *arrayIndex, void **value){ + ARC_String *substr, *temp; + ARC_String_CopySubstring(&temp, stripped, index, length); + ARC_String_StripEndsWhitespace(temp, &substr); + ARC_String_Destroy(temp); + + // reading in reference + ARC_Rect *tempRect; + ARC_Config_Get(config, substr, (void **) &tempRect); + if(tempRect){ + ARC_String_Destroy(substr); + + ((ARC_Rect *)((ARC_Array *) *value)->data)[*arrayIndex] = *tempRect; + ++*arrayIndex; + + return; + } + + //reading in value + ARC_Rect_Read(config, substr, (void **) &tempRect); + if(arc_errno){ + ARC_DEBUG_LOG(arc_errno, "in ARC_RectArray_ReadRect(config, string, index, length, arrayIndex, value); failed to read rect: %s", substr->data); + ARC_String_Destroy(substr); + return; + } + + ((ARC_Rect *)((ARC_Array *) *value)->data)[*arrayIndex] = *tempRect; + ++*arrayIndex; + + ARC_Rect_Delete(config, substr, (void *)tempRect); + ARC_String_Destroy(substr); +} + +uint8_t ARC_RectArray_Read(ARC_Config* config, ARC_String *string, void **value){ + ARC_Config_Get(config, string, value); + if(*value){ + return 1; + } + + if(string->data[0] != '{' || string->data[string->length - 1] != '}'){ + arc_errno = ARC_ERRNO_DATA; + ARC_DEBUG_LOG(arc_errno, "in ARC_RectArray_Read(config, string, value); no matching curly braces: %s", string->data); + return 0; + } + + ARC_String *temp, *stripped; + ARC_String_CopySubstring(&temp, string, 1, string->length - 2); + ARC_String_StripEndsWhitespace(temp, &stripped); + ARC_String_Destroy(temp); + + uint64_t arraySize = 1; + int64_t encapsulated = 0; + for(uint64_t i = 0; i < stripped->length; i++){ + if(stripped->data[i] == '{'){ + encapsulated++; + continue; + } + + if(stripped->data[i] == '}'){ + encapsulated--; + continue; + } + + if(!encapsulated && stripped->data[i] == ','){ + arraySize++; + } + } + + if(encapsulated){ + arc_errno = ARC_ERRNO_DATA; + ARC_DEBUG_LOG(arc_errno, "in ARC_RectArray_Read(config, data, subdata, value); after looping encapsulated was %ld", encapsulated); + ARC_String_Destroy(stripped); + return 0; + } + + *value = malloc(sizeof(ARC_Array)); + ((ARC_Array *) *value)->data = malloc(sizeof(ARC_Rect) * arraySize); + ((ARC_Array *) *value)->size = arraySize; + + uint64_t index = 0; + arraySize = 0; + encapsulated = 0; + for(uint64_t i = 0; i < stripped->length; i++){ + if(stripped->data[i] == '{'){ + encapsulated++; + continue; + } + + if(stripped->data[i] == '}'){ + encapsulated--; + continue; + } + + if(!encapsulated && stripped->data[i] == ','){ + ARC_RectArray_ReadRect(config, stripped, index, i - index, &arraySize, value); + if(arc_errno){ + return 0; + } + + index = i + 1; + + if(arraySize == ((ARC_Array *) *value)->size){ + break; + } + } + } + + if(arraySize != ((ARC_Array *) *value)->size){ + ARC_RectArray_ReadRect(config, stripped, index, stripped->length - index, &arraySize, value); + } + ARC_String_Destroy(stripped); + return 0; +} + +void ARC_Point_Delete(ARC_Config* config, ARC_String *string, void *value){ + free((ARC_Point *)value); +} + +void ARC_Rect_Delete(ARC_Config* config, ARC_String *string, void *value){ + free((ARC_Rect *)value); +} + +void ARC_RectArray_Delete(ARC_Config* config, ARC_String *string, void *value){ + free((ARC_Array *)value); +} \ No newline at end of file diff --git a/src/std/string.c b/src/std/string.c index 3854af2..706b62b 100644 --- a/src/std/string.c +++ b/src/std/string.c @@ -303,7 +303,6 @@ void ARC_String_StripWhitespace(ARC_String *original, ARC_String **stripped){ ARC_String_Create(stripped, data, length); } - void ARC_String_StripEndsWhitespace(ARC_String *original, ARC_String **stripped){ uint64_t index; for(uint64_t i = 0; i < original->length; i++){