arr.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef arr_h
  2. #define arr_h
  3. // this header needs
  4. #include "byte_arr.h"
  5. // this array is different from bytarr in the sense that
  6. // it adds a few more information about the elements in the array
  7. typedef struct
  8. {
  9. // the array pointer with its byte size
  10. owl_mem_space * arr;
  11. // variable related functions
  12. struct {
  13. owl_type type;
  14. owl_umax size;
  15. owl_umax (* print_elem)(owl_byte *, owl_umax size);
  16. owl_char (* comp_elem)(owl_byte *, owl_byte *);
  17. } var;
  18. } owl_arr;
  19. typedef enum
  20. {
  21. OWL_TYPE_ARR = OWL_TYPE_BYTARR + 1,
  22. } owl_type_arr_h;
  23. // arr functions
  24. owl_bool owl_check_arr_pointer(owl_byte * src, owl_umax size);
  25. owl_bool owl_check_arr_members(owl_byte * ptr, owl_umax arr_size, owl_type type, owl_umax var_size,
  26. owl_umax (* print_elem)(owl_byte *, owl_umax size),
  27. owl_char (* comp_elem)(owl_byte *, owl_byte *));
  28. owl_bool owl_check_arr_all(owl_arr * data, owl_umax size);
  29. owl_arr * owl_create_arr(owl_byte * data, owl_umax arr_size, owl_type type, owl_umax var_size,
  30. owl_umax (* print_elem)(owl_byte *, owl_umax size),
  31. owl_char (* comp_elem)(owl_byte *, owl_byte *));
  32. owl_umax owl_free_arr(owl_arr * arr);
  33. owl_umax owl_print_arr(owl_byte * src, owl_umax size);
  34. owl_char owl_comp_arr(owl_byte * arr1, owl_byte * arr2);
  35. // specific functions
  36. owl_umax owl_reverse_arr(owl_arr * arr);
  37. owl_byte * owl_find_arr_elem(owl_arr * arr, owl_byte * elem, owl_umax size);
  38. // to do later (probably)
  39. owl_umax owl_sort_arr(owl_arr * arr);
  40. #include "arr.c"
  41. #endif // arr_h