76#define str_concat(...) _str_concat_private(__VA_ARGS__, NULL)
106static inline bool streq(
const char *str1,
const char* str2)
109 for (i = 0 ; str1[i] !=
'\0' ; i++) {
110 if (str1[i] != str2[i])
114 return str2[i] ==
'\0';
121static inline bool strcaseeq(
const char *str1,
const char* str2)
124 for (i = 0 ; str1[i] !=
'\0' ; i++) {
125 if (str1[i] == str2[i])
127 else if (islower(str1[i]) && (str1[i] - 32) == str2[i])
129 else if (isupper(str1[i]) && (str1[i] + 32) == str2[i])
135 return str2[i] ==
'\0';
215 static inline int str_contains(
const char *haystack,
const char *needle) {
252char *
str_replace(
const char *haystack,
const char *needle,
const char *replacement);
auto printf(string_view fmt, const T &... args) -> int
Formats args according to specifications in fmt and writes the output to stdout.
Definition printf.h:621
static bool streq(const char *str1, const char *str2)
Definition string_util.h:106
void string_buffer_destroy(string_buffer_t *sb)
Frees the resources associated with a string buffer object, including space allocated for any appende...
char string_buffer_pop_back(string_buffer_t *sb)
Removes a single character from the end of the string and returns it.
char string_feeder_next(string_feeder_t *sf)
Retrieves the next available character from the supplied string feeder (which may be the terminating ...
char * string_feeder_peek_length(string_feeder_t *sf, size_t length)
Retrieves a series of characters from the supplied string feeder.
char * str_tolowercase(char *s)
Replaces all upper-case characters within the supplied string with their lower-case counterparts,...
void string_buffer_append(string_buffer_t *sb, char c)
Appends a single character to the end of the supplied string buffer.
char * str_lstrip(char *str)
Trims whitespace characters (i.e.
char * str_substring(const char *str, size_t startidx, size_t endidx)
Retrieves a (newly-allocated) substring of the given string, 'str', starting from character index 'st...
void string_buffer_reset(string_buffer_t *sb)
Clears the contents of the string buffer, setting its length to zero.
char * _str_concat_private(const char *first,...)
bool string_feeder_starts_with(string_feeder_t *sf, const char *str)
Determines whether the supplied string feeder's remaining contents starts with the given string.
void string_feeder_destroy(string_feeder_t *sf)
Frees resources associated with the supplied string feeder object, after which it will no longer be v...
string_buffer_t * string_buffer_create(void)
Creates and initializes a string buffer object which can be used with any of the string_buffer_*() fu...
char * str_trim(char *str)
Trims whitespace characters (i.e.
int str_diff_idx(const char *a, const char *b)
int string_feeder_get_column(string_feeder_t *sf)
Retrieves the column index in the current line for the current position in the supplied string feeder...
void str_split_destroy(zarray_t *s)
static int str_contains(const char *haystack, const char *needle)
Definition string_util.h:215
char char * vsprintf_alloc(const char *fmt, va_list args)
Similar to vsprintf(), except that it will malloc() enough space for the formatted string which it re...
bool string_feeder_has_next(string_feeder_t *sf)
Determines whether any characters remain to be retrieved from the string feeder's string (not includi...
zarray_t * str_split(const char *str, const char *delim)
Splits the supplied string into an array of strings by subdividing it at each occurrence of the suppl...
int str_last_indexof(const char *haystack, const char *needle)
bool str_matches_any(const char *haystack, const char **needles, int num_needles)
Returns true if the string 'haystack' matches any needle, else false.
char * str_replace_many(const char *_haystack,...)
int str_indexof(const char *haystack, const char *needle)
Retrieves the zero-based index of the beginning of the supplied substring (needle) within the search ...
char * str_replace(const char *haystack, const char *needle, const char *replacement)
Replaces all occurrences of 'needle' in the string 'haystack', substituting for them the value of 're...
char * str_expand_envs(const char *in)
string_feeder_t * string_feeder_create(const char *str)
Creates a string feeder object which can be used to traverse the supplied string using the string_fee...
char * str_touppercase(char *s)
Replaces all lower-case characters within the supplied string with their upper-case counterparts,...
void string_feeder_require(string_feeder_t *sf, const char *str)
Consumes from the string feeder the number of characters contained in the given string (not including...
char * sprintf_alloc(const char *fmt,...) __attribute__((format(printf
Similar to sprintf(), except that it will malloc() enough space for the formatted string which it ret...
void string_buffer_append_string(string_buffer_t *sb, const char *str)
Appends the supplied string to the end of the supplied string buffer.
void bool string_buffer_ends_with(string_buffer_t *sb, const char *str)
Determines whether the character contents held by the supplied string buffer ends with the supplied s...
char * str_rstrip(char *str)
Trims whitespace characters (i.e.
void string_buffer_appendf(string_buffer_t *sb, const char *fmt,...) __attribute__((format(printf
Formats the supplied string and arguments in a manner akin to printf(), and appends the resulting str...
char string_feeder_peek(string_feeder_t *sf)
Retrieves the next available character from the supplied string feeder (which may be the terminating ...
char * string_feeder_next_length(string_feeder_t *sf, size_t length)
Retrieves a series of characters from the supplied string feeder.
bool str_ends_with(const char *haystack, const char *needle)
Returns true if the end of string 'haystack' matches 'needle', else false.
bool str_starts_with(const char *haystack, const char *needle)
Returns true if the start of string 'haystack' matches 'needle', else false.
size_t string_buffer_size(string_buffer_t *sb)
Returns the string-length of the contents of the string buffer (not counting \0).
bool str_starts_with_any(const char *haystack, const char **needles, int num_needles)
Returns true if the start of string 'haystack' matches any needle, else false.
zarray_t * str_split_spaces(const char *str)
static bool strcaseeq(const char *str1, const char *str2)
Determines if str1 exactly matches str2, ignoring case (more efficient than strcasecmp(....
Definition string_util.h:121
int string_feeder_get_line(string_feeder_t *sf)
Retrieves the line number of the current position in the supplied string feeder, which will be increm...
char * string_buffer_to_string(string_buffer_t *sb)
Returns the contents of the string buffer in a newly-allocated string, which it is the caller's respo...
Definition string_util.h:46
int line
Definition string_util.h:51
char * s
Definition string_util.h:47
int col
Definition string_util.h:51
size_t pos
Definition string_util.h:49
size_t len
Definition string_util.h:48