GATE
|
String management, UTF conversion and basic text parsing functions. More...
#include "gate/gate_core_api.h"
#include "gate/atomics.h"
#include "gate/memalloc.h"
#include <stdarg.h>
Data Structures | |
struct | gate_stringbuffer8_class |
character (byte) string buffer class More... | |
struct | gate_strbuilder8_class |
character (byte) string builder class More... | |
struct | gate_string8_class |
character (byte) string class More... | |
struct | gate_cstrbuffer8_class |
C-string buffer class. More... | |
struct | gate_print_value_class |
Structure holding a pair of GATE_PRINT_* and a pointer to a target type specified by GATE_PRINT_* IDs. More... | |
Macros | |
#define | GATE_STRING_INIT(ptr_str) |
Initializes a gate_string_t variable with a string pointer and dynamically detect string length. | |
#define | GATE_STRING_INIT_EMPTY { NULL, 0, NULL } |
Initializes a gate_string_t variable with NULL values like an empty string. | |
#define | GATE_STRING_INIT_STATIC(const_text) |
Initializes a gate_string_t variable with a static string literal. | |
#define | GATE_STR_NPOS GATE_INVALID_SIZE |
#define | GATE_PRINT_END ((int)0x00) |
#define | GATE_PRINT_CHAR ((int)0x01) |
#define | GATE_PRINT_NEWLINE ((int)0x02) |
#define | GATE_PRINT_CSTR ((int)0x03) |
#define | GATE_PRINT_STRING ((int)0x04) |
#define | GATE_PRINT_CR ((int)0x05) |
#define | GATE_PRINT_LF ((int)0x06) |
#define | GATE_PRINT_CRLF ((int)0x07) |
#define | GATE_PRINT_BOOL ((int)0x10) |
#define | GATE_PRINT_I8 ((int)0x11) |
#define | GATE_PRINT_UI8 ((int)0x12) |
#define | GATE_PRINT_I16 ((int)0x13) |
#define | GATE_PRINT_UI16 ((int)0x14) |
#define | GATE_PRINT_I32 ((int)0x15) |
#define | GATE_PRINT_UI32 ((int)0x16) |
#define | GATE_PRINT_I64 ((int)0x17) |
#define | GATE_PRINT_UI64 ((int)0x18) |
#define | GATE_PRINT_H8 ((int)0x1a) |
#define | GATE_PRINT_H16 ((int)0x1b) |
#define | GATE_PRINT_H32 ((int)0x1c) |
#define | GATE_PRINT_H64 ((int)0x1d) |
#define | GATE_PRINT_R32 ((int)0x21) |
#define | GATE_PRINT_R64 ((int)0x22) |
#define | GATE_PRINT_ADDRESS ((int)0x23) |
Typedefs | |
typedef struct gate_stringbuffer8_class | gate_stringbuffer8_t |
character (byte) string buffer class | |
typedef struct gate_strbuilder8_class | gate_strbuilder8_t |
character (byte) string builder class | |
typedef struct gate_string8_class | gate_string8_t |
character (byte) string class | |
typedef struct gate_cstrbuffer8_class | gate_cstrbuffer8_t |
C-string buffer class. | |
typedef char const * | gate_cstr_t |
constant byte character string | |
typedef wchar_t const * | gate_wstr_t |
constant wide character string | |
typedef struct gate_print_value_class | gate_print_value_t |
Structure holding a pair of GATE_PRINT_* and a pointer to a target type specified by GATE_PRINT_* IDs. | |
Functions | |
GATE_CORE_API int | gate_char_lowercase (int chr) |
Converts an ASCII character to its lower case. | |
GATE_CORE_API int | gate_char_uppercase (int chr) |
Converts an ASCII character to its upper case. | |
GATE_CORE_API gate_bool_t | gate_char_is_digit (int chr) |
Returns true, if the ASCII character is a digite '0' - '9'. | |
GATE_CORE_API gate_bool_t | gate_char_is_whitespace (int chr) |
Returns true, if the ASCII character is a whitespace. | |
GATE_CORE_API gate_size_t | gate_char_read_utf8 (gate_char8_t const *src, gate_size_t srclen, gate_char32_t *dst) |
Reads an UTF-8 encoded byte sequence and decodes a single unicode character. | |
GATE_CORE_API gate_size_t | gate_char_read_utf16 (gate_char16_t const *src, gate_size_t srclen, gate_char32_t *dst) |
Reads an UTF-16 encoded sequence and decodes a single unicode character. | |
GATE_CORE_API gate_size_t | gate_char_read_utf32 (gate_char32_t const *src, gate_size_t srclen, gate_char32_t *dst) |
Reads an UTF-32 encoded byte sequence and decodes a single unicode character. | |
GATE_CORE_API gate_size_t | gate_char_write_utf8 (gate_char32_t src, gate_char8_t *dst, gate_size_t dstlen) |
Encodes one unicode character into an UTF-8 byte buffer. | |
GATE_CORE_API gate_size_t | gate_char_write_utf16 (gate_char32_t src, gate_char16_t *dst, gate_size_t dstlen) |
Encodes one unicode character into an UTF-16 word buffer. | |
GATE_CORE_API gate_size_t | gate_char_write_utf32 (gate_char32_t src, gate_char32_t *dst, gate_size_t dstlen) |
Encodes one unicode character into an UTF-32 word buffer. | |
GATE_CORE_API gate_size_t | gate_str_utf8_2_utf16 (gate_char8_t const *src, gate_size_t srclen, gate_char16_t *dst, gate_size_t dstlen) |
Converts an UTF-8 input buffer into an UTF-16 output buffer. | |
GATE_CORE_API gate_size_t | gate_str_utf8_2_utf32 (gate_char8_t const *src, gate_size_t srclen, gate_char32_t *dst, gate_size_t dstlen) |
Converts an UTF-8 input buffer into an UTF-32 output buffer. | |
GATE_CORE_API gate_size_t | gate_str_utf16_2_utf8 (gate_char16_t const *src, gate_size_t srclen, gate_char8_t *dst, gate_size_t dstlen) |
Converts an UTF-16 input buffer into an UTF-8 output buffer. | |
GATE_CORE_API gate_size_t | gate_str_utf16_2_utf32 (gate_char16_t const *src, gate_size_t srclen, gate_char32_t *dst, gate_size_t dstlen) |
Converts an UTF-16 input buffer into an UTF-32 output buffer. | |
GATE_CORE_API gate_size_t | gate_str_utf32_2_utf8 (gate_char32_t const *src, gate_size_t srclen, gate_char8_t *dst, gate_size_t dstlen) |
Converts an UTF-32 input buffer into an UTF-8 output buffer. | |
GATE_CORE_API gate_size_t | gate_str_utf32_2_utf16 (gate_char32_t const *src, gate_size_t srclen, gate_char16_t *dst, gate_size_t dstlen) |
Converts an UTF-32 input buffer into an UTF-16 output buffer. | |
GATE_CORE_API gate_size_t | gate_str_length (gate_char8_t const *src) |
Returns the length of a NULL-terminated character string. | |
GATE_CORE_API gate_size_t | gate_str_length_max (gate_char8_t const *src, gate_size_t capacity) |
Returns the length of a NULL-terminated character string with a limited capacity. | |
GATE_CORE_API gate_bool_t | gate_str_is_empty (gate_char8_t const *src) |
Returns true if the given character string is emptry. | |
GATE_CORE_API int | gate_str_comp_range (gate_char8_t const *str1, gate_char8_t const *str2, gate_size_t len) |
Compares two string ranges of equal size by their byte values. | |
GATE_CORE_API int | gate_str_comp_range_ic (gate_char8_t const *str1, gate_char8_t const *str2, gate_size_t len) |
Compares two string ranges of equal size by their byte values and treats all ASCII values as lower-case. | |
GATE_CORE_API void | gate_str_to_lower (gate_char8_t *str, gate_size_t len) |
Converts all ASCII characters in a string to their lower-case counterparts. | |
GATE_CORE_API void | gate_str_to_upper (gate_char8_t *str, gate_size_t len) |
Converts all ASCII characters in a string to their upper-case counterparts. | |
GATE_CORE_API void | gate_str_reverse (gate_char8_t *str, gate_size_t len) |
Reverses the bytes sequence of a string (first <-> last) | |
GATE_CORE_API gate_size_t | gate_str_char_pos (gate_char8_t const *str, gate_size_t len, gate_char8_t find, gate_size_t startat) |
Searches for the first occurance of a character in a string. | |
GATE_CORE_API gate_size_t | gate_str_char_pos_last (gate_char8_t const *str, gate_size_t len, gate_char8_t find) |
Searches for the last occurance of a character in a string. | |
GATE_CORE_API gate_size_t | gate_str_pos (gate_char8_t const *str, gate_size_t len, gate_char8_t const *find, gate_size_t findlen, gate_size_t startat) |
Searches for the first occurance of a sub-string in a string. | |
GATE_CORE_API gate_size_t | gate_str_count_chars (gate_char8_t const *str, gate_size_t len, gate_char8_t chr) |
Counts the amount of given character in a string. | |
GATE_CORE_API int | gate_str_comp (gate_char8_t const *str1, gate_char8_t const *str2) |
Compares two NULL-terminated strings. | |
GATE_CORE_API int | gate_str_comp_ic (gate_char8_t const *str1, gate_char8_t const *str2) |
Compares two NULL-terminated strings and compare characters case insensitive. | |
GATE_CORE_API int | gate_str_compare (gate_char8_t const *str1, gate_size_t len1, gate_char8_t const *str2, gate_size_t len2) |
Compares two strings including their byte lengths. | |
GATE_CORE_API int | gate_str_compare_ic (gate_char8_t const *str1, gate_size_t len1, gate_char8_t const *str2, gate_size_t len2) |
Compares two strings including their byte lengths and compare characters case insensitive. | |
GATE_CORE_API gate_size_t | gate_str_is_numeric (gate_char8_t const *str, gate_size_t len) |
Checks the content of the string and returns the amount of consecutive digits. | |
GATE_CORE_API gate_bool_t | gate_str_starts_with (gate_char8_t const *str, gate_size_t len, gate_char8_t const *starttoken, gate_size_t startlen) |
Detects if a string starts with the content of another string exactly. | |
GATE_CORE_API gate_bool_t | gate_str_ends_with (gate_char8_t const *str, gate_size_t len, gate_char8_t const *endtoken, gate_size_t endlen) |
Detects if a string ends with the content of another string exactly. | |
GATE_CORE_API gate_bool_t | gate_str_starts_with_ic (gate_char8_t const *str, gate_size_t len, gate_char8_t const *starttoken, gate_size_t startlen) |
Detects if a string starts with the content of another string by comparing case insensitive. | |
GATE_CORE_API gate_bool_t | gate_str_ends_with_ic (gate_char8_t const *str, gate_size_t len, gate_char8_t const *endtoken, gate_size_t endlen) |
Detects if a string ends with the content of another string by comparing case insensitive. | |
GATE_CORE_API gate_size_t | gate_str_print_text (gate_char8_t *dst, gate_size_t dstlen, gate_char8_t const *txt, gate_size_t txtlen) |
Prints the text content of a 8-bit encoded string into a destination string buffer. | |
GATE_CORE_API gate_size_t | gate_str_print_wtext (gate_char8_t *dst, gate_size_t dstlen, wchar_t const *txt, gate_size_t txtlen) |
Prints the text content of a wide string into a destination string buffer. | |
GATE_CORE_API gate_size_t | gate_str_print_uint (gate_char8_t *dst, gate_size_t dstlen, gate_uint64_t num, gate_size_t intlen) |
Prints a unsigned integer as a decimal number into a destination string buffer. | |
GATE_CORE_API gate_size_t | gate_str_print_real (gate_char8_t *dst, gate_size_t dstlen, gate_real64_t num, unsigned intlen, unsigned decimallen, unsigned grouplen) |
Prints a floating point number into a destination string buffer. | |
GATE_CORE_API gate_bool_t | gate_str_like (gate_char8_t const *str, gate_size_t len, gate_char8_t const *like, gate_size_t likelen) |
Evaluates if a string matches a simple wildcard pattern. | |
GATE_CORE_API gate_bool_t | gate_str_like_one_of (gate_char8_t const *str, gate_size_t len, gate_char8_t const *like, gate_size_t likelen, gate_char8_t like_separator) |
Evaluates if a string matches one of a group of wildcard patterns. | |
GATE_CORE_API gate_size_t | gate_str_find_first_of (gate_char8_t const *str, gate_size_t len, gate_char8_t const *chars, gate_size_t charcount, gate_size_t startat) |
Finds the first byte position of one match of some characters in a string. | |
GATE_CORE_API gate_size_t | gate_str_find_first_not_of (gate_char8_t const *str, gate_size_t len, gate_char8_t const *chars, gate_size_t charcount, gate_size_t startat) |
Finds the first byte position of a character not matching a list of characters. | |
GATE_CORE_API gate_size_t | gate_str_find_last_of (gate_char8_t const *str, gate_size_t len, gate_char8_t const *chars, gate_size_t charcount) |
Finds the last byte position of one match of some characters in a string. | |
GATE_CORE_API gate_size_t | gate_str_find_last_not_of (gate_char8_t const *str, gate_size_t len, gate_char8_t const *chars, gate_size_t charcount) |
Finds the last byte position of a character not matching a list of characters. | |
GATE_CORE_API gate_uint32_t | gate_str_hash (gate_char8_t const *str, gate_size_t len) |
Calculates a hash value over the content of the given string bytes. | |
GATE_CORE_API gate_size_t | gate_str_replace (gate_char8_t *str, gate_size_t len, gate_char8_t find, gate_char8_t replace) |
Replaces all occurances of a character in a string with another character. | |
GATE_CORE_API gate_size_t | gate_str_print_int16 (gate_char8_t *dst, gate_size_t dstlen, gate_int16_t num) |
Prints a 16 bit signed integer into a destination string buffer. | |
GATE_CORE_API gate_size_t | gate_str_print_uint16 (gate_char8_t *dst, gate_size_t dstlen, gate_uint16_t num) |
Prints a 16 bit unsigned signed integer into a destination string buffer. | |
GATE_CORE_API gate_size_t | gate_str_print_int32 (gate_char8_t *dst, gate_size_t dstlen, gate_int32_t num) |
Prints a 32 bit signed integer into a destination string buffer. | |
GATE_CORE_API gate_size_t | gate_str_print_uint32 (gate_char8_t *dst, gate_size_t dstlen, gate_uint32_t num) |
Prints a 32 bit unsigned integer into a destination string buffer. | |
GATE_CORE_API gate_size_t | gate_str_print_int64 (gate_char8_t *dst, gate_size_t dstlen, gate_int64_t num) |
Prints a 64 bit signed integer into a destination string buffer. | |
GATE_CORE_API gate_size_t | gate_str_print_uint64 (gate_char8_t *dst, gate_size_t dstlen, gate_uint64_t num) |
Prints a 64 bit unsigned integer into a destination string buffer. | |
GATE_CORE_API gate_char8_t | gate_str_print_hex_nibble (gate_uint8_t nibble, gate_bool_t uppercase) |
Prints a 4-bit number (nibble) into a hexadecimal character. | |
GATE_CORE_API gate_size_t | gate_str_print_hex_byte (gate_char8_t *dst, gate_size_t dstlen, gate_uint8_t num, gate_bool_t uppercase) |
Prints a byte as a hexadecimal number of 2 characters. | |
GATE_CORE_API gate_size_t | gate_str_print_hex_num (gate_char8_t *dst, gate_size_t dstlen, gate_uint64_t num, gate_bool_t uppercase) |
Prints a number as a hexadecimal number without leading zeros. | |
GATE_CORE_API gate_size_t | gate_str_print_hex_uint16 (gate_char8_t *dst, gate_size_t dstlen, gate_uint16_t num, gate_bool_t uppercase) |
Prints a 16-bit number as a hexadecimal number of 4 characters. | |
GATE_CORE_API gate_size_t | gate_str_print_hex_uint32 (gate_char8_t *dst, gate_size_t dstlen, gate_uint32_t num, gate_bool_t uppercase) |
Prints a 32-bit number as a hexadecimal number of 8 characters. | |
GATE_CORE_API gate_size_t | gate_str_print_hex_uint64 (gate_char8_t *dst, gate_size_t dstlen, gate_uint64_t num, gate_bool_t uppercase) |
Prints a 64-bit number as a hexadecimal number of 16 characters. | |
GATE_CORE_API gate_size_t | gate_str_print_hex_buffer (gate_char8_t *dst, gate_size_t dstlen, void const *buffer, gate_size_t bufferlen, gate_bool_t uppercase) |
Prints a binary buffer as a hexadecimal number representation. | |
GATE_CORE_API gate_size_t | gate_str_print_hex (gate_char8_t *dst, gate_size_t dstlen, gate_uint64_t num, gate_size_t numlen, gate_bool_t uppercase) |
Prints a number as a hexadecimal number. | |
GATE_CORE_API gate_size_t | gate_str_print_to (gate_str_printer_t printer, void *printer_param, va_list arg) |
Prints pairs of (type + parameter) arguments using a user defined printer function. | |
GATE_CORE_API gate_size_t | gate_str_print (gate_char8_t *dst, gate_size_t dstlen,...) |
Prints pairs of (type + parameter) arguments into a destination string buffer. | |
GATE_CORE_API gate_size_t | gate_str_print_values (gate_char8_t *dst, gate_size_t dstlen, gate_print_value_t const *values, gate_size_t values_count) |
Prints an array of type + parameter arguments into a destination string buffer. | |
GATE_CORE_API gate_bool_t | gate_str_parse_digit (gate_char8_t const *src, gate_uint8_t *digit) |
Parses a string for a digit character. | |
GATE_CORE_API gate_size_t | gate_str_parse_bool (gate_char8_t const *src, gate_size_t srclen, gate_bool_t *value) |
Parses a string for a boolean value. | |
GATE_CORE_API gate_size_t | gate_str_parse_uint64 (gate_char8_t const *src, gate_size_t srclen, gate_uint64_t *num) |
Parses a string for an unsigned 64-bit decimal integer value. | |
GATE_CORE_API gate_size_t | gate_str_parse_int64 (gate_char8_t const *src, gate_size_t srclen, gate_int64_t *num) |
Parses a string for a signed 64-bit decimal integer value. | |
GATE_CORE_API gate_size_t | gate_str_parse_real (gate_char8_t const *src, gate_size_t srclen, gate_real64_t *num) |
Parses a string for 64-bit floating point decimal integer value. | |
GATE_CORE_API gate_bool_t | gate_str_parse_hex_nibble (gate_char8_t chr, gate_uint8_t *value) |
Parses a character for a hexadecimal nibble (0-9)|(a-f) | |
GATE_CORE_API gate_bool_t | gate_str_parse_hex_byte (gate_char8_t const chr[2], gate_uint8_t *value) |
Parses a string for a a hexadecimal byte value value. | |
GATE_CORE_API gate_size_t | gate_str_parse_hex_int (gate_char8_t const *text, gate_size_t textlen, gate_uint64_t *num) |
Parses a string for an unsigned 64-bit hexadecimal integer value. | |
GATE_CORE_API gate_size_t | gate_str_parse_hex_buffer (gate_char8_t const *text, gate_size_t textlen, gate_char8_t *buffer, gate_size_t bufferlen) |
Parses a string for a hexadecimal number sequence into an output buffer. | |
GATE_CORE_API gate_bool_t | gate_str_parse_oct_byte (gate_char8_t const chr[3], gate_uint8_t *value) |
Parses a string for a octal number into a byte. | |
GATE_CORE_API gate_size_t | gate_str_parse_line (gate_char8_t const *text, gate_size_t textlen, gate_char8_t *buffer, gate_size_t *bufferlen) |
Parses a string for a full text line (until end-of-line character is detected) | |
GATE_CORE_API void | gate_strbuilder_create (gate_strbuilder_t *builder, gate_size_t capacity) |
Creates a string-builder instance and tries to preallocate memory for the requested capacity. | |
GATE_CORE_API void | gate_strbuilder_create_static (gate_strbuilder_t *builder, char *buffer, gate_size_t capacity, gate_size_t length_used) |
Creates a string-builder instance and binds it to a static (external) buffer. | |
GATE_CORE_API void | gate_strbuilder_release (gate_strbuilder_t *builder) |
Releases all allocated resources of a stringbuilder object. | |
GATE_CORE_API gate_size_t | gate_strbuilder_resize (gate_strbuilder_t *builder, gate_size_t sz) |
Tries to resize the internal buffer of a string builder. | |
GATE_CORE_API gate_size_t | gate_strbuilder_length (gate_strbuilder_t const *builder) |
Returns the currently used length of text in a string builder. | |
GATE_CORE_API gate_char8_t const * | gate_strbuilder_ptr (gate_strbuilder_t const *builder, gate_size_t charpos) |
Returns a pointer to the character within the string builder buffer at the given position. | |
GATE_CORE_API gate_size_t | gate_strbuilder_increase (gate_strbuilder_t *builder, gate_size_t sz) |
Tries to increase the allocated size of a string builder. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_text (gate_strbuilder_t *builder, gate_char8_t const *txt, gate_size_t txtlen) |
Appends the given character string at the end of the current string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_chars (gate_strbuilder_t *builder, gate_size_t char_count, char chr) |
Appends a single character multiple times at the end of the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_text16 (gate_strbuilder_t *builder, gate_char16_t const *txt, gate_size_t txtlen) |
Appends a UTF16 string to the string builder's buffer (by converting it to UTF-8) | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_text32 (gate_strbuilder_t *builder, gate_char32_t const *txt, gate_size_t txtlen) |
Appends a UTF32 string to the string builder's buffer (by converting it to UTF-8) | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_cstr (gate_strbuilder_t *builder, char const *txt) |
Appends a Null-terminated C-string to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_string (gate_strbuilder_t *builder, gate_string_t const *txt) |
Appends a copy of the given string object to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_int16 (gate_strbuilder_t *builder, gate_int16_t num) |
Appends a default string representation of the given 16-bit signed integer to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_uint16 (gate_strbuilder_t *builder, gate_uint16_t num) |
Appends a default string representation of the given 16-bit unsigned integer to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_int32 (gate_strbuilder_t *builder, gate_int32_t num) |
Appends a default string representation of the given 32-bit signed integer to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_uint32 (gate_strbuilder_t *builder, gate_uint32_t num) |
Appends a default string representation of the given 32-bit unsigned integer to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_int64 (gate_strbuilder_t *builder, gate_int64_t num) |
Appends a default string representation of the given 64-bit signed integer to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_uint64 (gate_strbuilder_t *builder, gate_uint64_t num) |
Appends a default string representation of the given 64-bit unsigned integer to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_real (gate_strbuilder_t *builder, gate_real64_t num, unsigned intlen, unsigned decimallen, unsigned grouplen) |
Appends a default string representation of the given floating point number to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append_hex (gate_strbuilder_t *builder, gate_uint8_t const *bytes, gate_size_t bytescount, gate_bool_t uppercase) |
Appends a hexadecimal representation of the given byte buffer to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_append (gate_strbuilder_t *builder,...) |
Appends GATE_PRINT_* typed values to the string builder's buffer. | |
GATE_CORE_API gate_size_t | gate_strbuilder_insert (gate_strbuilder_t *builder, gate_size_t pos, char const *txt, gate_size_t txtlen) |
Inserts the given characters into the string builder's buffer at a specific position. | |
GATE_CORE_API gate_size_t | gate_strbuilder_remove (gate_strbuilder_t *builder, gate_size_t pos, gate_size_t length) |
Removes bytes at the given position in the buffer, following bytes are moved forward. | |
GATE_CORE_API gate_cstrbuffer_t * | gate_cstrbuffer_create (gate_cstrbuffer_t *buffer, gate_char8_t const *textptr, gate_size_t length, gate_bool_t copy_needed) |
Creates a C-string buffer from a given string-range. | |
GATE_CORE_API gate_cstrbuffer_t * | gate_cstrbuffer_create_string (gate_cstrbuffer_t *buffer, gate_string_t const *strptr, gate_bool_t copy_needed) |
Creates a C-string buffer from a given string. | |
GATE_CORE_API void | gate_cstrbuffer_destroy (gate_cstrbuffer_t *buffer) |
Destroys C-string buffer (deallocates heap if used) | |
GATE_CORE_API gate_char8_t const * | gate_cstrbuffer_get (gate_cstrbuffer_t const *buffer) |
Returns a pointer to the buffered NUL-terminated string. | |
GATE_CORE_API gate_size_t | gate_cstrbuffer_length (gate_cstrbuffer_t const *buffer) |
Returns the length of the buffered string (not counting the NUL-terminator) | |
String management, UTF conversion and basic text parsing functions.
#define GATE_STR_NPOS GATE_INVALID_SIZE |
Invalid position indicator
#define GATE_PRINT_END ((int)0x00) |
end of print argument list
#define GATE_PRINT_CHAR ((int)0x01) |
print a single character
#define GATE_PRINT_NEWLINE ((int)0x02) |
send platform specific newline-characters
#define GATE_PRINT_CSTR ((int)0x03) |
print null terminated char array (char const*)
#define GATE_PRINT_STRING ((int)0x04) |
print content of gate_string_t
#define GATE_PRINT_CR ((int)0x05) |
print CR character
#define GATE_PRINT_LF ((int)0x06) |
print LF character
#define GATE_PRINT_CRLF ((int)0x07) |
print CR + LF characters
#define GATE_PRINT_BOOL ((int)0x10) |
print boolean content (true / false)
#define GATE_PRINT_I8 ((int)0x11) |
print signed 8 bit integer
#define GATE_PRINT_UI8 ((int)0x12) |
print unsigned 8 bit integer
#define GATE_PRINT_I16 ((int)0x13) |
print signed 16 bit integer
#define GATE_PRINT_UI16 ((int)0x14) |
print unsigned 16 bit integer
#define GATE_PRINT_I32 ((int)0x15) |
print signed 32 bit integer
#define GATE_PRINT_UI32 ((int)0x16) |
print unsigned 32 bit integer
#define GATE_PRINT_I64 ((int)0x17) |
print signed 64 bit integer
#define GATE_PRINT_UI64 ((int)0x18) |
print unsigned 64 bit integer
#define GATE_PRINT_H8 ((int)0x1a) |
print byte as 2 HEX chars
#define GATE_PRINT_H16 ((int)0x1b) |
print 16 bit word as 4 HEX chars
#define GATE_PRINT_H32 ((int)0x1c) |
print 32 bit dword as 8 HEX chars
#define GATE_PRINT_H64 ((int)0x1d) |
print 64 bit qword as 16 HEX chars
#define GATE_PRINT_R32 ((int)0x21) |
print 32 bit floating point number
#define GATE_PRINT_R64 ((int)0x22) |
print 64 bit floating point number
#define GATE_PRINT_ADDRESS ((int)0x23) |
print pointer address as HEX chars
typedef struct gate_stringbuffer8_class gate_stringbuffer8_t |
character (byte) string buffer class
The object is a reference-count managed, overallocated heap object Its data member as an "open array" of bytes
typedef struct gate_strbuilder8_class gate_strbuilder8_t |
character (byte) string builder class
Stringbuilders hold a stringbuffer and grow them if necessary (when the current capacity is reached)
typedef struct gate_string8_class gate_string8_t |
character (byte) string class
A string class holds a pointer to the first character of a constant (immutable) text string and the valid length. Strings are expected to be UTF-8 encoded but the encoding is not checked until conversion into other text-formats are performed. Strings need not to be null-terminated. If a string-buffer is attached, the content of the string is bound to the attached buffer. If no buffer is attached, the object points to a foreign region and its allocation must be ensured as long as the string object referres to it.
typedef struct gate_cstrbuffer8_class gate_cstrbuffer8_t |
C-string buffer class.
GATE strings need not to be NUL-terminated, but many C APIs require this convention. A C-string buffer takes a string pointer, and check it for NUL-termination. If it's NUL-terminated, it takes it as it is. Otherwise it checks the length and tries to copy it into a local buffer. If the local buffer is not big enough, a heap allocation is done to copy the string into it. At the end we get a string pointer that points to a NUL-terminated string.
GATE_CORE_API int gate_char_lowercase | ( | int | chr | ) |
Converts an ASCII character to its lower case.
chr | input ASCII character value |
GATE_CORE_API int gate_char_uppercase | ( | int | chr | ) |
Converts an ASCII character to its upper case.
chr | input ASCII character value |
GATE_CORE_API gate_bool_t gate_char_is_digit | ( | int | chr | ) |
Returns true, if the ASCII character is a digite '0' - '9'.
chr | input ASCII character value |
GATE_CORE_API gate_bool_t gate_char_is_whitespace | ( | int | chr | ) |
Returns true, if the ASCII character is a whitespace.
chr | input ASCII character value |
GATE_CORE_API gate_size_t gate_char_read_utf8 | ( | gate_char8_t const * | src, |
gate_size_t | srclen, | ||
gate_char32_t * | dst ) |
Reads an UTF-8 encoded byte sequence and decodes a single unicode character.
src | pointer to byte sequence |
srclen | total length of byte sequence |
dst | pointer to one output unicode character |
GATE_CORE_API gate_size_t gate_char_read_utf16 | ( | gate_char16_t const * | src, |
gate_size_t | srclen, | ||
gate_char32_t * | dst ) |
Reads an UTF-16 encoded sequence and decodes a single unicode character.
src | pointer to 16-bit word sequence |
srclen | total amount of 16-bit words in sequence |
dst | pointer to one output unicode character |
GATE_CORE_API gate_size_t gate_char_read_utf32 | ( | gate_char32_t const * | src, |
gate_size_t | srclen, | ||
gate_char32_t * | dst ) |
Reads an UTF-32 encoded byte sequence and decodes a single unicode character.
src | pointer to 32-bit word sequence |
srclen | total amount of 32-bit words in sequence |
dst | pointer to one output unicode character |
GATE_CORE_API gate_size_t gate_char_write_utf8 | ( | gate_char32_t | src, |
gate_char8_t * | dst, | ||
gate_size_t | dstlen ) |
Encodes one unicode character into an UTF-8 byte buffer.
src | one unicode character to encode |
dst | pointer to allocated output buffer that receives an UTF-8 character sequence |
dstlen | size of output buffer in bytes |
GATE_CORE_API gate_size_t gate_char_write_utf16 | ( | gate_char32_t | src, |
gate_char16_t * | dst, | ||
gate_size_t | dstlen ) |
Encodes one unicode character into an UTF-16 word buffer.
src | one unicode character to encode |
dst | pointer to allocated output buffer that receives an UTF-16 character sequence |
dstlen | size of output buffer in 16-bit words |
GATE_CORE_API gate_size_t gate_char_write_utf32 | ( | gate_char32_t | src, |
gate_char32_t * | dst, | ||
gate_size_t | dstlen ) |
Encodes one unicode character into an UTF-32 word buffer.
src | one unicode character to encode |
dst | pointer to allocated output buffer that receives an UTF-32 character sequence |
dstlen | size of output buffer in 32-bit words |
GATE_CORE_API gate_size_t gate_str_utf8_2_utf16 | ( | gate_char8_t const * | src, |
gate_size_t | srclen, | ||
gate_char16_t * | dst, | ||
gate_size_t | dstlen ) |
Converts an UTF-8 input buffer into an UTF-16 output buffer.
src | pointer to first byte in UTF-8 input buffer |
srclen | length of bytes in UTF-8 input buffer |
dst | pointer to first word in UTF-16 output buffer |
dstlen | length of UTF-16 output buffer in 16-bit words |
GATE_CORE_API gate_size_t gate_str_utf8_2_utf32 | ( | gate_char8_t const * | src, |
gate_size_t | srclen, | ||
gate_char32_t * | dst, | ||
gate_size_t | dstlen ) |
Converts an UTF-8 input buffer into an UTF-32 output buffer.
src | pointer to first byte in UTF-8 input buffer |
srclen | length of bytes in UTF-8 input buffer |
dst | pointer to first word in UTF-32 output buffer |
dstlen | length of UTF-32 output buffer in 32-bit words |
GATE_CORE_API gate_size_t gate_str_utf16_2_utf8 | ( | gate_char16_t const * | src, |
gate_size_t | srclen, | ||
gate_char8_t * | dst, | ||
gate_size_t | dstlen ) |
Converts an UTF-16 input buffer into an UTF-8 output buffer.
src | pointer to first 16-bit word in UTF-16 input buffer |
srclen | length of 16-bit words in UTF-16 input buffer |
dst | pointer to first byte in UTF-8 output buffer |
dstlen | length of UTF-8 output buffer in bytes |
GATE_CORE_API gate_size_t gate_str_utf16_2_utf32 | ( | gate_char16_t const * | src, |
gate_size_t | srclen, | ||
gate_char32_t * | dst, | ||
gate_size_t | dstlen ) |
Converts an UTF-16 input buffer into an UTF-32 output buffer.
src | pointer to first 16-bit word in UTF-16 input buffer |
srclen | length of 16-bit words in UTF-16 input buffer |
dst | pointer to first 32-bit word in UTF-32 output buffer |
dstlen | length of UTF-32 output buffer in 32-bit words |
GATE_CORE_API gate_size_t gate_str_utf32_2_utf8 | ( | gate_char32_t const * | src, |
gate_size_t | srclen, | ||
gate_char8_t * | dst, | ||
gate_size_t | dstlen ) |
Converts an UTF-32 input buffer into an UTF-8 output buffer.
src | pointer to first 32-bit word in UTF-32 input buffer |
srclen | length of 32-bit words in UTF-32 input buffer |
dst | pointer to first byte in UTF-8 output buffer |
dstlen | length of UTF-8 output buffer in bytes |
GATE_CORE_API gate_size_t gate_str_utf32_2_utf16 | ( | gate_char32_t const * | src, |
gate_size_t | srclen, | ||
gate_char16_t * | dst, | ||
gate_size_t | dstlen ) |
Converts an UTF-32 input buffer into an UTF-16 output buffer.
src | pointer to first 32-bit word in UTF-32 input buffer |
srclen | length of 32-bit words in UTF-32 input buffer |
dst | pointer to first 16-bit word in UTF-16 output buffer |
dstlen | length of UTF-16 output buffer in 16-bit words |
GATE_CORE_API gate_size_t gate_str_length | ( | gate_char8_t const * | src | ) |
Returns the length of a NULL-terminated character string.
src | pointer to first character in string |
GATE_CORE_API gate_size_t gate_str_length_max | ( | gate_char8_t const * | src, |
gate_size_t | capacity ) |
Returns the length of a NULL-terminated character string with a limited capacity.
src | pointer to first character in string |
capacity | maximum allocated space of string |
GATE_CORE_API gate_bool_t gate_str_is_empty | ( | gate_char8_t const * | src | ) |
Returns true if the given character string is emptry.
src | pointer to first character in string |
GATE_CORE_API int gate_str_comp_range | ( | gate_char8_t const * | str1, |
gate_char8_t const * | str2, | ||
gate_size_t | len ) |
Compares two string ranges of equal size by their byte values.
str1 | pointer to first byte in first string |
str2 | pointer to first byte in second string |
len | length of both strings in bytes |
GATE_CORE_API int gate_str_comp_range_ic | ( | gate_char8_t const * | str1, |
gate_char8_t const * | str2, | ||
gate_size_t | len ) |
Compares two string ranges of equal size by their byte values and treats all ASCII values as lower-case.
str1 | pointer to first byte in first string |
str2 | pointer to first byte in second string |
len | length of both strings in bytes |
GATE_CORE_API void gate_str_to_lower | ( | gate_char8_t * | str, |
gate_size_t | len ) |
Converts all ASCII characters in a string to their lower-case counterparts.
str | pointer to first character in string |
len | length of string |
GATE_CORE_API void gate_str_to_upper | ( | gate_char8_t * | str, |
gate_size_t | len ) |
Converts all ASCII characters in a string to their upper-case counterparts.
str | pointer to first character in string |
len | length of string |
GATE_CORE_API void gate_str_reverse | ( | gate_char8_t * | str, |
gate_size_t | len ) |
Reverses the bytes sequence of a string (first <-> last)
str | pointer to first character in string |
len | length of string |
GATE_CORE_API gate_size_t gate_str_char_pos | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t | find, | ||
gate_size_t | startat ) |
Searches for the first occurance of a character in a string.
str | pointer to first character in string |
len | length of string |
find | character value to search for |
startat | character offset in string where search starts |
GATE_CORE_API gate_size_t gate_str_char_pos_last | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t | find ) |
Searches for the last occurance of a character in a string.
str | pointer to first character in string |
len | length of string |
find | character value to search for |
GATE_CORE_API gate_size_t gate_str_pos | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | find, | ||
gate_size_t | findlen, | ||
gate_size_t | startat ) |
Searches for the first occurance of a sub-string in a string.
str | pointer to first character in string |
len | length of string |
find | pointer to first character in sub-string token to search for |
findlen | length of sub-string token to search for |
startat | character offset in string where search starts |
GATE_CORE_API gate_size_t gate_str_count_chars | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t | chr ) |
Counts the amount of given character in a string.
[in] | str | pointer to first character in first string |
[in] | len | Length of the string in bytes |
[in] | chr | Character to be counted |
GATE_CORE_API int gate_str_comp | ( | gate_char8_t const * | str1, |
gate_char8_t const * | str2 ) |
Compares two NULL-terminated strings.
str1 | pointer to first character in first string |
str2 | pointer to first character in second string |
GATE_CORE_API int gate_str_comp_ic | ( | gate_char8_t const * | str1, |
gate_char8_t const * | str2 ) |
Compares two NULL-terminated strings and compare characters case insensitive.
str1 | pointer to first character in first string |
str2 | pointer to first character in second string |
GATE_CORE_API int gate_str_compare | ( | gate_char8_t const * | str1, |
gate_size_t | len1, | ||
gate_char8_t const * | str2, | ||
gate_size_t | len2 ) |
Compares two strings including their byte lengths.
str1 | pointer to first character in first string |
len1 | length in bytes of str1 |
str2 | pointer to first character in second string |
len2 | length in bytes of str2 |
GATE_CORE_API int gate_str_compare_ic | ( | gate_char8_t const * | str1, |
gate_size_t | len1, | ||
gate_char8_t const * | str2, | ||
gate_size_t | len2 ) |
Compares two strings including their byte lengths and compare characters case insensitive.
str1 | pointer to first character in first string |
len1 | length in bytes of str1 |
str2 | pointer to first character in second string |
len2 | length in bytes of str2 |
GATE_CORE_API gate_size_t gate_str_is_numeric | ( | gate_char8_t const * | str, |
gate_size_t | len ) |
Checks the content of the string and returns the amount of consecutive digits.
str | pointer to character string |
len | length of string in bytes |
GATE_CORE_API gate_bool_t gate_str_starts_with | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | starttoken, | ||
gate_size_t | startlen ) |
Detects if a string starts with the content of another string exactly.
str | pointer to string to be analyzed |
len | length of text in str in bytes |
starttoken | pointer to string with expected start token |
startlen | length of text in starttoken in bytes |
GATE_CORE_API gate_bool_t gate_str_ends_with | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | endtoken, | ||
gate_size_t | endlen ) |
Detects if a string ends with the content of another string exactly.
str | pointer to string to be analyzed |
len | length of text in str in bytes |
endtoken | pointer to string with expected end token |
endlen | length of text in endtoken in bytes |
GATE_CORE_API gate_bool_t gate_str_starts_with_ic | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | starttoken, | ||
gate_size_t | startlen ) |
Detects if a string starts with the content of another string by comparing case insensitive.
str | pointer to string to be analyzed |
len | length of text in str in bytes |
starttoken | pointer to string with expected start token |
startlen | length of text in starttoken in bytes |
GATE_CORE_API gate_bool_t gate_str_ends_with_ic | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | endtoken, | ||
gate_size_t | endlen ) |
Detects if a string ends with the content of another string by comparing case insensitive.
str | pointer to string to be analyzed |
len | length of text in str in bytes |
endtoken | pointer to string with expected end token |
endlen | length of text in endtoken in bytes |
GATE_CORE_API gate_size_t gate_str_print_text | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_char8_t const * | txt, | ||
gate_size_t | txtlen ) |
Prints the text content of a 8-bit encoded string into a destination string buffer.
A null-terminator will be appended in the buffer, but it is not counted
dst | pointer to destination buffer to be filled |
dstlen | byte capacity of destination buffer |
txt | pointer to first character in text to be printed into buffer |
txtlen | byte length of string in txt to be printed |
GATE_CORE_API gate_size_t gate_str_print_wtext | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
wchar_t const * | txt, | ||
gate_size_t | txtlen ) |
Prints the text content of a wide string into a destination string buffer.
A null-terminator will be appended in the buffer, but it is not counted
dst | pointer to destination buffer to be filled |
dstlen | byte capacity of destination buffer |
txt | pointer to first character in text to be printed into buffer |
txtlen | amount of wide-characters in the text to be printed |
GATE_CORE_API gate_size_t gate_str_print_uint | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_uint64_t | num, | ||
gate_size_t | intlen ) |
Prints a unsigned integer as a decimal number into a destination string buffer.
A null-terminator will be appended in the buffer, but it is not counted
dst | pointer to destination buffer to be filled |
dstlen | byte capacity of destination buffer |
num | unsigned integer to be printed |
intlen | fixed length of size, 0: means free length, length < intlen: leading zeros are added, length > intlen: leading digits are cut off |
GATE_CORE_API gate_size_t gate_str_print_real | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_real64_t | num, | ||
unsigned | intlen, | ||
unsigned | decimallen, | ||
unsigned | grouplen ) |
Prints a floating point number into a destination string buffer.
A null-terminator will be appended in the buffer, but it is not counted
[out] | dst | pointer to destination buffer to be filled |
[in] | dstlen | byte capacity of destination buffer |
[in] | num | floating point value to be printed |
[in] | intlen | fixed length of size, 0: means free length, length < intlen: leading zeros are added, length > intlen: leading digits are cut off |
[in] | decimallen | maximum amount of post-comma digits, zero prints as much as possible |
[in] | grouplen | length of digits in a group (some cultures use 3 to separate 1000 steps), zero disables grouping |
GATE_CORE_API gate_bool_t gate_str_like | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | like, | ||
gate_size_t | likelen ) |
Evaluates if a string matches a simple wildcard pattern.
Wildcard patterns are "*" or "?", e.g. "Hello World" would match the pattern "He??o W*d"
[in] | str | Pointer to string to be evaluated |
[in] | len | Length of str in bytes |
[in] | like | Pointer to string with pattern |
[in] | likelen | Length of like in bytes |
str
matches the pattern in like
GATE_CORE_API gate_bool_t gate_str_like_one_of | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | like, | ||
gate_size_t | likelen, | ||
gate_char8_t | like_separator ) |
Evaluates if a string matches one of a group of wildcard patterns.
Patterns are provided in one string, a separator character cuts their the group into separate patterns
[in] | str | Pointer to string to be evaluated |
[in] | len | Length of str in bytes |
[in] | like | Pointer to string with multiple patterns |
[in] | likelen | Length of like in bytes |
[in] | like_separator | Character used to cut like into pieces |
str
matches at least on of the patterns in like
GATE_CORE_API gate_size_t gate_str_find_first_of | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | chars, | ||
gate_size_t | charcount, | ||
gate_size_t | startat ) |
Finds the first byte position of one match of some characters in a string.
[in] | str | Pointer to string to be evaluated |
[in] | len | Length of str in bytes |
[in] | chars | Pointer to array of characters to search |
[in] | charcount | Count of characters in chars |
[in] | startat | Offset in string to start search |
str
matchting chars
, or GATE_STR_NPOS if no character was found GATE_CORE_API gate_size_t gate_str_find_first_not_of | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | chars, | ||
gate_size_t | charcount, | ||
gate_size_t | startat ) |
Finds the first byte position of a character not matching a list of characters.
[in] | str | Pointer to string to be evaluated |
[in] | len | Length of str in bytes |
[in] | chars | Pointer to array of characters to search |
[in] | charcount | Count of characters in chars |
[in] | startat | Offset in string to start search |
str
NOT matching chars
, or GATE_STR_NPOS if all characters are matching GATE_CORE_API gate_size_t gate_str_find_last_of | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | chars, | ||
gate_size_t | charcount ) |
Finds the last byte position of one match of some characters in a string.
[in] | str | Pointer to string to be evaluated |
[in] | len | Length of str in bytes |
[in] | chars | Pointer to array of characters to search |
[in] | charcount | Count of characters in chars |
str
matchting chars
(reverse search), or GATE_STR_NPOS if no character was found GATE_CORE_API gate_size_t gate_str_find_last_not_of | ( | gate_char8_t const * | str, |
gate_size_t | len, | ||
gate_char8_t const * | chars, | ||
gate_size_t | charcount ) |
Finds the last byte position of a character not matching a list of characters.
[in] | str | Pointer to string to be evaluated |
[in] | len | Length of str in bytes |
[in] | chars | Pointer to array of characters to search |
[in] | charcount | Count of characters in chars |
str
NOT matching chars
(reverse search), or GATE_STR_NPOS if all characters are matching GATE_CORE_API gate_uint32_t gate_str_hash | ( | gate_char8_t const * | str, |
gate_size_t | len ) |
Calculates a hash value over the content of the given string bytes.
[in] | str | Pointer to string to be evaluated |
[in] | len | Length of str in bytes |
GATE_CORE_API gate_size_t gate_str_replace | ( | gate_char8_t * | str, |
gate_size_t | len, | ||
gate_char8_t | find, | ||
gate_char8_t | replace ) |
Replaces all occurances of a character in a string with another character.
[in] | str | Pointer to string to be updated |
[in] | len | Length of str in bytes |
[in] | find | Character to be searched for |
[in] | replace | Character to replace all found characters of value find |
GATE_CORE_API gate_size_t gate_str_print_int16 | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_int16_t | num ) |
Prints a 16 bit signed integer into a destination string buffer.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | integer to be printed |
dst
GATE_CORE_API gate_size_t gate_str_print_uint16 | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_uint16_t | num ) |
Prints a 16 bit unsigned signed integer into a destination string buffer.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | integer to be printed |
dst
GATE_CORE_API gate_size_t gate_str_print_int32 | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_int32_t | num ) |
Prints a 32 bit signed integer into a destination string buffer.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | integer to be printed |
dst
GATE_CORE_API gate_size_t gate_str_print_uint32 | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_uint32_t | num ) |
Prints a 32 bit unsigned integer into a destination string buffer.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | integer to be printed |
dst
GATE_CORE_API gate_size_t gate_str_print_int64 | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_int64_t | num ) |
Prints a 64 bit signed integer into a destination string buffer.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | integer to be printed |
dst
GATE_CORE_API gate_size_t gate_str_print_uint64 | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_uint64_t | num ) |
Prints a 64 bit unsigned integer into a destination string buffer.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | integer to be printed |
dst
GATE_CORE_API gate_char8_t gate_str_print_hex_nibble | ( | gate_uint8_t | nibble, |
gate_bool_t | uppercase ) |
Prints a 4-bit number (nibble) into a hexadecimal character.
[in] | nibble | 4-bit unsigned number to be printed |
[in] | uppercase | true prints letters in upper case, otherwise lower case |
GATE_CORE_API gate_size_t gate_str_print_hex_byte | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_uint8_t | num, | ||
gate_bool_t | uppercase ) |
Prints a byte as a hexadecimal number of 2 characters.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | number to be printed |
[in] | uppercase | if true, uses upper case letters (A-F), otherwise lower case (a-f) |
dst
GATE_CORE_API gate_size_t gate_str_print_hex_num | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_uint64_t | num, | ||
gate_bool_t | uppercase ) |
Prints a number as a hexadecimal number without leading zeros.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | number to be printed |
[in] | uppercase | if true, uses upper case letters (A-F), otherwise lower case (a-f) |
dst
GATE_CORE_API gate_size_t gate_str_print_hex_uint16 | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_uint16_t | num, | ||
gate_bool_t | uppercase ) |
Prints a 16-bit number as a hexadecimal number of 4 characters.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | number to be printed |
[in] | uppercase | if true, uses upper case letters (A-F), otherwise lower case (a-f) |
dst
GATE_CORE_API gate_size_t gate_str_print_hex_uint32 | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_uint32_t | num, | ||
gate_bool_t | uppercase ) |
Prints a 32-bit number as a hexadecimal number of 8 characters.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | number to be printed |
[in] | uppercase | if true, uses upper case letters (A-F), otherwise lower case (a-f) |
dst
GATE_CORE_API gate_size_t gate_str_print_hex_uint64 | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_uint64_t | num, | ||
gate_bool_t | uppercase ) |
Prints a 64-bit number as a hexadecimal number of 16 characters.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | number to be printed |
[in] | uppercase | if true, uses upper case letters (A-F), otherwise lower case (a-f) |
dst
GATE_CORE_API gate_size_t gate_str_print_hex_buffer | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
void const * | buffer, | ||
gate_size_t | bufferlen, | ||
gate_bool_t | uppercase ) |
Prints a binary buffer as a hexadecimal number representation.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | buffer | Source buffer thats bytes are printed |
[in] | bufferlen | Length of buffer in bytes |
[in] | uppercase | if true, uses upper case letters (A-F), otherwise lower case (a-f) |
dst
GATE_CORE_API gate_size_t gate_str_print_hex | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_uint64_t | num, | ||
gate_size_t | numlen, | ||
gate_bool_t | uppercase ) |
Prints a number as a hexadecimal number.
[out] | dst | Pointer to string to be updated |
[in] | dstlen | Capacity of buffer in str in bytes |
[in] | num | number to be printed |
[in] | numlen | amount of bytes to be printed in target buffer (length limit, using leading zeros when required) |
[in] | uppercase | if true, uses upper case letters (A-F), otherwise lower case (a-f) |
dst
GATE_CORE_API gate_size_t gate_str_print_to | ( | gate_str_printer_t | printer, |
void * | printer_param, | ||
va_list | arg ) |
Prints pairs of (type + parameter) arguments using a user defined printer function.
[in] | printer | Pointer to printer-function that receives strings to print |
[in] | printer_param | User parameter handed over to printer function |
[in] | arg | va_list arguments containing pairs of GATE_PRINT_* integers + data types |
GATE_CORE_API gate_size_t gate_str_print | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
... ) |
Prints pairs of (type + parameter) arguments into a destination string buffer.
[in] | dst | Pointer to destination string where output is printed to |
[in] | dstlen | Capacity of destination string buffer dst |
GATE_CORE_API gate_size_t gate_str_print_values | ( | gate_char8_t * | dst, |
gate_size_t | dstlen, | ||
gate_print_value_t const * | values, | ||
gate_size_t | values_count ) |
Prints an array of type + parameter arguments into a destination string buffer.
[out] | dst | Pointer to destination string where output is printed to |
[in] | dstlen | Capacity of destination string buffer dst |
[in] | values | Pointer to first gate_print_value_t structure in an array |
[in] | values_count | Amount of gate_print_value_t structures in array |
GATE_CORE_API gate_bool_t gate_str_parse_digit | ( | gate_char8_t const * | src, |
gate_uint8_t * | digit ) |
Parses a string for a digit character.
[in] | src | Pointer to printer-function that receives strings to print |
[out] | digit | User parameter handed over to printer function |
GATE_CORE_API gate_size_t gate_str_parse_bool | ( | gate_char8_t const * | src, |
gate_size_t | srclen, | ||
gate_bool_t * | value ) |
Parses a string for a boolean value.
Supported values are "true", "false", "on", "off", "yes", "no", "1", "0"
[in] | src | Pointer to string to be parsed |
[in] | srclen | Length of src in bytes |
[out] | value | Pointer to ouput value filled with parsing result |
GATE_CORE_API gate_size_t gate_str_parse_uint64 | ( | gate_char8_t const * | src, |
gate_size_t | srclen, | ||
gate_uint64_t * | num ) |
Parses a string for an unsigned 64-bit decimal integer value.
[in] | src | Pointer to string to be parsed |
[in] | srclen | Length of src in bytes |
[out] | num | Pointer to ouput value filled with parsing result |
GATE_CORE_API gate_size_t gate_str_parse_int64 | ( | gate_char8_t const * | src, |
gate_size_t | srclen, | ||
gate_int64_t * | num ) |
Parses a string for a signed 64-bit decimal integer value.
[in] | src | Pointer to string to be parsed |
[in] | srclen | Length of src in bytes |
[out] | num | Pointer to ouput value filled with parsing result |
GATE_CORE_API gate_size_t gate_str_parse_real | ( | gate_char8_t const * | src, |
gate_size_t | srclen, | ||
gate_real64_t * | num ) |
Parses a string for 64-bit floating point decimal integer value.
[in] | src | Pointer to string to be parsed |
[in] | srclen | Length of src in bytes |
[out] | num | Pointer to ouput value filled with parsing result |
GATE_CORE_API gate_bool_t gate_str_parse_hex_nibble | ( | gate_char8_t | chr, |
gate_uint8_t * | value ) |
Parses a character for a hexadecimal nibble (0-9)|(a-f)
[in] | chr | Character to be parsed |
[out] | value | Pointer to ouput value filled with parsing result |
GATE_CORE_API gate_bool_t gate_str_parse_hex_byte | ( | gate_char8_t const | chr[2], |
gate_uint8_t * | value ) |
Parses a string for a a hexadecimal byte value value.
[in] | chr | Pointer to 2-bytes string |
[out] | value | Pointer to ouput value filled with parsing result |
GATE_CORE_API gate_size_t gate_str_parse_hex_int | ( | gate_char8_t const * | text, |
gate_size_t | textlen, | ||
gate_uint64_t * | num ) |
Parses a string for an unsigned 64-bit hexadecimal integer value.
[in] | text | Pointer to string to be parsed |
[in] | textlen | Length of text in bytes |
[out] | num | Pointer to ouput value filled with parsing result |
GATE_CORE_API gate_size_t gate_str_parse_hex_buffer | ( | gate_char8_t const * | text, |
gate_size_t | textlen, | ||
gate_char8_t * | buffer, | ||
gate_size_t | bufferlen ) |
Parses a string for a hexadecimal number sequence into an output buffer.
[in] | text | Pointer to string to be parsed |
[in] | textlen | Length of text in bytes |
[out] | buffer | Pointer to ouput value filled with parsing result |
[in] | bufferlen | Capacity of buffer |
GATE_CORE_API gate_bool_t gate_str_parse_oct_byte | ( | gate_char8_t const | chr[3], |
gate_uint8_t * | value ) |
Parses a string for a octal number into a byte.
[in] | chr | 3-character string to be parsed |
[out] | value | Pointer to ouput value filled with parsing result |
GATE_CORE_API gate_size_t gate_str_parse_line | ( | gate_char8_t const * | text, |
gate_size_t | textlen, | ||
gate_char8_t * | buffer, | ||
gate_size_t * | bufferlen ) |
Parses a string for a full text line (until end-of-line character is detected)
[in] | text | Pointer to string to be parsed |
[in] | textlen | Length of text in bytes |
[out] | buffer | Pointer to ouput buffer filled with parsed line content |
[in,out] | bufferlen | Pointer to size of buffer , updated with amout of used bytes after parsing (not including line-ending characters) |
GATE_CORE_API void gate_strbuilder_create | ( | gate_strbuilder_t * | builder, |
gate_size_t | capacity ) |
Creates a string-builder instance and tries to preallocate memory for the requested capacity.
If capacity allocation fails, string-builder starts with an empty buffer, no error is generated
[out] | builder | Pointer to string-builder to be initialized |
[in] | capacity | Amount of bytes of preallocated buffer capacity in string-builder |
GATE_CORE_API void gate_strbuilder_create_static | ( | gate_strbuilder_t * | builder, |
char * | buffer, | ||
gate_size_t | capacity, | ||
gate_size_t | length_used ) |
Creates a string-builder instance and binds it to a static (external) buffer.
A static string builder cannot grow over the size of the given external buffer
[out] | builder | Pointer to string-builder to be initialized |
[in] | buffer | External buffer to be used within string-builder |
[in] | capacity | Total capacity of buffer |
[in] | length_used | Length of bytes in buffer that are already valid as a string |
GATE_CORE_API void gate_strbuilder_release | ( | gate_strbuilder_t * | builder | ) |
Releases all allocated resources of a stringbuilder object.
[in] | builder | Pointer to string-builder to be released |
GATE_CORE_API gate_size_t gate_strbuilder_resize | ( | gate_strbuilder_t * | builder, |
gate_size_t | sz ) |
Tries to resize the internal buffer of a string builder.
[in] | builder | Pointer to string-builder to be accessed |
[in] | sz | Size in bytes of requested new size |
builder
, or 0 in case of an error GATE_CORE_API gate_size_t gate_strbuilder_length | ( | gate_strbuilder_t const * | builder | ) |
Returns the currently used length of text in a string builder.
[in] | builder | Pointer to string-builder to be accessed |
GATE_CORE_API gate_char8_t const * gate_strbuilder_ptr | ( | gate_strbuilder_t const * | builder, |
gate_size_t | charpos ) |
Returns a pointer to the character within the string builder buffer at the given position.
[in] | builder | Pointer to string-builder to be accessed |
[in] | charpos | Position of character to be accessed |
charpos
is out of range. GATE_CORE_API gate_size_t gate_strbuilder_increase | ( | gate_strbuilder_t * | builder, |
gate_size_t | sz ) |
Tries to increase the allocated size of a string builder.
[in] | builder | Pointer to string-builder to be accessed |
[in] | sz | Amount of bytes to increase the internal buffer size |
GATE_CORE_API gate_size_t gate_strbuilder_append_text | ( | gate_strbuilder_t * | builder, |
gate_char8_t const * | txt, | ||
gate_size_t | txtlen ) |
Appends the given character string at the end of the current string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | txt | Pointer to first character of string to add |
[in] | txtlen | Length of string to add |
GATE_CORE_API gate_size_t gate_strbuilder_append_chars | ( | gate_strbuilder_t * | builder, |
gate_size_t | char_count, | ||
char | chr ) |
Appends a single character multiple times at the end of the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | char_count | Character to be added |
[in] | chr | Amount of repeats the character is added |
GATE_CORE_API gate_size_t gate_strbuilder_append_text16 | ( | gate_strbuilder_t * | builder, |
gate_char16_t const * | txt, | ||
gate_size_t | txtlen ) |
Appends a UTF16 string to the string builder's buffer (by converting it to UTF-8)
[in] | builder | Pointer to string-builder to be accessed |
[in] | txt | Pointer to UTF-16 input string |
[in] | txtlen | Lenght of UTF-16 string in 16-bit words-count |
GATE_CORE_API gate_size_t gate_strbuilder_append_text32 | ( | gate_strbuilder_t * | builder, |
gate_char32_t const * | txt, | ||
gate_size_t | txtlen ) |
Appends a UTF32 string to the string builder's buffer (by converting it to UTF-8)
[in] | builder | Pointer to string-builder to be accessed |
[in] | txt | Pointer to UTF-32 input string |
[in] | txtlen | Lenght of UTF-32 string in 32-bit words |
GATE_CORE_API gate_size_t gate_strbuilder_append_cstr | ( | gate_strbuilder_t * | builder, |
char const * | txt ) |
Appends a Null-terminated C-string to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | txt | Pointer to C-string to be added |
GATE_CORE_API gate_size_t gate_strbuilder_append_string | ( | gate_strbuilder_t * | builder, |
gate_string_t const * | txt ) |
Appends a copy of the given string object to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | txt | Pointer to the gate-string object to be added |
GATE_CORE_API gate_size_t gate_strbuilder_append_int16 | ( | gate_strbuilder_t * | builder, |
gate_int16_t | num ) |
Appends a default string representation of the given 16-bit signed integer to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | num | Numeric value to be added |
GATE_CORE_API gate_size_t gate_strbuilder_append_uint16 | ( | gate_strbuilder_t * | builder, |
gate_uint16_t | num ) |
Appends a default string representation of the given 16-bit unsigned integer to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | num | Numeric value to be added |
GATE_CORE_API gate_size_t gate_strbuilder_append_int32 | ( | gate_strbuilder_t * | builder, |
gate_int32_t | num ) |
Appends a default string representation of the given 32-bit signed integer to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | num | Numeric value to be added |
GATE_CORE_API gate_size_t gate_strbuilder_append_uint32 | ( | gate_strbuilder_t * | builder, |
gate_uint32_t | num ) |
Appends a default string representation of the given 32-bit unsigned integer to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | num | Numeric value to be added |
GATE_CORE_API gate_size_t gate_strbuilder_append_int64 | ( | gate_strbuilder_t * | builder, |
gate_int64_t | num ) |
Appends a default string representation of the given 64-bit signed integer to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | num | Numeric value to be added |
GATE_CORE_API gate_size_t gate_strbuilder_append_uint64 | ( | gate_strbuilder_t * | builder, |
gate_uint64_t | num ) |
Appends a default string representation of the given 64-bit unsigned integer to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | num | Numeric value to be added |
GATE_CORE_API gate_size_t gate_strbuilder_append_real | ( | gate_strbuilder_t * | builder, |
gate_real64_t | num, | ||
unsigned | intlen, | ||
unsigned | decimallen, | ||
unsigned | grouplen ) |
Appends a default string representation of the given floating point number to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | num | Floating point value to be added |
[in] | intlen | Maximum character length of integer digits to be added, 0 adds as much as neccessary |
[in] | decimallen | Maximum character length of decimal digits to be added, 0 adds as much as ncecssary |
[in] | grouplen | Optional digit group length, if != 0 a digit-group-separator character is added before/after every Nth digit |
GATE_CORE_API gate_size_t gate_strbuilder_append_hex | ( | gate_strbuilder_t * | builder, |
gate_uint8_t const * | bytes, | ||
gate_size_t | bytescount, | ||
gate_bool_t | uppercase ) |
Appends a hexadecimal representation of the given byte buffer to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | bytes | Pointer to first byte in the buffer thats content is added as HEX string |
[in] | bytescount | Amount of bytes in the buffer to be added |
[in] | uppercase | true adds hex characters uppercase, false adds lower case values |
GATE_CORE_API gate_size_t gate_strbuilder_append | ( | gate_strbuilder_t * | builder, |
... ) |
Appends GATE_PRINT_* typed values to the string builder's buffer.
[in] | builder | Pointer to string-builder to be accessed |
[in] | type_1 | 1-st GATE_PRINT_* type id |
[in] | value_1 | value or pointer of 1-st content, identified by GATE_PRINT_* |
[in] | type_N | n-th GATE_PRINT_* type id |
[in] | value_N | value or pointer of n-th content, identified by GATE_PRINT_* |
[in] | terminator | Final type-id with value GATE_PRINT_END to signal end of parameters. |
GATE_CORE_API gate_size_t gate_strbuilder_insert | ( | gate_strbuilder_t * | builder, |
gate_size_t | pos, | ||
char const * | txt, | ||
gate_size_t | txtlen ) |
Inserts the given characters into the string builder's buffer at a specific position.
[in] | builder | Pointer to string-builder to be accessed |
[in] | pos | Byte position, where the string should be inserted, existing characters are move backwards |
[in] | txt | Pointer to first character of text to be inserted |
[in] | txtlen | Amount of character bytes to be inserted |
GATE_CORE_API gate_size_t gate_strbuilder_remove | ( | gate_strbuilder_t * | builder, |
gate_size_t | pos, | ||
gate_size_t | length ) |
Removes bytes at the given position in the buffer, following bytes are moved forward.
[in] | builder | Pointer to string-builder to be accessed |
[in] | pos | Byte position, where character bytes should be removed |
[in] | length | Amount of character bytes to be removed |
GATE_CORE_API gate_cstrbuffer_t * gate_cstrbuffer_create | ( | gate_cstrbuffer_t * | buffer, |
gate_char8_t const * | textptr, | ||
gate_size_t | length, | ||
gate_bool_t | copy_needed ) |
Creates a C-string buffer from a given string-range.
[out] | buffer | Pointer to output cstrbuffer to be initialized |
[in] | textptr | Pointer to input string range to be integrated |
[in] | length | Length of input string |
[in] | copy_needed | Contents of source buffer is always copied into local or heap buffer |
GATE_CORE_API gate_cstrbuffer_t * gate_cstrbuffer_create_string | ( | gate_cstrbuffer_t * | buffer, |
gate_string_t const * | strptr, | ||
gate_bool_t | copy_needed ) |
Creates a C-string buffer from a given string.
[out] | buffer | Pointer to output cstrbuffer to be initialized |
[in] | strptr | Pointer to input string to be integrated |
[in] | copy_needed | Contents of source buffer is always copied into local or heap buffer |
GATE_CORE_API void gate_cstrbuffer_destroy | ( | gate_cstrbuffer_t * | buffer | ) |
Destroys C-string buffer (deallocates heap if used)
[in] | buffer | Pointer to c-string buffer to be destroyed |
GATE_CORE_API gate_char8_t const * gate_cstrbuffer_get | ( | gate_cstrbuffer_t const * | buffer | ) |
Returns a pointer to the buffered NUL-terminated string.
[in] | buffer | Pointer to buffer to be accessed |
GATE_CORE_API gate_size_t gate_cstrbuffer_length | ( | gate_cstrbuffer_t const * | buffer | ) |
Returns the length of the buffered string (not counting the NUL-terminator)
[in] | buffer | Pointer to buffer to be accessed |