MySQL 8.4.2
Source Code Documentation
log_builtins_string_imp Class Reference

String primitives for logging services. More...

#include <log_builtins_imp.h>

Static Public Member Functions

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

Detailed Description

String primitives for logging services.

Member Function Documentation

◆ 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
athe first string
bthe second string
lencompare at most this many characters – 0 for no limit
case_insensitiveignore upper/lower case in comparison
Return values
-1a < b
0a == b
1a > b

◆ 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
lenlength 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
fmstring to copy
lenlength 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
tobuffer to write the result to
nsize of that buffer
fmtformat string
apva_list with valuables for all substitutions in format string
Return values
returnvalue of vsnprintf

The documentation for this class was generated from the following files: