9 #include <kiba/containers/array.h>
42 static inline b8 character_is_whitespace(
char c) {
return c ==
' ' || c ==
'\t' || c ==
'\n'; }
44 static inline b8 character_is_decimal(
char c) {
return c >=
'0' && c <=
'9'; }
46 static inline b8 character_is_hexadecimal(
char c) {
return character_is_decimal(c) || (c >=
'a' && c <=
'f'); }
61 KB_API
string string_copy_raw(
const char *raw,
allocator *alloc);
153 KB_API b8
string_equal(
const string lhs,
const string rhs);
165 KB_API b8
string_n_equal(
const string lhs,
const string rhs, usize n);
Central header providing allocator functionality.
KB_API string string_clone(const string str, allocator *alloc)
Clone a complete string.
KB_API usize string_view_index_of(const string_view view, const char c)
Get the first index of a letter in a string_view.
KB_API string_view string_view_until_next_char(const string_view view, const char c)
Create a new string_view of an existing string_view until a certain character.
KB_API string_view string_view_subview(const string_view view, usize start, usize length)
Create a new string_view of an existing string_view.
struct string_view string_view
Non owning views on actual strings.
struct string string
Structure for a string.
KB_API string string_from_raw_n(const char *raw, usize n)
Construct a string from n chars of raw character data.
KB_API string string_from_views(const array_of(string_view) views, allocator *alloc)
Creates a new single string based on all provided views.
KB_API string_view string_view_after_next_char(const string_view view, const char c)
Create a new string_view of an existing string_view after a certain character.
KB_API string string_from_raw(const char *raw)
Construct a string from a raw string.
KB_API usize string_index_of(const string str, const char c)
Get the first index of a letter in a string.
KB_API b8 string_view_n_equal(const string_view lhs, const string_view rhs, usize n)
Check if the contents of two string views are equal.
KB_API b8 string_is_valid(const string str)
Check if string is valid.
KB_API void string_destroy(string *str)
Free data of the string.
KB_API string string_join_views(const array_of(string_view) views, const char sep, allocator *alloc)
Creates a new single string based on all provided views separated by a separator.
KB_API string string_from_view(const string_view view, allocator *alloc)
Creates a new string from a string view.
KB_API b8 string_equal(const string lhs, const string rhs)
Check if the contents of two strings are equal.
KB_API string_view string_view_from_string(const string str)
Create a new string view of a whole string.
KB_API string_view string_view_trim(const string_view view)
Create a new string_view which does not start or end in whitespace.
KB_API const char * string_view_data(const string_view view)
Get raw pointer to beginning of the string_view data.
KB_API char string_view_char_at(const string_view view, usize index)
Get the letter at an specific index in a string_view.
KB_API b8 string_view_equal(const string_view lhs, const string_view rhs)
Check if the contents of two string views are equal.
KB_API string_view string_view_at_offset(const string_view view, usize offset)
Create a new string_view of an existing string_view.
KB_API b8 string_view_split(const string_view view, const char c, array_of(string_view) *arr)
Split a single string_view into multiple based on a separator.
KB_API b8 string_n_equal(const string lhs, const string rhs, usize n)
Check if the contents of two strings are equal.
Global typedefs and macros.
Central allocator structure.
Non owning views on actual strings.
string str
The string the view is defined on.
b8 is_valid
Indicates if the view is valid and can be used/accessed.
usize length
The length of the view.
usize offset
The offset into the string.
allocator * alloc
The allocator used for construction. KB_NULL if constructed from a raw literal.
char * data
The character sequence of the string.
usize length
The length of the string.