Kohi Game Engine
|
This file contains a basic C string handling library. More...
Go to the source code of this file.
Data Structures | |
struct | kstring |
A kstring is a managed string for higher-level logic to use. It is safer and, in some cases quicker than a typical cstring because it maintains length/allocation information and doesn't have to use strlen on most of its internal operations. More... | |
Typedefs | |
typedef struct kstring | kstring |
A kstring is a managed string for higher-level logic to use. It is safer and, in some cases quicker than a typical cstring because it maintains length/allocation information and doesn't have to use strlen on most of its internal operations. More... | |
Functions | |
KAPI u64 | string_length (const char *str) |
Gets the number of bytes of the given string, minus the null terminator. More... | |
KAPI u32 | string_utf8_length (const char *str) |
Gets the length of a string in UTF-8 (potentially multibyte) characters, minus the null terminator. More... | |
KAPI u64 | string_nlength (const char *str, u32 max_len) |
Gets the number of bytes of the given string, minus the null terminator, but at most max_len. This function only ever looks at the bytes pointed to in str up until, but never beyond, max_len - 1. More... | |
KAPI u32 | string_utf8_nlength (const char *str, u32 max_len) |
Gets the number of characters (multibyte = 1 character) of a string in UTF-8 (potentially multibyte) characters, minus the null terminator, but at most max_len. This function only ever looks at the characters pointed to in str up until, but never beyond, max_len - 1. More... | |
KAPI b8 | bytes_to_codepoint (const char *bytes, u32 offset, i32 *out_codepoint, u8 *out_advance) |
Obtains bytes needed from the byte array to form a UTF-8 codepoint, also providing how many bytes the current character is. More... | |
KAPI b8 | char_is_whitespace (char c) |
Indicates if the provided character is considered whitespace. More... | |
KAPI b8 | codepoint_is_whitespace (i32 codepoint) |
Indicates if the provided codepoint is considered whitespace. More... | |
KAPI char * | string_duplicate (const char *str) |
Duplicates the provided string. Note that this allocates new memory, which should be freed by the caller. More... | |
KAPI void | string_free (const char *str) |
Frees the memory of the given string. More... | |
KAPI i64 | kstr_ncmp (const char *str0, const char *str1, u32 max_len) |
KAPI i64 | kstr_ncmpi (const char *str0, const char *str1, u32 max_len) |
KAPI b8 | strings_equal (const char *str0, const char *str1) |
Case-sensitive string comparison. More... | |
KAPI b8 | strings_equali (const char *str0, const char *str1) |
Case-insensitive string comparison. More... | |
KAPI b8 | strings_nequal (const char *str0, const char *str1, u32 max_len) |
Case-sensitive string comparison, where comparison stops at max_len. More... | |
KAPI b8 | strings_nequali (const char *str0, const char *str1, u32 max_len) |
Case-insensitive string comparison, where comparison stops at max_len. More... | |
KAPI char * | string_format (const char *format,...) |
Performs string formatting against the given format string and parameters. NOTE: that this performs a dynamic allocation and should be freed by the caller. More... | |
KAPI char * | string_format_v (const char *format, void *va_list) |
Performs variadic string formatting against the given format string and va_list. NOTE: that this performs a dynamic allocation and should be freed by the caller. More... | |
KAPI i32 | string_format_unsafe (char *dest, const char *format,...) |
Performs string formatting to dest given format string and parameters. More... | |
KAPI i32 | string_format_v_unsafe (char *dest, const char *format, void *va_list) |
Performs variadic string formatting to dest given format string and va_list. More... | |
KAPI char * | string_empty (char *str) |
Empties the provided string by setting the first character to 0. More... | |
KAPI char * | string_copy (char *dest, const char *source) |
Copies the string in source to dest. Does not perform any allocations. More... | |
KAPI char * | string_ncopy (char *dest, const char *source, u32 max_len) |
Copies the bytes in the source buffer into the dest buffer up to the given length. Does not perform any allocations. Any remaining length after a 0 terminator will be zero-padded unless max_len is U32_MAX. More... | |
KAPI char * | string_trim (char *str) |
Performs an in-place trim of the provided string. This removes all whitespace from both ends of the string. More... | |
KAPI void | string_mid (char *dest, const char *source, i32 start, i32 length) |
Gets a substring of the source string between start and length or to the end of the string. If length is negative, goes to the end of the string. More... | |
KAPI i32 | string_index_of (const char *str, char c) |
Returns the index of the first occurance of c in str; otherwise -1. More... | |
KAPI i32 | string_last_index_of (const char *str, char c) |
Returns the index of the last occurance of c in str; otherwise -1. More... | |
KAPI i32 | string_index_of_str (const char *str_0, const char *str_1) |
Returns the index of the first occurance of str_1 in str_0; otherwise -1. More... | |
KAPI b8 | string_starts_with (const char *str_0, const char *str_1) |
Indicates if str_0 starts with str_1. Case-sensitive. More... | |
KAPI b8 | string_starts_withi (const char *str_0, const char *str_1) |
Indicates if str_0 starts with str_1. Case-insensitive. More... | |
KAPI void | string_insert_char_at (char *dest, const char *src, u32 pos, char c) |
KAPI void | string_insert_str_at (char *dest, const char *src, u32 pos, const char *str) |
KAPI void | string_remove_at (char *dest, const char *src, u32 pos, u32 length) |
KAPI b8 | string_to_mat4 (const char *str, mat4 *out_mat) |
Attempts to parse a 4x4 matrix from the provided string. More... | |
KAPI const char * | mat4_to_string (mat4 m) |
Creates a string representation of the provided matrix. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_vec4 (const char *str, vec4 *out_vector) |
Attempts to parse a vector from the provided string. More... | |
KAPI const char * | vec4_to_string (vec4 v) |
Creates a string representation of the provided vector. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_vec3 (const char *str, vec3 *out_vector) |
Attempts to parse a vector from the provided string. More... | |
KAPI const char * | vec3_to_string (vec3 v) |
Creates a string representation of the provided vector. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_vec2 (const char *str, vec2 *out_vector) |
Attempts to parse a vector from the provided string. More... | |
KAPI const char * | vec2_to_string (vec2 v) |
Creates a string representation of the provided vector. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_f32 (const char *str, f32 *f) |
Attempts to parse a 32-bit floating-point number from the provided string. More... | |
KAPI const char * | f32_to_string (f32 f) |
Creates a string representation of the provided float. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_f64 (const char *str, f64 *f) |
Attempts to parse a 64-bit floating-point number from the provided string. More... | |
KAPI const char * | f64_to_string (f64 f) |
Creates a string representation of the provided 64-bit float. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_i8 (const char *str, i8 *i) |
Attempts to parse an 8-bit signed integer from the provided string. More... | |
KAPI const char * | i8_to_string (i8 i) |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_i16 (const char *str, i16 *i) |
Attempts to parse a 16-bit signed integer from the provided string. More... | |
KAPI const char * | i16_to_string (i16 i) |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_i32 (const char *str, i32 *i) |
Attempts to parse a 32-bit signed integer from the provided string. More... | |
KAPI const char * | i32_to_string (i32 i) |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_i64 (const char *str, i64 *i) |
Attempts to parse a 64-bit signed integer from the provided string. More... | |
KAPI const char * | i64_to_string (i64 i) |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_u8 (const char *str, u8 *u) |
Attempts to parse an 8-bit unsigned integer from the provided string. More... | |
KAPI const char * | u8_to_string (u8 u) |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_u16 (const char *str, u16 *u) |
Attempts to parse a 16-bit unsigned integer from the provided string. More... | |
KAPI const char * | u16_to_string (u16 u) |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_u32 (const char *str, u32 *u) |
Attempts to parse a 32-bit unsigned integer from the provided string. More... | |
KAPI const char * | u32_to_string (u32 u) |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_u64 (const char *str, u64 *u) |
Attempts to parse a 64-bit unsigned integer from the provided string. More... | |
KAPI const char * | u64_to_string (u64 u) |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI b8 | string_to_bool (const char *str, b8 *b) |
Attempts to parse a boolean from the provided string. "true" or "1" are considered true; anything else is false. More... | |
KAPI const char * | bool_to_string (b8 b) |
Creates a string representation of the provided boolean, i.e. "false" for false/0 and "true" for everything else. NOTE: string is dynamically allocated, so the caller should free it. More... | |
KAPI u32 | string_split (const char *str, char delimiter, char ***str_darray, b8 trim_entries, b8 include_empty) |
Splits the given string by the delimiter provided and stores in the provided darray. Optionally trims each entry. NOTE: A string allocation occurs for each entry, and MUST be freed by the caller. More... | |
KAPI void | string_cleanup_split_darray (char **str_darray) |
Cleans up string allocations in str_darray, but does not free the darray itself. More... | |
KAPI void | string_cleanup_array (const char **str_array, u32 length) |
Cleans up string allocations in str_array and frees the array itself. More... | |
KAPI u32 | string_nsplit (const char *str, char delimiter, u32 max_count, char **str_array, b8 trim_entries, b8 include_empty) |
Splits the given string by the delimiter provided and stores in the provided fixed-size array. Optionally trims each entry. NOTE: A string allocation occurs for each entry, and MUST be freed by the caller. More... | |
KAPI void | string_cleanup_split_array (char **str_array, u32 max_count) |
Cleans up string allocations in the fixed-size str_array, but does not free the array itself. More... | |
KAPI void | string_append_string (char *dest, const char *source, const char *append) |
KAPI void | string_append_int (char *dest, const char *source, i64 i) |
Appends the supplied integer to source and outputs to dest. More... | |
KAPI void | string_append_float (char *dest, const char *source, f32 f) |
Appends the supplied float to source and outputs to dest. More... | |
KAPI void | string_append_bool (char *dest, const char *source, b8 b) |
Appends the supplied boolean (as either "true" or "false") to source and outputs to dest. More... | |
KAPI void | string_append_char (char *dest, const char *source, char c) |
Appends the supplied character to source and outputs to dest. More... | |
KAPI char * | string_join (const char **strings, u32 count, char delimiter) |
Joins the array of strings given with the provided delimiter. The delimiter is not used after the final entry. More... | |
KAPI const char * | string_directory_from_path (const char *path) |
Extracts the directory from a full file path. More... | |
KAPI const char * | string_filename_from_path (const char *path) |
Extracts the filename (including file extension) from a full file path. More... | |
KAPI const char * | string_filename_no_extension_from_path (const char *path) |
Extracts the filename (excluding file extension) from a full file path. More... | |
KAPI const char * | string_extension_from_path (const char *path, b8 include_dot) |
Attempts to get the file extension from the given path. Allocates a new string which should be freed. More... | |
KAPI b8 | string_parse_array_length (const char *str, u32 *out_length) |
Attempts to extract an array length from a given string. Ex: a string of sampler2D[4] will return True and set out_length to 4. More... | |
KAPI b8 | string_line_get (const char *source_str, u16 max_line_length, u32 start_from, char **out_buffer, u32 *out_line_length, u8 *out_addl_advance) |
KAPI b8 | codepoint_is_lower (i32 codepoint) |
KAPI b8 | codepoint_is_upper (i32 codepoint) |
KAPI b8 | codepoint_is_alpha (i32 codepoint) |
KAPI b8 | codepoint_is_numeric (i32 codepoint) |
KAPI b8 | codepoint_is_space (i32 codepoint) |
KAPI void | string_to_lower (char *str) |
KAPI void | string_to_upper (char *str) |
KAPI void | kstring_create (kstring *out_string) |
KAPI void | kstring_from_cstring (const char *source, kstring *out_string) |
KAPI void | kstring_destroy (kstring *string) |
KAPI u32 | kstring_length (const kstring *string) |
KAPI u32 | kstring_utf8_length (const kstring *string) |
KAPI void | kstring_append_str (kstring *string, const char *s) |
KAPI void | kstring_append_kstring (kstring *string, const kstring *other) |
This file contains a basic C string handling library.
A kstring is a managed string for higher-level logic to use. It is safer and, in some cases quicker than a typical cstring because it maintains length/allocation information and doesn't have to use strlen on most of its internal operations.
Creates a string representation of the provided boolean, i.e. "false" for false/0 and "true" for everything else. NOTE: string is dynamically allocated, so the caller should free it.
b | The boolean to create a string from. |
KAPI b8 bytes_to_codepoint | ( | const char * | bytes, |
u32 | offset, | ||
i32 * | out_codepoint, | ||
u8 * | out_advance | ||
) |
Obtains bytes needed from the byte array to form a UTF-8 codepoint, also providing how many bytes the current character is.
bytes | The byte array to choose from. |
offset | The offset in bytes to start from. |
out_codepoint | A pointer to hold the UTF-8 codepoint. |
out_advance | A pointer to hold the advance, or how many bytes the codepoint takes. |
Indicates if the provided character is considered whitespace.
c | The character to examine. |
Indicates if provided codepoint is alpha-numeric. Regular ASCII and western European high-ascii characters only.
Indicates if provided codepoint is lower-case. Regular ASCII and western European high-ascii characters only.
Indicates if provided codepoint is numeric. Regular ASCII and western European high-ascii characters only.
Indicates if the given codepoint is considered to be a space. Includes ' ', \f \r
\t and \v.
Indicates if provided codepoint is upper-case. Regular ASCII and western European high-ascii characters only.
Indicates if the provided codepoint is considered whitespace.
codepoint | The codepoint to examine. |
Creates a string representation of the provided float. NOTE: string is dynamically allocated, so the caller should free it.
f | The float to convert to string. |
Creates a string representation of the provided 64-bit float. NOTE: string is dynamically allocated, so the caller should free it.
f | The 64-bit float to convert to string. |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it.
i | The integer to create a string from. |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it.
i | The integer to create a string from. |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it.
i | The integer to create a string from. |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it.
i | The integer to create a string from. |
Creates a string representation of the provided matrix. NOTE: string is dynamically allocated, so the caller should free it.
m | The matrix to convert to string. |
Appends the supplied boolean (as either "true" or "false") to source and outputs to dest.
dest | The destination for the string. |
source | The string to be appended to. |
b | The boolean to be appended. |
KAPI void string_append_char | ( | char * | dest, |
const char * | source, | ||
char | c | ||
) |
Appends the supplied character to source and outputs to dest.
dest | The destination for the string. |
source | The string to be appended to. |
c | The character to be appended. |
Appends the supplied float to source and outputs to dest.
dest | The destination for the string. |
source | The string to be appended to. |
f | The float to be appended. |
Appends the supplied integer to source and outputs to dest.
dest | The destination for the string. |
source | The string to be appended to. |
i | The integer to be appended. |
KAPI void string_append_string | ( | char * | dest, |
const char * | source, | ||
const char * | append | ||
) |
Appends append to source and returns a new string.
dest | The destination string. |
source | The string to be appended to. |
append | The string to append to source. |
Cleans up string allocations in str_array and frees the array itself.
NOTE: Not for use with darrays! Use string_cleanup_split_darray() instead or memory will be leaked.
str_array | The array to be cleaned up and freed. |
length | The number of string elements in the array. |
Cleans up string allocations in the fixed-size str_array, but does not free the array itself.
str_darray | The fixed-size array to be cleaned up. |
max_count | The number of entries (and thus the size) of the fixed-size array. |
KAPI void string_cleanup_split_darray | ( | char ** | str_darray | ) |
Cleans up string allocations in str_darray, but does not free the darray itself.
str_darray | The darray to be cleaned up. |
KAPI char* string_copy | ( | char * | dest, |
const char * | source | ||
) |
Copies the string in source to dest. Does not perform any allocations.
dest | The destination string. |
source | The source string. |
KAPI const char* string_directory_from_path | ( | const char * | path | ) |
Extracts the directory from a full file path.
path | The full path to extract from. |
KAPI char* string_duplicate | ( | const char * | str | ) |
Duplicates the provided string. Note that this allocates new memory, which should be freed by the caller.
str | The string to be duplicated. |
KAPI char* string_empty | ( | char * | str | ) |
Empties the provided string by setting the first character to 0.
str | The string to be emptied. |
Attempts to get the file extension from the given path. Allocates a new string which should be freed.
NOTE: This function dynamically allocates string memory. The string should be freed by the caller.
path | The full path to extract from. |
include_dot | Indicates if the '.' should be included in the output. |
KAPI const char* string_filename_from_path | ( | const char * | path | ) |
Extracts the filename (including file extension) from a full file path.
NOTE: This function dynamically allocates string memory. The string should be freed by the caller.
path | The full path to extract from. |
KAPI const char* string_filename_no_extension_from_path | ( | const char * | path | ) |
Extracts the filename (excluding file extension) from a full file path.
NOTE: This function dynamically allocates string memory. The string should be freed by the caller.
path | The full path to extract from. |
KAPI char* string_format | ( | const char * | format, |
... | |||
) |
Performs string formatting against the given format string and parameters. NOTE: that this performs a dynamic allocation and should be freed by the caller.
format | The format string to use for the operation |
... | The format arguments. |
Performs string formatting to dest given format string and parameters.
dest | The destination for the formatted string. |
format | The format string to use for the operation |
... | The format arguments. |
KAPI char* string_format_v | ( | const char * | format, |
void * | va_list | ||
) |
Performs variadic string formatting against the given format string and va_list. NOTE: that this performs a dynamic allocation and should be freed by the caller.
format | The string to be formatted. |
va_list | The variadic argument list. |
Performs variadic string formatting to dest given format string and va_list.
dest | The destination for the formatted string. |
format | The string to be formatted. |
va_list | The variadic argument list. |
KAPI void string_free | ( | const char * | str | ) |
Frees the memory of the given string.
str | The string to be freed. |
Returns the index of the first occurance of c in str; otherwise -1.
str | The string to be scanned. |
c | The character to search for. |
Returns the index of the first occurance of str_1 in str_0; otherwise -1.
str_0 | The string to be scanned. |
str_1 | The substring to search for. |
Joins the array of strings given with the provided delimiter. The delimiter is not used after the final entry.
NOTE: This function dynamically allocates string memory. The string should be freed by the caller.
strings | The array of strings to be joined. |
count | The number of strings to be joined. |
delimiter | The delimiter character to join with. |
Returns the index of the last occurance of c in str; otherwise -1.
str | The string to be scanned. |
c | The character to search for. |
Gets the number of bytes of the given string, minus the null terminator.
NOTE: For strings without a null terminator, use string_nlength instead.
str | The string whose length to obtain. |
KAPI b8 string_line_get | ( | const char * | source_str, |
u16 | max_line_length, | ||
u32 | start_from, | ||
char ** | out_buffer, | ||
u32 * | out_line_length, | ||
u8 * | out_addl_advance | ||
) |
Gets a substring of the source string between start and length or to the end of the string. If length is negative, goes to the end of the string.
Done by placing zeroes in the string at relevant points.
str | The string to be trimmed. |
Copies the bytes in the source buffer into the dest buffer up to the given length. Does not perform any allocations. Any remaining length after a 0 terminator will be zero-padded unless max_len is U32_MAX.
dest | A pointer to the destination buffer. Must be at least max_len large. |
source | A constant pointer to the source buffer. |
length | The maximum number of bytes to be copied. |
Gets the number of bytes of the given string, minus the null terminator, but at most max_len. This function only ever looks at the bytes pointed to in str up until, but never beyond, max_len - 1.
str | The string whose length to obtain. |
max_len | The maximum number of bytes to examine in the string. |
KAPI u32 string_nsplit | ( | const char * | str, |
char | delimiter, | ||
u32 | max_count, | ||
char ** | str_array, | ||
b8 | trim_entries, | ||
b8 | include_empty | ||
) |
Splits the given string by the delimiter provided and stores in the provided fixed-size array. Optionally trims each entry. NOTE: A string allocation occurs for each entry, and MUST be freed by the caller.
str | The string to be split. |
delimiter | The character to split by. |
max_count | The maximum number of entries to split. |
str_darray | A fixed-size array of char arrays. Must be large enough to hold max_count entries. |
trim_entries | Trims each entry if true. |
include_empty | Indicates if empty entries should be included. |
Attempts to extract an array length from a given string. Ex: a string of sampler2D[4] will return True and set out_length to 4.
str | The string to examine. |
out_length | A pointer to hold the length, if extracted successfully. |
KAPI u32 string_split | ( | const char * | str, |
char | delimiter, | ||
char *** | str_darray, | ||
b8 | trim_entries, | ||
b8 | include_empty | ||
) |
Splits the given string by the delimiter provided and stores in the provided darray. Optionally trims each entry. NOTE: A string allocation occurs for each entry, and MUST be freed by the caller.
str | The string to be split. |
delimiter | The character to split by. |
str_darray | A pointer to a darray of char arrays to hold the entries. NOTE: must be a darray. |
trim_entries | Trims each entry if true. |
include_empty | Indicates if empty entries should be included. |
Indicates if str_0 starts with str_1. Case-sensitive.
str_0 | The string to be scanned. |
str_1 | The substring to search for. |
Indicates if str_0 starts with str_1. Case-insensitive.
str_0 | The string to be scanned. |
str_1 | The substring to search for. |
Attempts to parse a boolean from the provided string. "true" or "1" are considered true; anything else is false.
str | The string to parse from. "true" or "1" are considered true; anything else is false. |
b | A pointer to the boolean to write to. |
Attempts to parse a 32-bit floating-point number from the provided string.
str | The string to parse from. Should not be postfixed with 'f'. |
f | A pointer to the float to write to. |
Attempts to parse a 64-bit floating-point number from the provided string.
str | The string to parse from. |
f | A pointer to the float to write to. |
Attempts to parse a 16-bit signed integer from the provided string.
str | The string to parse from. |
i | A pointer to the int to write to. |
Attempts to parse a 32-bit signed integer from the provided string.
str | The string to parse from. |
i | A pointer to the int to write to. |
Attempts to parse a 64-bit signed integer from the provided string.
str | The string to parse from. |
i | A pointer to the int to write to. |
Attempts to parse an 8-bit signed integer from the provided string.
str | The string to parse from. |
i | A pointer to the int to write to. |
KAPI void string_to_lower | ( | char * | str | ) |
Converts string in-place to uppercase. Regular ASCII and western European high-ascii characters only.
Attempts to parse a 4x4 matrix from the provided string.
str | The string to parse from. Should be space delimited. (i.e "1.0 1.0 ... 1.0") |
out_mat | A pointer to the matrix to write to. |
Attempts to parse a 16-bit unsigned integer from the provided string.
str | The string to parse from. |
u | A pointer to the int to write to. |
Attempts to parse a 32-bit unsigned integer from the provided string.
str | The string to parse from. |
u | A pointer to the int to write to. |
Attempts to parse a 64-bit unsigned integer from the provided string.
str | The string to parse from. |
u | A pointer to the int to write to. |
Attempts to parse an 8-bit unsigned integer from the provided string.
str | The string to parse from. |
u | A pointer to the int to write to. |
KAPI void string_to_upper | ( | char * | str | ) |
Converts string in-place to uppercase. Regular ASCII and western European high-ascii characters only.
Attempts to parse a vector from the provided string.
str | The string to parse from. Should be space-delimited. (i.e. "1.0 2.0") |
out_vector | A pointer to the vector to write to. |
Attempts to parse a vector from the provided string.
str | The string to parse from. Should be space-delimited. (i.e. "1.0 2.0 3.0") |
out_vector | A pointer to the vector to write to. |
Attempts to parse a vector from the provided string.
str | The string to parse from. Should be space-delimited. (i.e. "1.0 2.0 3.0 4.0") |
out_vector | A pointer to the vector to write to. |
KAPI char* string_trim | ( | char * | str | ) |
Performs an in-place trim of the provided string. This removes all whitespace from both ends of the string.
Done by placing zeroes in the string at relevant points.
str | The string to be trimmed. |
Gets the length of a string in UTF-8 (potentially multibyte) characters, minus the null terminator.
NOTE: For strings without a null terminator, use string_utf8_nlength instead.
str | The string to examine. |
Gets the number of characters (multibyte = 1 character) of a string in UTF-8 (potentially multibyte) characters, minus the null terminator, but at most max_len. This function only ever looks at the characters pointed to in str up until, but never beyond, max_len - 1.
str | The string to examine. |
max_len | The maximum number of characters to examine in the string. |
Case-sensitive string comparison.
str0 | The first string to be compared. |
str1 | The second string to be compared. |
Case-insensitive string comparison.
str0 | The first string to be compared. |
str1 | The second string to be compared. |
Case-sensitive string comparison, where comparison stops at max_len.
str0 | The first string to be compared. |
str1 | The second string to be compared. |
max_len | The maximum number of bytes to be compared. |
Case-insensitive string comparison, where comparison stops at max_len.
str0 | The first string to be compared. |
str1 | The second string to be compared. |
max_len | The maximum number of bytes to be compared. |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it.
u | The integer to create a string from. |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it.
u | The integer to create a string from. |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it.
u | The integer to create a string from. |
Creates a string representation of the provided integer. NOTE: string is dynamically allocated, so the caller should free it.
u | The integer to create a string from. |
Creates a string representation of the provided vector. NOTE: string is dynamically allocated, so the caller should free it.
v | The vector to convert to string. |
Creates a string representation of the provided vector. NOTE: string is dynamically allocated, so the caller should free it.
v | The vector to convert to string. |