2014-03-28 12:40:24 +00:00
|
|
|
#ifndef ALSTRING_H
|
|
|
|
#define ALSTRING_H
|
|
|
|
|
2014-03-28 14:59:47 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2014-03-28 12:40:24 +00:00
|
|
|
#include "vector.h"
|
|
|
|
|
2014-03-28 14:59:47 +00:00
|
|
|
|
2014-03-28 12:40:24 +00:00
|
|
|
typedef char al_string_char_type;
|
2014-07-06 10:27:39 +00:00
|
|
|
TYPEDEF_VECTOR(al_string_char_type, al_string)
|
2015-10-04 03:41:18 +00:00
|
|
|
TYPEDEF_VECTOR(al_string, vector_al_string)
|
2014-03-28 12:40:24 +00:00
|
|
|
|
2014-07-06 10:27:39 +00:00
|
|
|
inline void al_string_deinit(al_string *str)
|
|
|
|
{ VECTOR_DEINIT(*str); }
|
|
|
|
#define AL_STRING_INIT(_x) do { (_x) = (al_string)NULL; } while(0)
|
|
|
|
#define AL_STRING_INIT_STATIC() ((al_string)NULL)
|
2014-08-09 13:15:11 +00:00
|
|
|
#define AL_STRING_DEINIT(_x) al_string_deinit(&(_x))
|
2014-03-28 12:40:24 +00:00
|
|
|
|
2014-10-01 04:47:22 +00:00
|
|
|
inline size_t al_string_length(const_al_string str)
|
2014-03-28 12:40:24 +00:00
|
|
|
{ return VECTOR_SIZE(str); }
|
|
|
|
|
2014-04-30 19:53:52 +00:00
|
|
|
inline ALboolean al_string_empty(const_al_string str)
|
2014-03-28 12:40:24 +00:00
|
|
|
{ return al_string_length(str) == 0; }
|
|
|
|
|
|
|
|
inline const al_string_char_type *al_string_get_cstr(const_al_string str)
|
2014-04-03 18:13:12 +00:00
|
|
|
{ return str ? &VECTOR_FRONT(str) : ""; }
|
2014-03-28 12:40:24 +00:00
|
|
|
|
|
|
|
void al_string_clear(al_string *str);
|
|
|
|
|
2014-04-03 20:46:09 +00:00
|
|
|
int al_string_cmp(const_al_string str1, const_al_string str2);
|
|
|
|
int al_string_cmp_cstr(const_al_string str1, const al_string_char_type *str2);
|
2014-03-28 14:59:47 +00:00
|
|
|
|
2014-03-28 12:40:24 +00:00
|
|
|
void al_string_copy(al_string *str, const_al_string from);
|
|
|
|
void al_string_copy_cstr(al_string *str, const al_string_char_type *from);
|
2016-02-24 12:53:32 +00:00
|
|
|
void al_string_copy_range(al_string *str, const al_string_char_type *from, const al_string_char_type *to);
|
2014-03-28 12:40:24 +00:00
|
|
|
|
|
|
|
void al_string_append_char(al_string *str, const al_string_char_type c);
|
2014-03-28 14:59:47 +00:00
|
|
|
void al_string_append_cstr(al_string *str, const al_string_char_type *from);
|
2014-03-28 12:40:24 +00:00
|
|
|
void al_string_append_range(al_string *str, const al_string_char_type *from, const al_string_char_type *to);
|
|
|
|
|
2014-03-28 14:59:47 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <wchar.h>
|
|
|
|
/* Windows-only methods to deal with WideChar strings. */
|
|
|
|
void al_string_copy_wcstr(al_string *str, const wchar_t *from);
|
2015-10-04 10:17:52 +00:00
|
|
|
void al_string_append_wcstr(al_string *str, const wchar_t *from);
|
|
|
|
void al_string_append_wrange(al_string *str, const wchar_t *from, const wchar_t *to);
|
2014-03-28 14:59:47 +00:00
|
|
|
#endif
|
|
|
|
|
2014-03-28 12:40:24 +00:00
|
|
|
#endif /* ALSTRING_H */
|