String primitives for logging services.
More...
#include <log_builtins_imp.h>
|
static void * | malloc (size_t len) noexcept |
| Wrapper for my_malloc(): Alloc (len+1) bytes. More...
|
|
static char * | strndup (const char *fm, size_t len) noexcept |
| Wrapper for my_strndup(): Alloc (len+1) bytes, then copy len bytes from fm, and \0 terminate. More...
|
|
static void | free (void *ptr) noexcept |
| Wrapper for my_free(): free allocated memory. More...
|
|
static size_t | length (const char *s) noexcept |
| Wrapper for strlen(): length of a nul-terminated byte string. More...
|
|
static char * | find_first (const char *s, int c) noexcept |
| Wrapper for strchr(): find character in string, from the left. More...
|
|
static char * | find_last (const char *s, int c) noexcept |
| Wrapper for strrchr(): find character in string, from the right. More...
|
|
static int | compare (const char *a, const char *b, size_t len, bool case_insensitive) noexcept |
| Compare two NUL-terminated byte strings. More...
|
|
static size_t | substitutev (char *to, size_t n, const char *fmt, va_list ap) noexcept |
| Wrapper for vsnprintf(): Replace all % in format string with variables from list. More...
|
|
static size_t | substitute (char *to, size_t n, const char *fmt,...) noexcept |
| Wrapper for vsnprintf(): Replace all % in format string with variables from list. More...
|
|
String primitives for logging services.
◆ compare()
int log_builtins_string_imp::compare |
( |
const char * |
a, |
|
|
const char * |
b, |
|
|
size_t |
len, |
|
|
bool |
case_insensitive |
|
) |
| |
|
staticnoexcept |
Compare two NUL-terminated byte strings.
Note that when comparing without length limit, the long string is greater if they're equal up to the length of the shorter string, but the shorter string will be considered greater if its "value" up to that point is greater:
compare 'abc','abcd': -100 (longer wins if otherwise same) compare 'abca','abcd': -3 (higher value wins) compare 'abcaaaaa','abcd': -3 (higher value wins)
- Parameters
-
a | the first string |
b | the second string |
len | compare at most this many characters – 0 for no limit |
case_insensitive | ignore upper/lower case in comparison |
- Return values
-
◆ find_first()
char * log_builtins_string_imp::find_first |
( |
const char * |
s, |
|
|
int |
c |
|
) |
| |
|
staticnoexcept |
Wrapper for strchr(): find character in string, from the left.
◆ find_last()
char * log_builtins_string_imp::find_last |
( |
const char * |
s, |
|
|
int |
c |
|
) |
| |
|
staticnoexcept |
Wrapper for strrchr(): find character in string, from the right.
◆ free()
void log_builtins_string_imp::free |
( |
void * |
ptr | ) |
|
|
staticnoexcept |
Wrapper for my_free(): free allocated memory.
◆ length()
size_t log_builtins_string_imp::length |
( |
const char * |
s | ) |
|
|
staticnoexcept |
Wrapper for strlen(): length of a nul-terminated byte string.
◆ malloc()
void * log_builtins_string_imp::malloc |
( |
size_t |
len | ) |
|
|
staticnoexcept |
Wrapper for my_malloc(): Alloc (len+1) bytes.
- Parameters
-
len | length of string to copy |
◆ strndup()
char * log_builtins_string_imp::strndup |
( |
const char * |
fm, |
|
|
size_t |
len |
|
) |
| |
|
staticnoexcept |
Wrapper for my_strndup(): Alloc (len+1) bytes, then copy len bytes from fm, and \0 terminate.
Like my_strndup(), and unlike strndup(), \0 in input won't end copying.
- Parameters
-
fm | string to copy |
len | length of string to copy |
◆ substitute()
size_t log_builtins_string_imp::substitute |
( |
char * |
to, |
|
|
size_t |
n, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
|
staticnoexcept |
Wrapper for vsnprintf(): Replace all % in format string with variables from list.
◆ substitutev()
size_t log_builtins_string_imp::substitutev |
( |
char * |
to, |
|
|
size_t |
n, |
|
|
const char * |
fmt, |
|
|
va_list |
ap |
|
) |
| |
|
staticnoexcept |
Wrapper for vsnprintf(): Replace all % in format string with variables from list.
- Parameters
-
to | buffer to write the result to |
n | size of that buffer |
fmt | format string |
ap | va_list with valuables for all substitutions in format string |
- Return values
-
The documentation for this class was generated from the following files: