C++ Library, mos@ua
0.9
cpplib-mos
|
Useful common functions and macros. More...
Go to the source code of this file.
Macros | |
#define | int2str(num) |
Converts an int value to a stack allocated string. More... | |
#define | int2nstr(num, len) |
Converts an int value to a stack allocated string. More... | |
#define | perc2str(percentage) |
Converts an int percentage to a stack allocated string. More... | |
#define | length_vargs_string_list(first) |
Determines the length of all strings passed as a NULL terminated variable list of arguments (vargs). More... | |
#define | not_null(pnt) |
Checks if address is not NULL , before its application. More... | |
String concatenation in stack memory | |
#define | concat_2str(str1, str2) |
Concatenates two strings in the stack memory (thus it cannot be implemented in a function). More... | |
#define | concat_3str(str1, str2, str3) |
Concatenates three strings in the stack memory (thus it cannot be implemented in a function). More... | |
#define | concat_4str(str1, str2, str3, str4) |
Concatenates four strings in the stack memory (thus it cannot be implemented in a function). More... | |
#define | concat_5str(str1, str2, str3, str4, str5) |
Concatenates five strings in the stack memory (thus it cannot be implemented in a function). More... | |
#define | concat_6str(str1, str2, str3, str4, str5, str6) |
Concatenates six strings in the stack memory (thus it cannot be implemented in a function). More... | |
#define | concat_7str(str1, str2, str3, str4, str5, str6, str7) |
Concatenates seven strings in the stack memory (thus it cannot be implemented in a function). More... | |
Functions | |
void * | mem_alloc (int size) |
A replacement for malloc function. More... | |
void | mem_free (void *pnt) |
A replacement for free function. More... | |
char * | string_clone (char *str) |
Replicates a string. More... | |
int | string_num_lines (char *text) |
Number of lines of a string. More... | |
int | string_num_columns (char *text) |
Maximum number of columns of a string (not counting character `'\n'`). More... | |
int | string_count_char (char *text, char *ch) |
Counts the number of occurrences of an UTF8 character in a text. More... | |
int | string_starts_with (char *text, char *prefix) |
Tests if a string starts with a prefix. More... | |
int | string_ends_with (char *text, char *suffix) |
Tests if a string ends with a suffix. More... | |
char * | string_concat (char *res, int max_length, char *text,...) |
Concatenates a NULL terminated list of string arguments. More... | |
int | random_boolean (int trueProb) |
Generates a random boolean value. More... | |
int | random_int (int min, int max) |
Generates a random integer value within a given interval. More... | |
char * | random_string (char **list, int *used, int length) |
Returns a random string from a given string list. More... | |
void | clear_console () |
Clears the terminal. | |
void | move_cursor (int line, int column) |
Moves the cursor to a position in terminal. More... | |
void | hide_cursor () |
Hides the terminal cursor. | |
void | show_cursor () |
Shows the terminal cursor. | |
int | string_list_length (char **list) |
Number of elements of a NULL terminated list of strings. More... | |
char ** | string_list_clone (char **list) |
Replicates a NULL terminated list of strings. More... | |
char ** | string_list_free (char **list) |
Frees the memory allocated to a NULL terminated list of strings. More... | |
char * | int2nstring (char *res, int num, int len) |
Converts an int value to a string. More... | |
char * | percentage2string (char *res, int percentage) |
Converts an int percentage to a string. More... | |
Useful common functions and macros.