|
libclod
C library for interacting with NBTs, region files, LOD data and other things.
|
Sized string helpers. More...
Go to the source code of this file.
Classes | |
| struct | clod_sstr |
Macros | |
| #define | clod_sstr(ptr_v, size_v) |
| #define | CLOD_SSTR_NULL ((clod_sstr){ .ptr = nullptr, .size = 0 }) |
| #define | CLOD_SSTR_C(c_string) |
Functions | |
| static bool | clod_sstr_eq (const clod_sstr str1, const clod_sstr str2) |
| static void | clod_sstr_cat (clod_sstr *str1, const clod_sstr str2) |
| static clod_sstr | clod_sstr_contains (const clod_sstr str, const clod_sstr elem) |
| static clod_sstr | clod_sstr_find (const clod_sstr str, const char elem, ptrdiff_t occurrence) |
Sized string helpers.
A few simple methods for dealing with strings when an explicit size is needed instead of being zero terminated. It's C-centric (obviously) and mostly serves as a helper for some C-centric public libclod methods.
Definition in file sstr.h.
| #define clod_sstr | ( | ptr_v, | |
| size_v ) |
| #define CLOD_SSTR_NULL ((clod_sstr){ .ptr = nullptr, .size = 0 }) |
| #define CLOD_SSTR_C | ( | c_string | ) |
Find the first instance of a string inside another string.
| [in] | str | The string to search in. |
| [in] | elem | String to search for. |
str points to at the offset where elem was found and with a size equal to elem's size. If no match was found, it returns null.
|
inlinestatic |
Find the Nth instance of elem in str. When occurrence is positive or negative, it searches from the start or end of str respectively. Then, abs(occurrence) - 1 instances of elem are skipped, and a string pointing to the final instance returned.
| [in] | str | The string to search in. |
| [in] | elem | The character to search for. |
| [in] | occurrence | Which instance of elem to search for. |
elem, and a length including the rest of str. If occurrence is 0, str is returned.