GATE
Loading...
Searching...
No Matches
strings.h File Reference

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_tgate_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_tgate_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)
 

Detailed Description

String management, UTF conversion and basic text parsing functions.

Macro Definition Documentation

◆ GATE_STR_NPOS

#define GATE_STR_NPOS   GATE_INVALID_SIZE

Invalid position indicator

◆ GATE_PRINT_END

#define GATE_PRINT_END   ((int)0x00)

end of print argument list

◆ GATE_PRINT_CHAR

#define GATE_PRINT_CHAR   ((int)0x01)

print a single character

◆ GATE_PRINT_NEWLINE

#define GATE_PRINT_NEWLINE   ((int)0x02)

send platform specific newline-characters

◆ GATE_PRINT_CSTR

#define GATE_PRINT_CSTR   ((int)0x03)

print null terminated char array (char const*)

◆ GATE_PRINT_STRING

#define GATE_PRINT_STRING   ((int)0x04)

print content of gate_string_t

◆ GATE_PRINT_CR

#define GATE_PRINT_CR   ((int)0x05)

print CR character

◆ GATE_PRINT_LF

#define GATE_PRINT_LF   ((int)0x06)

print LF character

◆ GATE_PRINT_CRLF

#define GATE_PRINT_CRLF   ((int)0x07)

print CR + LF characters

◆ GATE_PRINT_BOOL

#define GATE_PRINT_BOOL   ((int)0x10)

print boolean content (true / false)

◆ GATE_PRINT_I8

#define GATE_PRINT_I8   ((int)0x11)

print signed 8 bit integer

◆ GATE_PRINT_UI8

#define GATE_PRINT_UI8   ((int)0x12)

print unsigned 8 bit integer

◆ GATE_PRINT_I16

#define GATE_PRINT_I16   ((int)0x13)

print signed 16 bit integer

◆ GATE_PRINT_UI16

#define GATE_PRINT_UI16   ((int)0x14)

print unsigned 16 bit integer

◆ GATE_PRINT_I32

#define GATE_PRINT_I32   ((int)0x15)

print signed 32 bit integer

◆ GATE_PRINT_UI32

#define GATE_PRINT_UI32   ((int)0x16)

print unsigned 32 bit integer

◆ GATE_PRINT_I64

#define GATE_PRINT_I64   ((int)0x17)

print signed 64 bit integer

◆ GATE_PRINT_UI64

#define GATE_PRINT_UI64   ((int)0x18)

print unsigned 64 bit integer

◆ GATE_PRINT_H8

#define GATE_PRINT_H8   ((int)0x1a)

print byte as 2 HEX chars

◆ GATE_PRINT_H16

#define GATE_PRINT_H16   ((int)0x1b)

print 16 bit word as 4 HEX chars

◆ GATE_PRINT_H32

#define GATE_PRINT_H32   ((int)0x1c)

print 32 bit dword as 8 HEX chars

◆ GATE_PRINT_H64

#define GATE_PRINT_H64   ((int)0x1d)

print 64 bit qword as 16 HEX chars

◆ GATE_PRINT_R32

#define GATE_PRINT_R32   ((int)0x21)

print 32 bit floating point number

◆ GATE_PRINT_R64

#define GATE_PRINT_R64   ((int)0x22)

print 64 bit floating point number

◆ GATE_PRINT_ADDRESS

#define GATE_PRINT_ADDRESS   ((int)0x23)

print pointer address as HEX chars

Typedef Documentation

◆ 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

◆ gate_strbuilder8_t

character (byte) string builder class

Stringbuilders hold a stringbuffer and grow them if necessary (when the current capacity is reached)

◆ 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.

◆ 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.

Function Documentation

◆ gate_char_lowercase()

GATE_CORE_API int gate_char_lowercase ( int chr)

Converts an ASCII character to its lower case.

Parameters
chrinput ASCII character value
Returns
lower case version of 'chr'

◆ gate_char_uppercase()

GATE_CORE_API int gate_char_uppercase ( int chr)

Converts an ASCII character to its upper case.

Parameters
chrinput ASCII character value
Returns
upper case version of 'chr'

◆ gate_char_is_digit()

GATE_CORE_API gate_bool_t gate_char_is_digit ( int chr)

Returns true, if the ASCII character is a digite '0' - '9'.

Parameters
chrinput ASCII character value
Returns
true if 'chr' is a digit, otherwise false

◆ gate_char_is_whitespace()

GATE_CORE_API gate_bool_t gate_char_is_whitespace ( int chr)

Returns true, if the ASCII character is a whitespace.

Parameters
chrinput ASCII character value
Returns
true if 'chr' is a whitespace character, otherwise false

◆ gate_char_read_utf8()

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.

Parameters
srcpointer to byte sequence
srclentotal length of byte sequence
dstpointer to one output unicode character
Returns
amount of input bytes processed to decode one unicode character

◆ gate_char_read_utf16()

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.

Parameters
srcpointer to 16-bit word sequence
srclentotal amount of 16-bit words in sequence
dstpointer to one output unicode character
Returns
amount of input 16-bit words processed to decode one unicode character

◆ gate_char_read_utf32()

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.

Parameters
srcpointer to 32-bit word sequence
srclentotal amount of 32-bit words in sequence
dstpointer to one output unicode character
Returns
amount of input 32-bit words processed to decode one unicode character

◆ gate_char_write_utf8()

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.

Parameters
srcone unicode character to encode
dstpointer to allocated output buffer that receives an UTF-8 character sequence
dstlensize of output buffer in bytes
Returns
amount of used bytes in output buffer

◆ gate_char_write_utf16()

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.

Parameters
srcone unicode character to encode
dstpointer to allocated output buffer that receives an UTF-16 character sequence
dstlensize of output buffer in 16-bit words
Returns
amount of used 16-bit words in output buffer

◆ gate_char_write_utf32()

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.

Parameters
srcone unicode character to encode
dstpointer to allocated output buffer that receives an UTF-32 character sequence
dstlensize of output buffer in 32-bit words
Returns
amount of used 32-bit words in output buffer

◆ gate_str_utf8_2_utf16()

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.

Parameters
srcpointer to first byte in UTF-8 input buffer
srclenlength of bytes in UTF-8 input buffer
dstpointer to first word in UTF-16 output buffer
dstlenlength of UTF-16 output buffer in 16-bit words
Returns
amount of used 16-bit words in output buffer

◆ gate_str_utf8_2_utf32()

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.

Parameters
srcpointer to first byte in UTF-8 input buffer
srclenlength of bytes in UTF-8 input buffer
dstpointer to first word in UTF-32 output buffer
dstlenlength of UTF-32 output buffer in 32-bit words
Returns
amount of used 32-bit words in output buffer

◆ gate_str_utf16_2_utf8()

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.

Parameters
srcpointer to first 16-bit word in UTF-16 input buffer
srclenlength of 16-bit words in UTF-16 input buffer
dstpointer to first byte in UTF-8 output buffer
dstlenlength of UTF-8 output buffer in bytes
Returns
amount of used bytes in output buffer

◆ gate_str_utf16_2_utf32()

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.

Parameters
srcpointer to first 16-bit word in UTF-16 input buffer
srclenlength of 16-bit words in UTF-16 input buffer
dstpointer to first 32-bit word in UTF-32 output buffer
dstlenlength of UTF-32 output buffer in 32-bit words
Returns
amount of used 32-bit words in output buffer

◆ gate_str_utf32_2_utf8()

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.

Parameters
srcpointer to first 32-bit word in UTF-32 input buffer
srclenlength of 32-bit words in UTF-32 input buffer
dstpointer to first byte in UTF-8 output buffer
dstlenlength of UTF-8 output buffer in bytes
Returns
amount of used bytes in output buffer

◆ gate_str_utf32_2_utf16()

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.

Parameters
srcpointer to first 32-bit word in UTF-32 input buffer
srclenlength of 32-bit words in UTF-32 input buffer
dstpointer to first 16-bit word in UTF-16 output buffer
dstlenlength of UTF-16 output buffer in 16-bit words
Returns
amount of used 16-bit words in output buffer

◆ gate_str_length()

GATE_CORE_API gate_size_t gate_str_length ( gate_char8_t const * src)

Returns the length of a NULL-terminated character string.

Parameters
srcpointer to first character in string
Returns
amount of bytes in character string until NULL was reached

◆ gate_str_length_max()

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.

Parameters
srcpointer to first character in string
capacitymaximum allocated space of string
Returns
amount of bytes in character string until NULL or given capacity was reached

◆ gate_str_is_empty()

GATE_CORE_API gate_bool_t gate_str_is_empty ( gate_char8_t const * src)

Returns true if the given character string is emptry.

Parameters
srcpointer to first character in string
Returns
true if 'src' is NULL or points to a NULL-terminator character

◆ gate_str_comp_range()

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.

Parameters
str1pointer to first byte in first string
str2pointer to first byte in second string
lenlength of both strings in bytes
Returns
0 if strings are equal, < 0 if first string has lower byte values, > 0 if second string has lower byte values

◆ gate_str_comp_range_ic()

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.

Parameters
str1pointer to first byte in first string
str2pointer to first byte in second string
lenlength of both strings in bytes
Returns
0 if strings are case-insensitive equal, < 0 if first string has lower byte values, > 0 if second string has lower byte values

◆ gate_str_to_lower()

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.

Parameters
strpointer to first character in string
lenlength of string

◆ gate_str_to_upper()

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.

Parameters
strpointer to first character in string
lenlength of string

◆ gate_str_reverse()

GATE_CORE_API void gate_str_reverse ( gate_char8_t * str,
gate_size_t len )

Reverses the bytes sequence of a string (first <-> last)

Parameters
strpointer to first character in string
lenlength of string

◆ gate_str_char_pos()

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.

Parameters
strpointer to first character in string
lenlength of string
findcharacter value to search for
startatcharacter offset in string where search starts
Returns
position of found character, or GATE_STR_NPOS if not found

◆ gate_str_char_pos_last()

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.

Parameters
strpointer to first character in string
lenlength of string
findcharacter value to search for
Returns
position of found character, or GATE_STR_NPOS if not found

◆ gate_str_pos()

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.

Parameters
strpointer to first character in string
lenlength of string
findpointer to first character in sub-string token to search for
findlenlength of sub-string token to search for
startatcharacter offset in string where search starts
Returns
start position of found sub-string, or GATE_STR_NPOS if not found

◆ gate_str_count_chars()

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.

Parameters
[in]strpointer to first character in first string
[in]lenLength of the string in bytes
[in]chrCharacter to be counted
Returns
Amount of found characters

◆ gate_str_comp()

GATE_CORE_API int gate_str_comp ( gate_char8_t const * str1,
gate_char8_t const * str2 )

Compares two NULL-terminated strings.

Parameters
str1pointer to first character in first string
str2pointer to first character in second string
Returns
0 if strings are equal, < 0 if first string has lower bytes values, > 0 if second string has lower byte values

◆ gate_str_comp_ic()

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.

Parameters
str1pointer to first character in first string
str2pointer to first character in second string
Returns
0 if strings are equal, < 0 if first string has lower bytes values, > 0 if second string has lower byte values

◆ gate_str_compare()

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.

Parameters
str1pointer to first character in first string
len1length in bytes of str1
str2pointer to first character in second string
len2length in bytes of str2
Returns
0 if strings are equal, < 0 if first string has lower bytes values, > 0 if second string has lower byte values

◆ gate_str_compare_ic()

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.

Parameters
str1pointer to first character in first string
len1length in bytes of str1
str2pointer to first character in second string
len2length in bytes of str2
Returns
0 if strings are equal, < 0 if first string has lower bytes values, > 0 if second string has lower byte values

◆ gate_str_is_numeric()

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.

Parameters
strpointer to character string
lenlength of string in bytes
Returns
number of found digit characters

◆ gate_str_starts_with()

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.

Parameters
strpointer to string to be analyzed
lenlength of text in str in bytes
starttokenpointer to string with expected start token
startlenlength of text in starttoken in bytes
Returns
true if str begins with startoken's content

◆ gate_str_ends_with()

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.

Parameters
strpointer to string to be analyzed
lenlength of text in str in bytes
endtokenpointer to string with expected end token
endlenlength of text in endtoken in bytes
Returns
true if str ends with endtoken's content

◆ gate_str_starts_with_ic()

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.

Parameters
strpointer to string to be analyzed
lenlength of text in str in bytes
starttokenpointer to string with expected start token
startlenlength of text in starttoken in bytes
Returns
true if str begins with startoken's content

◆ gate_str_ends_with_ic()

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.

Parameters
strpointer to string to be analyzed
lenlength of text in str in bytes
endtokenpointer to string with expected end token
endlenlength of text in endtoken in bytes
Returns
true if str ends with endtoken's content

◆ gate_str_print_text()

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

Parameters
dstpointer to destination buffer to be filled
dstlenbyte capacity of destination buffer
txtpointer to first character in text to be printed into buffer
txtlenbyte length of string in txt to be printed
Returns
amount of bytes transferred into buffer

◆ gate_str_print_wtext()

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

Parameters
dstpointer to destination buffer to be filled
dstlenbyte capacity of destination buffer
txtpointer to first character in text to be printed into buffer
txtlenamount of wide-characters in the text to be printed
Returns
amount of bytes transferred into buffer

◆ gate_str_print_uint()

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

Parameters
dstpointer to destination buffer to be filled
dstlenbyte capacity of destination buffer
numunsigned integer to be printed
intlenfixed length of size, 0: means free length, length < intlen: leading zeros are added, length > intlen: leading digits are cut off
Returns
amount of bytes transferred into buffer

◆ gate_str_print_real()

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

Parameters
[out]dstpointer to destination buffer to be filled
[in]dstlenbyte capacity of destination buffer
[in]numfloating point value to be printed
[in]intlenfixed length of size, 0: means free length, length < intlen: leading zeros are added, length > intlen: leading digits are cut off
[in]decimallenmaximum amount of post-comma digits, zero prints as much as possible
[in]grouplenlength of digits in a group (some cultures use 3 to separate 1000 steps), zero disables grouping
Returns
amount of bytes transferred into buffer

◆ gate_str_like()

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"

Parameters
[in]strPointer to string to be evaluated
[in]lenLength of str in bytes
[in]likePointer to string with pattern
[in]likelenLength of like in bytes
Returns
true if str matches the pattern in like

◆ gate_str_like_one_of()

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

Parameters
[in]strPointer to string to be evaluated
[in]lenLength of str in bytes
[in]likePointer to string with multiple patterns
[in]likelenLength of like in bytes
[in]like_separatorCharacter used to cut like into pieces
Returns
true if str matches at least on of the patterns in like

◆ gate_str_find_first_of()

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.

Parameters
[in]strPointer to string to be evaluated
[in]lenLength of str in bytes
[in]charsPointer to array of characters to search
[in]charcountCount of characters in chars
[in]startatOffset in string to start search
Returns
Offset position of first found character in str matchting chars, or GATE_STR_NPOS if no character was found

◆ gate_str_find_first_not_of()

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.

Parameters
[in]strPointer to string to be evaluated
[in]lenLength of str in bytes
[in]charsPointer to array of characters to search
[in]charcountCount of characters in chars
[in]startatOffset in string to start search
Returns
Offset position of first found character in str NOT matching chars, or GATE_STR_NPOS if all characters are matching

◆ gate_str_find_last_of()

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.

Parameters
[in]strPointer to string to be evaluated
[in]lenLength of str in bytes
[in]charsPointer to array of characters to search
[in]charcountCount of characters in chars
Returns
Offset position of last found character in str matchting chars (reverse search), or GATE_STR_NPOS if no character was found

◆ gate_str_find_last_not_of()

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.

Parameters
[in]strPointer to string to be evaluated
[in]lenLength of str in bytes
[in]charsPointer to array of characters to search
[in]charcountCount of characters in chars
Returns
Offset position of last found character in str NOT matching chars (reverse search), or GATE_STR_NPOS if all characters are matching

◆ gate_str_hash()

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.

Parameters
[in]strPointer to string to be evaluated
[in]lenLength of str in bytes
Returns
Hash value of string content

◆ gate_str_replace()

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.

Parameters
[in]strPointer to string to be updated
[in]lenLength of str in bytes
[in]findCharacter to be searched for
[in]replaceCharacter to replace all found characters of value find
Returns
Amount of characters that were replaced

◆ gate_str_print_int16()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numinteger to be printed
Returns
Amount of bytes used in dst

◆ gate_str_print_uint16()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numinteger to be printed
Returns
Amount of bytes used in dst

◆ gate_str_print_int32()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numinteger to be printed
Returns
Amount of bytes used in dst

◆ gate_str_print_uint32()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numinteger to be printed
Returns
Amount of bytes used in dst

◆ gate_str_print_int64()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numinteger to be printed
Returns
Amount of bytes used in dst

◆ gate_str_print_uint64()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numinteger to be printed
Returns
Amount of bytes used in dst

◆ gate_str_print_hex_nibble()

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.

Parameters
[in]nibble4-bit unsigned number to be printed
[in]uppercasetrue prints letters in upper case, otherwise lower case
Returns
Character mapping of number (0-9)|(a-f)

◆ gate_str_print_hex_byte()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numnumber to be printed
[in]uppercaseif true, uses upper case letters (A-F), otherwise lower case (a-f)
Returns
Amount of bytes used in dst

◆ gate_str_print_hex_num()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numnumber to be printed
[in]uppercaseif true, uses upper case letters (A-F), otherwise lower case (a-f)
Returns
Amount of bytes used in dst

◆ gate_str_print_hex_uint16()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numnumber to be printed
[in]uppercaseif true, uses upper case letters (A-F), otherwise lower case (a-f)
Returns
Amount of bytes used in dst

◆ gate_str_print_hex_uint32()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numnumber to be printed
[in]uppercaseif true, uses upper case letters (A-F), otherwise lower case (a-f)
Returns
Amount of bytes used in dst

◆ gate_str_print_hex_uint64()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numnumber to be printed
[in]uppercaseif true, uses upper case letters (A-F), otherwise lower case (a-f)
Returns
Amount of bytes used in dst

◆ gate_str_print_hex_buffer()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]bufferSource buffer thats bytes are printed
[in]bufferlenLength of buffer in bytes
[in]uppercaseif true, uses upper case letters (A-F), otherwise lower case (a-f)
Returns
Amount of bytes used in dst

◆ gate_str_print_hex()

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.

Parameters
[out]dstPointer to string to be updated
[in]dstlenCapacity of buffer in str in bytes
[in]numnumber to be printed
[in]numlenamount of bytes to be printed in target buffer (length limit, using leading zeros when required)
[in]uppercaseif true, uses upper case letters (A-F), otherwise lower case (a-f)
Returns
Amount of bytes used in dst

◆ gate_str_print_to()

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.

Parameters
[in]printerPointer to printer-function that receives strings to print
[in]printer_paramUser parameter handed over to printer function
[in]argva_list arguments containing pairs of GATE_PRINT_* integers + data types
Returns
Amount of printed character bytes

◆ gate_str_print()

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.

Parameters
[in]dstPointer to destination string where output is printed to
[in]dstlenCapacity of destination string buffer dst
Returns
Amount of printed character bytes

◆ gate_str_print_values()

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.

Parameters
[out]dstPointer to destination string where output is printed to
[in]dstlenCapacity of destination string buffer dst
[in]valuesPointer to first gate_print_value_t structure in an array
[in]values_countAmount of gate_print_value_t structures in array
Returns
Amount of printed character bytes

◆ gate_str_parse_digit()

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.

Parameters
[in]srcPointer to printer-function that receives strings to print
[out]digitUser parameter handed over to printer function
Returns
true, if first character of string is a digit

◆ gate_str_parse_bool()

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"

Parameters
[in]srcPointer to string to be parsed
[in]srclenLength of src in bytes
[out]valuePointer to ouput value filled with parsing result
Returns
Amount of bytes that were parsed

◆ gate_str_parse_uint64()

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.

Parameters
[in]srcPointer to string to be parsed
[in]srclenLength of src in bytes
[out]numPointer to ouput value filled with parsing result
Returns
Amount of bytes that were parsed

◆ gate_str_parse_int64()

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.

Parameters
[in]srcPointer to string to be parsed
[in]srclenLength of src in bytes
[out]numPointer to ouput value filled with parsing result
Returns
Amount of bytes that were parsed

◆ gate_str_parse_real()

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.

Parameters
[in]srcPointer to string to be parsed
[in]srclenLength of src in bytes
[out]numPointer to ouput value filled with parsing result
Returns
Amount of bytes that were parsed

◆ gate_str_parse_hex_nibble()

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)

Parameters
[in]chrCharacter to be parsed
[out]valuePointer to ouput value filled with parsing result
Returns
true if nibble could be parsed, otherwise false

◆ gate_str_parse_hex_byte()

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.

Parameters
[in]chrPointer to 2-bytes string
[out]valuePointer to ouput value filled with parsing result
Returns
true if byte could be parsed, otherwise false

◆ gate_str_parse_hex_int()

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.

Parameters
[in]textPointer to string to be parsed
[in]textlenLength of text in bytes
[out]numPointer to ouput value filled with parsing result
Returns
Amount of bytes that were parsed

◆ gate_str_parse_hex_buffer()

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.

Parameters
[in]textPointer to string to be parsed
[in]textlenLength of text in bytes
[out]bufferPointer to ouput value filled with parsing result
[in]bufferlenCapacity of buffer
Returns
Amount of bytes that were parsed

◆ gate_str_parse_oct_byte()

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.

Parameters
[in]chr3-character string to be parsed
[out]valuePointer to ouput value filled with parsing result
Returns
true if parsing succeeded, otherwise false

◆ gate_str_parse_line()

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)

Parameters
[in]textPointer to string to be parsed
[in]textlenLength of text in bytes
[out]bufferPointer to ouput buffer filled with parsed line content
[in,out]bufferlenPointer to size of buffer, updated with amout of used bytes after parsing (not including line-ending characters)
Returns
Amount of bytes that were totally parsed

◆ gate_strbuilder_create()

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

Parameters
[out]builderPointer to string-builder to be initialized
[in]capacityAmount of bytes of preallocated buffer capacity in string-builder

◆ gate_strbuilder_create_static()

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

Parameters
[out]builderPointer to string-builder to be initialized
[in]bufferExternal buffer to be used within string-builder
[in]capacityTotal capacity of buffer
[in]length_usedLength of bytes in buffer that are already valid as a string

◆ gate_strbuilder_release()

GATE_CORE_API void gate_strbuilder_release ( gate_strbuilder_t * builder)

Releases all allocated resources of a stringbuilder object.

Parameters
[in]builderPointer to string-builder to be released

◆ gate_strbuilder_resize()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]szSize in bytes of requested new size
Returns
New capacity of builder, or 0 in case of an error

◆ gate_strbuilder_length()

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.

Parameters
[in]builderPointer to string-builder to be accessed
Returns
Length of contained string in bytes

◆ gate_strbuilder_ptr()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]charposPosition of character to be accessed
Returns
Pointer to character, or NULL if charpos is out of range.

◆ gate_strbuilder_increase()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]szAmount of bytes to increase the internal buffer size
Returns
New capacity if internal buffer in bytes

◆ gate_strbuilder_append_text()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]txtPointer to first character of string to add
[in]txtlenLength of string to add
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_chars()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]char_countCharacter to be added
[in]chrAmount of repeats the character is added
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_text16()

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)

Parameters
[in]builderPointer to string-builder to be accessed
[in]txtPointer to UTF-16 input string
[in]txtlenLenght of UTF-16 string in 16-bit words-count
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_text32()

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)

Parameters
[in]builderPointer to string-builder to be accessed
[in]txtPointer to UTF-32 input string
[in]txtlenLenght of UTF-32 string in 32-bit words
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_cstr()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]txtPointer to C-string to be added
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_string()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]txtPointer to the gate-string object to be added
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_int16()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]numNumeric value to be added
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_uint16()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]numNumeric value to be added
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_int32()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]numNumeric value to be added
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_uint32()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]numNumeric value to be added
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_int64()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]numNumeric value to be added
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_uint64()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]numNumeric value to be added
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_real()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]numFloating point value to be added
[in]intlenMaximum character length of integer digits to be added, 0 adds as much as neccessary
[in]decimallenMaximum character length of decimal digits to be added, 0 adds as much as ncecssary
[in]grouplenOptional digit group length, if != 0 a digit-group-separator character is added before/after every Nth digit
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append_hex()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]bytesPointer to first byte in the buffer thats content is added as HEX string
[in]bytescountAmount of bytes in the buffer to be added
[in]uppercasetrue adds hex characters uppercase, false adds lower case values
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_append()

GATE_CORE_API gate_size_t gate_strbuilder_append ( gate_strbuilder_t * builder,
... )

Appends GATE_PRINT_* typed values to the string builder's buffer.

Parameters
[in]builderPointer to string-builder to be accessed
[in]type_11-st GATE_PRINT_* type id
[in]value_1value or pointer of 1-st content, identified by GATE_PRINT_*
[in]type_Nn-th GATE_PRINT_* type id
[in]value_Nvalue or pointer of n-th content, identified by GATE_PRINT_*
[in]terminatorFinal type-id with value GATE_PRINT_END to signal end of parameters.
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_insert()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]posByte position, where the string should be inserted, existing characters are move backwards
[in]txtPointer to first character of text to be inserted
[in]txtlenAmount of character bytes to be inserted
Returns
Amount of characters (bytes) that were added to the string buffer

◆ gate_strbuilder_remove()

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.

Parameters
[in]builderPointer to string-builder to be accessed
[in]posByte position, where character bytes should be removed
[in]lengthAmount of character bytes to be removed
Returns
Amount of characters (bytes) that were removed from the string buffer

◆ gate_cstrbuffer_create()

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.

Parameters
[out]bufferPointer to output cstrbuffer to be initialized
[in]textptrPointer to input string range to be integrated
[in]lengthLength of input string
[in]copy_neededContents of source buffer is always copied into local or heap buffer
Returns
buffer-Pointer in case of success, NULL in case of allocation error

◆ gate_cstrbuffer_create_string()

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.

Parameters
[out]bufferPointer to output cstrbuffer to be initialized
[in]strptrPointer to input string to be integrated
[in]copy_neededContents of source buffer is always copied into local or heap buffer
Returns
buffer-pointer in case of success, NULL in case of allocation error

◆ gate_cstrbuffer_destroy()

GATE_CORE_API void gate_cstrbuffer_destroy ( gate_cstrbuffer_t * buffer)

Destroys C-string buffer (deallocates heap if used)

Parameters
[in]bufferPointer to c-string buffer to be destroyed

◆ gate_cstrbuffer_get()

GATE_CORE_API gate_char8_t const * gate_cstrbuffer_get ( gate_cstrbuffer_t const * buffer)

Returns a pointer to the buffered NUL-terminated string.

Parameters
[in]bufferPointer to buffer to be accessed
Returns
Pointer to NUL-terminated string

◆ gate_cstrbuffer_length()

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)

Parameters
[in]bufferPointer to buffer to be accessed
Returns
Length of NUL-terminated string (not counting the NUL-terminator)