alstring.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef ALSTRING_H
  2. #define ALSTRING_H
  3. #include <string.h>
  4. #include "vector.h"
  5. typedef char al_string_char_type;
  6. TYPEDEF_VECTOR(al_string_char_type, al_string)
  7. TYPEDEF_VECTOR(al_string, vector_al_string)
  8. inline void al_string_deinit(al_string *str)
  9. { VECTOR_DEINIT(*str); }
  10. #define AL_STRING_INIT(_x) do { (_x) = (al_string)NULL; } while(0)
  11. #define AL_STRING_INIT_STATIC() ((al_string)NULL)
  12. #define AL_STRING_DEINIT(_x) al_string_deinit(&(_x))
  13. inline size_t al_string_length(const_al_string str)
  14. { return VECTOR_SIZE(str); }
  15. inline ALboolean al_string_empty(const_al_string str)
  16. { return al_string_length(str) == 0; }
  17. inline const al_string_char_type *al_string_get_cstr(const_al_string str)
  18. { return str ? &VECTOR_FRONT(str) : ""; }
  19. void al_string_clear(al_string *str);
  20. int al_string_cmp(const_al_string str1, const_al_string str2);
  21. int al_string_cmp_cstr(const_al_string str1, const al_string_char_type *str2);
  22. void al_string_copy(al_string *str, const_al_string from);
  23. void al_string_copy_cstr(al_string *str, const al_string_char_type *from);
  24. void al_string_copy_range(al_string *str, const al_string_char_type *from, const al_string_char_type *to);
  25. void al_string_append_char(al_string *str, const al_string_char_type c);
  26. void al_string_append_cstr(al_string *str, const al_string_char_type *from);
  27. void al_string_append_range(al_string *str, const al_string_char_type *from, const al_string_char_type *to);
  28. #ifdef _WIN32
  29. #include <wchar.h>
  30. /* Windows-only methods to deal with WideChar strings. */
  31. void al_string_copy_wcstr(al_string *str, const wchar_t *from);
  32. void al_string_append_wcstr(al_string *str, const wchar_t *from);
  33. void al_string_append_wrange(al_string *str, const wchar_t *from, const wchar_t *to);
  34. #endif
  35. #endif /* ALSTRING_H */