str.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef TOOLBOX_STR_H
  2. #define TOOLBOX_STR_H
  3. #include <stddef.h>
  4. #include "toolbox/errno.h"
  5. #ifdef TOOLBOX_TYPEDEF
  6. typedef struct str str_st;
  7. #endif
  8. struct str {
  9. char *data;
  10. char *_c_data;
  11. size_t size;
  12. size_t _c_size;
  13. };
  14. struct str*
  15. str_create(const char *cstring, size_t cstring_size);
  16. struct str*
  17. str_create_ns(const char *cstring);
  18. RET_TYPE
  19. str_destroy(struct str *str);
  20. RET_TYPE
  21. str_to_lowercase(struct str *str);
  22. RET_TYPE
  23. str_to_uppercase(struct str *str);
  24. RET_TYPE
  25. str_to_titlecase(struct str *str);
  26. _Bool
  27. str_starts_with(struct str *str, struct str* start);
  28. _Bool
  29. str_starts_with_char(struct str *str, char chr);
  30. _Bool
  31. str_starts_with_cstring(struct str *str, char *cstring, size_t cstring_size);
  32. _Bool
  33. str_starts_with_cstring_ns(struct str *str, char *cstring);
  34. _Bool
  35. str_ends_with(struct str *str, struct str* end);
  36. _Bool
  37. str_ends_with_char(struct str *str, char chr);
  38. _Bool
  39. str_ends_with_cstring(struct str *str, char *cstring, size_t cstring_size);
  40. _Bool
  41. str_ends_with_cstring_ns(struct str *str, char *cstring);
  42. _Bool
  43. str_is_empty(struct str *str);
  44. size_t
  45. str_count_str(struct str *str, struct str *str2);
  46. size_t
  47. str_count_char(struct str *str, char chr);
  48. size_t
  49. str_count_cstring(struct str *str, char *cstring, size_t cstring_size);
  50. size_t
  51. str_count_cstring_ns(struct str *str, char *cstring);
  52. // reverse
  53. // append
  54. // prepend
  55. // trim_left
  56. // trim_right
  57. // trim
  58. // split
  59. // split_limit
  60. // equal
  61. // iequal
  62. // cmp
  63. // icmp
  64. // in_array
  65. // in_list
  66. // contains
  67. // to_cstring
  68. // to_char
  69. // to_short
  70. // to_int
  71. // to_long
  72. // to_float
  73. // to_double
  74. // formatted
  75. // join
  76. #endif