documentation/kernel/utils/string.h.md

3.9 KiB

string.h

Basic functions for string manipulation.

string_t - typedef

A null-terminated array of chars.

string_length(string) - function (uint32_t)

Returns the amount of chars a string has before it's null-terminator.

string_compare(a, b) - function (bool)

Returns true when the strings a and b are equal. Returns false if they aren't equal.

string_find_next(string, chr) - function (uint32_t)

Returns the index of the next character that matches chr in string.

string_find_last(string, chr) - function (uint32_t)

Returns the index of the last character that matches chr in string.

variadic_format_size(string, args) - function (uint64_t)

Returns how long a format string with the given pattern (string) and args would be. Useful to create a big enough buffer before formatting a string.

format_size(string, ...) - function (uint64_t)

This calls variadic_format_size, but instead of giving it a va_list you can give this function the actual arguments.

variadic_format(output, string, args) - function (void)

Formats string with args and writes the product to output. The rules for format strings are specified on top of this document in the General concepts block.

format(output, string, ...) - function (void)

This calls variadic_format, but instead of giving it a va_list you can give this function the actual arguments.

string_unsigned_dec_to_alpha(string, value) - function (void)

Converts the unsigned integer in value to an alphanumeric string. The representation is decimal. This string will be written into string.

string_dec_to_alpha(string, value) - function (void)

Converts the signed integer in value to an alphanumeric string. If it is negative it will be prefixed with a hyphen. The representation is decimal. This string will be written into string.

string_hex_8bit_to_alpha(string, value) - function (void)

Converts the byte in value to an alphanumeric string. The representation is hexadecimal. This string will be written into string.

string_hex_16bit_to_alpha(string, value) - function (void)

Converts the word(16-bits) in value to an alphanumeric string. The representation is hexadecimal. This string will be written into string.

string_hex_32bit_to_alpha(string, value) - function (void)

Converts the dword(32-bits) in value to an alphanumeric string. The representation is hexadecimal. This string will be written into string.

string_hex_64bit_to_alpha(string, value) - function (void)

Converts the qword(64-bits) in value to an alphanumeric string. The representation is hexadecimal. This string will be written into string.

string_bin_to_alpha(string, num_bits, value) - function (void)

Converts the data in value to an alphanumeric string. The representation is binary. num_bits specifies how many bits, starting at the least significant bit, will be converted. This string will be written into string.

string_bool_to_alpha(string, value) - function (void)

Converts the boolean in value to an alphanumeric string. The representation is true or false. This string will be written into string.

string_is_char_text(chr) - function (bool)

Returns whether the char (chr) contains text(a-z, A-Z, 0-9, special chars) or not.

string_is_char_number(chr) - function (bool)

Returns whether the char (chr) is a number(0-9) or not.

string_is_char_alpha(chr) - function (bool)

Returns whether the char (chr) is alphanumeric(a-z, A-Z, 0-9) or not.

string_is_char_uppercase(chr) - function (bool)

Returns whether the char (chr) is uppercase(A-Z) or not.

string_is_char_lowercase(chr) - function (bool)

Returns whether the char (chr) is lowercase(a-z) or not.