DDraceNetwork Documentation
Loading...
Searching...
No Matches
str.h File Reference
#include <cinttypes>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstring>
Include dependency graph for str.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PRIzu   "zu"
#define str_format   str_format_opt

Functions

int str_copy (char *dst, const char *src, int dst_size)
template<int N>
void str_copy (char(&dst)[N], const char *src)
void str_append (char *dst, const char *src, int dst_size)
template<int N>
void str_append (char(&dst)[N], const char *src)
void str_truncate (char *dst, int dst_size, const char *src, int truncation_len)
int str_length (const char *str)
int str_format_v (char *buffer, int buffer_size, const char *format, va_list args)
int str_format (char *buffer, int buffer_size, const char *format,...)
int str_format_int (char *buffer, size_t buffer_size, int value)
template<typename... Args>
int str_format_opt (char *buffer, int buffer_size, const char *format, Args... args)
template<>
int str_format_opt (char *buffer, int buffer_size, const char *format, int val)
char str_uppercase (char c)
bool str_isnum (char c)
int str_isallnum (const char *str)
int str_isallnum_hex (const char *str)
int str_isspace (char c)
const char * str_trim_words (const char *str, int words)
bool str_has_cc (const char *str)
void str_sanitize_cc (char *str)
void str_sanitize (char *str)
void str_sanitize_filename (char *str)
bool str_valid_filename (const char *str)
int str_comp_filenames (const char *a, const char *b)
void str_clean_whitespaces (char *str)
char * str_skip_to_whitespace (char *str)
const char * str_skip_to_whitespace_const (const char *str)
char * str_skip_whitespaces (char *str)
const char * str_skip_whitespaces_const (const char *str)
int str_comp_nocase (const char *a, const char *b)
int str_comp_nocase_num (const char *a, const char *b, int num)
int str_comp (const char *a, const char *b)
int str_comp_num (const char *a, const char *b, int num)
const char * str_startswith_nocase (const char *str, const char *prefix)
const char * str_startswith (const char *str, const char *prefix)
const char * str_endswith_nocase (const char *str, const char *suffix)
const char * str_endswith (const char *str, const char *suffix)
const char * str_find_nocase (const char *haystack, const char *needle)
const char * str_find (const char *haystack, const char *needle)
const char * str_next_token (const char *str, const char *delim, char *buffer, int buffer_size)
int str_in_list (const char *list, const char *delim, const char *needle)
bool str_delimiters_around_offset (const char *haystack, const char *delim, int offset, int *start, int *end)
const char * str_rchr (const char *haystack, char needle)
int str_countchr (const char *haystack, char needle)
void str_hex (char *dst, int dst_size, const void *data, int data_size)
void str_hex_cstyle (char *dst, int dst_size, const void *data, int data_size, int bytes_per_line=12)
int str_hex_decode (void *dst, int dst_size, const char *src)
void str_base64 (char *dst, int dst_size, const void *data, int data_size)
int str_base64_decode (void *dst, int dst_size, const char *data)
void str_escape (char **dst, const char *src, const char *end)
int str_toint (const char *str)
bool str_toint (const char *str, int *out)
int str_toint_base (const char *str, int base)
unsigned long str_toulong_base (const char *str, int base)
int64_t str_toint64_base (const char *str, int base=10)
float str_tofloat (const char *str)
bool str_tofloat (const char *str, float *out)
unsigned str_quickhash (const char *str)
int str_utf8_encode (char *ptr, int chr)
int str_utf8_decode (const char **ptr)
void str_utf8_truncate (char *dst, int dst_size, const char *src, int truncation_len)
int str_utf8_fix_truncation (char *str)
void str_utf8_trim_right (char *param)
void str_utf8_tolower (const char *input, char *output, size_t size)
int str_utf8_isspace (int code)
int str_utf8_isstart (char c)
int str_utf8_rewind (const char *str, int cursor)
const char * str_utf8_find_nocase (const char *haystack, const char *needle, const char **end=nullptr)
int str_utf8_comp_nocase (const char *a, const char *b)
int str_utf8_comp_nocase_num (const char *a, const char *b, int num)
const char * str_utf8_skip_whitespaces (const char *str)
int str_utf8_forward (const char *str, int cursor)
int str_utf8_check (const char *str)
void str_utf8_copy_num (char *dst, const char *src, int dst_size, int num)
void str_utf8_stats (const char *str, size_t max_size, size_t max_count, size_t *size, size_t *count)
size_t str_utf8_offset_bytes_to_chars (const char *str, size_t byte_offset)
size_t str_utf8_offset_chars_to_bytes (const char *str, size_t char_offset)
int str_utf8_dist (const char *a, const char *b)
int str_utf8_dist_buffer (const char *a, const char *b, int *buf, int buf_len)
int str_utf32_dist_buffer (const int *a, int a_len, const int *b, int b_len, int *buf, int buf_len)
int str_utf8_to_skeleton (const char *str, int *buf, int buf_len)
int str_utf8_comp_confusable (const char *str1, const char *str2)
int str_utf8_tolower_codepoint (int code)

Macro Definition Documentation

◆ PRIzu

#define PRIzu   "zu"

◆ str_format

#define str_format   str_format_opt

Function Documentation

◆ str_endswith()

const char * str_endswith ( const char * str,
const char * suffix )

Checks case sensitive whether the string ends with a certain suffix.

Parameters
strString to check.
suffixSuffix to look for.
Returns
A pointer to the beginning of the suffix in the string str.
nullptr if the string suffix isn't a suffix of the string str.
Remarks
The strings are treated as null-terminated strings.

◆ str_escape()

void str_escape ( char ** dst,
const char * src,
const char * end )

Escapes \ and " characters in a string.

Parameters
dstDestination array pointer, gets increased, will point to the terminating null.
srcSource array.
endEnd of destination array.

◆ str_format_int()

int str_format_int ( char * buffer,
size_t buffer_size,
int value )

◆ str_format_opt() [1/2]

template<typename... Args>
int str_format_opt ( char * buffer,
int buffer_size,
const char * format,
Args... args )

◆ str_format_opt() [2/2]

template<>
int str_format_opt ( char * buffer,
int buffer_size,
const char * format,
int val )
inline

◆ str_in_list()

int str_in_list ( const char * list,
const char * delim,
const char * needle )

Checks if needle is in list delimited by delim.

Parameters
listList.
delimList delimiter.
needleItem that is being looked for.
Returns
1 - Item is in list.
0 - Item isn't in list.
Remarks
The strings are treated as null-terminated strings.

◆ str_isallnum()

int str_isallnum ( const char * str)

◆ str_isallnum_hex()

int str_isallnum_hex ( const char * str)

◆ str_isnum()

bool str_isnum ( char c)

◆ str_quickhash()

unsigned str_quickhash ( const char * str)

◆ str_sanitize_filename()

void str_sanitize_filename ( char * str)

Replaces all invalid filename characters with whitespace.

Parameters
strString to sanitize.
Remarks
The strings are treated as null-terminated strings.

◆ str_tofloat() [1/2]

float str_tofloat ( const char * str)

◆ str_tofloat() [2/2]

bool str_tofloat ( const char * str,
float * out )

◆ str_toint() [1/2]

int str_toint ( const char * str)

◆ str_toint() [2/2]

bool str_toint ( const char * str,
int * out )

◆ str_toint64_base()

int64_t str_toint64_base ( const char * str,
int base = 10 )

◆ str_toint_base()

int str_toint_base ( const char * str,
int base )

◆ str_toulong_base()

unsigned long str_toulong_base ( const char * str,
int base )

◆ str_uppercase()

char str_uppercase ( char c)

◆ str_utf8_dist()

int str_utf8_dist ( const char * a,
const char * b )

Computes the edit distance between two strings.

Parameters
aFirst string for the edit distance.
bSecond string for the edit distance.
Returns
The edit distance between the both strings.
Remarks
The strings are treated as null-terminated strings.

◆ str_utf8_to_skeleton()

int str_utf8_to_skeleton ( const char * str,
int * buf,
int buf_len )

◆ str_valid_filename()

bool str_valid_filename ( const char * str)

Checks if a string is a valid filename on all supported platforms.

Parameters
strFilename to check.
Returns
true if the string is a valid filename, false otherwise.
Remarks
The strings are treated as null-terminated strings.