aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alstring.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-03-28 05:40:24 -0700
committerChris Robinson <[email protected]>2014-03-28 05:44:19 -0700
commitaf8fda8a4a19e7d51506bf873c719361277249d2 (patch)
treee32990f884b9d3d6caed01dbccab4c111ee6902d /Alc/alstring.h
parent2ca673cca2205271fc1198e9bbf04695960cf25d (diff)
Add an al_string type and use it for the device lists
Diffstat (limited to 'Alc/alstring.h')
-rw-r--r--Alc/alstring.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/Alc/alstring.h b/Alc/alstring.h
new file mode 100644
index 00000000..b393a8f4
--- /dev/null
+++ b/Alc/alstring.h
@@ -0,0 +1,32 @@
+#ifndef ALSTRING_H
+#define ALSTRING_H
+
+#include "vector.h"
+
+typedef char al_string_char_type;
+DECL_VECTOR(al_string_char_type)
+
+typedef vector_al_string_char_type al_string;
+typedef const_vector_al_string_char_type const_al_string;
+
+#define AL_STRING_INIT(_x) do { (_x) = calloc(1, sizeof(*(_x)) + sizeof((_x)->Data[0])); } while(0)
+#define AL_STRING_DEINIT(_x) VECTOR_DEINIT(_x)
+
+inline ALsizei al_string_length(const_al_string str)
+{ return VECTOR_SIZE(str); }
+
+inline ALsizei al_string_empty(const_al_string str)
+{ return al_string_length(str) == 0; }
+
+inline const al_string_char_type *al_string_get_cstr(const_al_string str)
+{ return &VECTOR_FRONT(str); }
+
+void al_string_clear(al_string *str);
+
+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);
+
+void al_string_append_char(al_string *str, const al_string_char_type c);
+void al_string_append_range(al_string *str, const al_string_char_type *from, const al_string_char_type *to);
+
+#endif /* ALSTRING_H */