28#ifndef __FANCY_STRING_H__
29#define __FANCY_STRING_H__
char * fancy_string_array_get_value(fancy_string_array_t const *const self, size_t index)
Returns a memory-independent copy of the fancy_string_t instance's internal state (i....
void fancy_string_prepend(fancy_string_t *const self, fancy_string_t const *const string)
Prepends a string object's data (in this case string ) to the current string object's internal state ...
bool fancy_string_equals(fancy_string_t const *const self, fancy_string_t const *const string)
Checks whether the string object's internal value equals to string 's internal value.
fancy_string_regex_t * fancy_string_regex_create(fancy_string_t const *const string, fancy_string_t const *const pattern, ssize_t n_max_matches)
Instantiates a regular expression object and returns a pointer to it. That object can then be interro...
void fancy_string_regex_debug(fancy_string_regex_t const *const self, FILE *stream, bool verbose)
Prints a summary of the self regular expression object to the specified stream (i....
char * fancy_string_value(fancy_string_t const *const self)
Returns a pointer to a heap-allocated copy of the string object's internal state.
bool fancy_string_array_includes_value(fancy_string_array_t const *const self, char const *const value)
Checks whether the value value is contained inside the array object's internal list.
bool(* fancy_string_filter_t)(fancy_string_t const *const string, size_t index, fancy_string_array_t const *const array, void *context)
The signature a callback function needs to implement to be allowed to be passed as argument to the fa...
Definition: fancy_string.h:1503
void fancy_string_replace_value(fancy_string_t *const self, char const *const old_value, char const *const new_value, ssize_t replace_n)
Replaces the specified number of occurrences (i.e., replace_n ) of old_value with new_value in the st...
void fancy_string_array_append(fancy_string_array_t *const self, fancy_string_array_t const *const array)
Appends the elements of another array object (i.e., array ) into the current array object (i....
fancy_string_t * fancy_string_array_join_by_value(fancy_string_array_t const *const self, char const *const separator)
Creates (and returns a pointer to) a fancy_string_t instance and populates it with copies of the arra...
void fancy_string_update_value(fancy_string_t *const self, char const *const value)
Updates the internal state of the string object with the new string data (i.e., value ).
fancy_string_array_t * fancy_string_array_clone(fancy_string_array_t const *const self)
Clones an array object.
struct fancy_string_regex_s fancy_string_regex_t
An opaque type that serves as a container for regular expression matching results,...
Definition: fancy_string.h:82
fancy_string_array_t * fancy_string_split(fancy_string_t const *const self, fancy_string_t const *const separator, ssize_t n_max_splits)
Splits the string into an array (i.e., a list) of string objects based on the separator string object...
fancy_string_t * fancy_string_substring(fancy_string_t const *const self, ssize_t start, ssize_t end)
Creates a substring of a string object.
fancy_string_t * fancy_string_replaced_value(fancy_string_t const *const self, char const *const old_value, char const *const new_value, ssize_t replace_n)
Creates a string object with the specified number of occurrences (i.e., replace_n ) of old_value repl...
bool fancy_string_starts_with_value(fancy_string_t const *const self, char const *const value)
Checks whether the string object's internal value starts with value.
fancy_string_t * fancy_string_regex_to_string_with_updated_matches(fancy_string_regex_t const *const self, fancy_string_regex_updater_t fn, void *context)
Similar to, but more flexible than fancy_string_regex_replaced_matches(), this method can be used to ...
void fancy_string_array_push_value(fancy_string_array_t *const self, char const *const value)
Instantiates a string object, with internal state set to value , and appends it at the end of the arr...
fancy_string_t * fancy_string_create(char const *const value)
Instantiates a string object with its internal state specified by the value parameter.
size_t fancy_string_array_size(fancy_string_array_t const *const self)
Returns the array object's size; i.e., the number of fancy_string_t instances it contains.
fancy_string_t * fancy_string_clone(fancy_string_t const *const self)
Creates a memory-independent copy of the fancy_string_t instance (i.e., self ).
fancy_string_t * fancy_string_uppercased(fancy_string_t const *const self)
Creates a new string object whose internal data corresponds to a copy of self with an uppercase trans...
void fancy_string_update(fancy_string_t *const self, fancy_string_t const *const string)
Updates the internal state of the string object using that of another string object (i....
void fancy_string_array_for_each(fancy_string_array_t *const self, fancy_string_for_each_t fn, void *context)
Iterates over the array object's elements and calls the fn callback with each element (i....
fancy_string_t * fancy_string_array_remove(fancy_string_array_t *const self, size_t index)
Removes and returns the pointer to the fancy_string_t instance located at position index inside the a...
void fancy_string_array_splice_and_destroy(fancy_string_array_t *const self, size_t index, ssize_t delete_count, fancy_string_array_t const *const optional_new_strings)
Splices the array object's internal list and destroys the removed elements (if any).
bool fancy_string_equals_value(fancy_string_t const *const self, char const *const value)
Checks whether the string object's internal value equals to value .
fancy_string_t * fancy_string_array_last(fancy_string_array_t const *const self)
Returns a memory-independent copy of the array object's internal list's last string object.
void fancy_string_array_sort_values(fancy_string_array_t *const self)
Sorts the array object's internal list's elements based on their internal values, in the most basic w...
bool(* fancy_string_sort_t)(fancy_string_t const *const string_1, fancy_string_t const *const string_2, void *context)
The signature a callback function needs to implement to be allowed to be passed as argument to the fa...
Definition: fancy_string.h:1443
void fancy_string_library_version(uint16_t *major, uint16_t *minor, uint16_t *revision)
Populates its arguments with the library's version.
fancy_string_t * fancy_string_regex_replaced_matches(fancy_string_regex_t *const self, fancy_string_t *new_string)
Creates and returns a new string object whose internal string data is equivalent to the regular expre...
fancy_string_array_t * fancy_string_array_mapped(fancy_string_array_t const *const self, fancy_string_mapped_t fn, void *context)
Iterates over the array object's elements and calls the fn callback with each element (i....
void fancy_string_array_reverse(fancy_string_array_t *const self)
Reverses the order of the elements in the array object's internal list.
bool fancy_string_contains_value(fancy_string_t const *const self, char const *const value)
Checks whether the string object's data contains at least one occurrence of value .
fancy_string_array_t * fancy_string_array_reversed(fancy_string_array_t const *const self)
Clones the array object and reverses the clone's element before returning it.
void fancy_string_prepend_value(fancy_string_t *const self, char const *const value)
Prepends a (string) value to the current string object's internal state.
bool fancy_string_is_empty(fancy_string_t const *const self)
Checks whether the string is empty.
fancy_string_regex_match_info_t fancy_string_regex_match_info_for_index(fancy_string_regex_t const *const self, size_t index)
Retrieves and returns the match information in a fancy_string_regex_t instance for the specified posi...
fancy_string_t * fancy_string_padded_end(fancy_string_t const *const self, size_t target_size, char value)
Creates a string object whose right-hand side has been padded with the specified character (i....
bool fancy_string_array_includes(fancy_string_array_t const *const self, fancy_string_t const *const string)
Checks whether a string object's internal value is contained inside the array object's internal list.
void fancy_string_line_break(fancy_string_t *const self, bool with_carriage_return)
Appends a line break character (i.e., \\n) at the end of the object's internal string data.
fancy_string_t * fancy_string_create_repeat(char const *const value, size_t n_repeat)
Similarly to fancy_string_create(), instantiates a string object, but repeats the initial value the s...
char * fancy_string_array_first_value(fancy_string_array_t const *const self)
Returns a memory-independent copy of the array object's internal list's first string object's interna...
fancy_string_memory_usage_mode_e
An enumeration whose members can be used to specify, through the fancy_string_memory_usage_init() sta...
Definition: fancy_string.h:122
@ FANCY_STRING_MEMORY_USAGE_MODE_NONE
Disables the library's memory usage tracking feature. This is the default behaviour.
Definition: fancy_string.h:127
@ FANCY_STRING_MEMORY_USAGE_MODE_GLOBAL_SYNC
Tracks memory usage and stores the tracking data in a private static variable shared by all threads....
Definition: fancy_string.h:146
@ FANCY_STRING_MEMORY_USAGE_MODE_THREAD_LOCAL
Tracks memory usage and stores the tracking data in a private static variable for each thread using t...
Definition: fancy_string.h:138
size_t fancy_string_memory_usage_get(void)
A "static method" that retrieves and returns the amount of memory allocated by the library.
bool fancy_string_ends_with_value(fancy_string_t const *const self, char const *const value)
Checks whether the string object's internal value ends with value .
void fancy_string_lowercase(fancy_string_t *const self)
Applies a lowercase transformation to the string object's internal data.
ssize_t fancy_string_array_last_index_of(fancy_string_array_t const *const self, fancy_string_t const *const string)
Finds the index of the last element in the array object's internal list whose internal value is equal...
void fancy_string_array_pop_and_destroy(fancy_string_array_t *const self)
Removes and destroys the array object's internal list's last element.
void fancy_string_array_clear(fancy_string_array_t *const self)
Clears (i.e, empties) the array; i.e., destroys all of the internal fancy_string_t instances and free...
fancy_string_array_t * fancy_string_array_filtered(fancy_string_array_t const *const self, fancy_string_filter_t fn, void *context)
Clones the array object (i.e., self ) and performs filtering on that clone, based on the rules establ...
fancy_string_array_t * fancy_string_array_sliced(fancy_string_array_t const *const self, ssize_t start, ssize_t end)
Creates a memory-independent slice of the array object.
fancy_string_array_t * fancy_string_regex_split_at_matches(fancy_string_regex_t const *const self)
Uses the matches as separators for splitting the regular expression object's string into an array obj...
void fancy_string_array_filter(fancy_string_array_t *const self, fancy_string_filter_t fn, void *context)
Filters (therefore likely mutates) the array object's internal list's elements based on the rules est...
fancy_string_array_t * fancy_string_split_by_value(fancy_string_t const *const self, char const *const separator, ssize_t n_max_splits)
Splits the string into an array (i.e., a list) of string objects based on the separator .
fancy_string_array_t * fancy_string_array_sorted_values(fancy_string_array_t const *const self)
Clones the array object and then sorts the clone's internal list's elements based on their internal v...
void fancy_string_regex_destroy(fancy_string_regex_t *const self)
Destroys the regular expression object.
void fancy_string_array_push(fancy_string_array_t *const self, fancy_string_t const *const string)
Appends a memory-independent copy of the string object string at the end of the array object's intern...
fancy_string_array_t * fancy_string_array_create(void)
Instantiates an empty array object (i.e, a list whose components are string objects).
void(* fancy_string_regex_updater_t)(fancy_string_t *const match, size_t start, size_t end, fancy_string_t const *const string, void *context)
The signature a callback function needs to implement to be allowed to be passed as argument to the fa...
Definition: fancy_string.h:964
fancy_string_array_t * fancy_string_array_splice(fancy_string_array_t *const self, size_t index, ssize_t delete_count, fancy_string_array_t const *const optional_new_strings)
Splices the array object's internal list and returns the removed elements (if any) in a new array obj...
void(* fancy_string_for_each_t)(fancy_string_t *const string, size_t index, fancy_string_array_t const *const array, void *context)
The signature a callback function needs to implement to be allowed to be passed as argument to the fa...
Definition: fancy_string.h:1383
fancy_string_t * fancy_string_array_first(fancy_string_array_t const *const self)
Returns a memory-independent copy of the array object's internal list's first string object.
void fancy_string_memory_usage_init(fancy_string_memory_usage_mode_t mode)
If called, specifies the memory usage tracking mode to be used by the library.
void fancy_string_print(fancy_string_t const *const self, FILE *stream, bool debug)
Prints (i.e., writes) the string object's data to the specified stream .
fancy_string_t * fancy_string_regex_string_for_match_at_index(fancy_string_regex_t const *const self, size_t index)
Retrieves the index -th matched character sequence (if any), and returns it as a memory-independent s...
bool fancy_string_array_none(fancy_string_array_t const *const self, fancy_string_find_t fn, void *context)
Checks whether there are no elements in the array object's internal list for which fn returns true.
void fancy_string_append_value(fancy_string_t *const self, char const *const value)
Appends a (string) value to the current string object's internal state.
void fancy_string_pad_end(fancy_string_t *const self, size_t target_size, char value)
Pads the right-hand side of the string with the specified character (i.e., value ).
fancy_string_t * fancy_string_create_empty(void)
Similarly to fancy_string_create(), instantiates a string object, but with its internal value set to ...
bool fancy_string_regex_has_match(fancy_string_regex_t const *const self)
Checks whether there was at least one match in the regular expression object pointed to by self .
struct fancy_string_s fancy_string_t
An opaque type that serves as a container for the string data and which is passed to the library's "s...
Definition: fancy_string.h:54
void fancy_string_array_print(fancy_string_array_t const *const self, FILE *stream, bool debug)
Prints (i.e., writes) the array's string contents to the specified stream .
enum fancy_string_memory_usage_mode_e fancy_string_memory_usage_mode_t
An enumeration whose members can be used to specify, through the fancy_string_memory_usage_init() sta...
fancy_string_t *(* fancy_string_mapped_t)(fancy_string_t const *const string, size_t index, fancy_string_array_t const *const array, void *context)
The signature a callback function needs to implement to be allowed to be passed as argument to the fa...
Definition: fancy_string.h:1410
void fancy_string_pad_start(fancy_string_t *const self, size_t target_size, char value)
Pads the left-hand side of the string with the specified character (i.e., value ).
ssize_t fancy_string_index_of_value(fancy_string_t const *const self, char const *const value)
Finds and returns the index of the first occurrence of value in the string object's internal value,...
fancy_string_t * fancy_string_array_find_last(fancy_string_array_t const *const self, fancy_string_find_t fn, void *context)
Finds the last element in the array object's internal list for which fn returns true and returns a me...
fancy_string_t * fancy_string_regex_pattern(fancy_string_regex_t const *const self)
Retrieves and returns the regular expression object's pattern as a memory-independent string object.
void fancy_string_array_insert(fancy_string_array_t *const self, fancy_string_t const *const string, size_t index)
Inserts a memory-independent copy of the string object string at the specified position index inside ...
void fancy_string_array_slice_and_destroy(fancy_string_array_t *const self, ssize_t start, ssize_t end)
Slices the array object self based on the start and end positions, preserving the elements in that ra...
fancy_string_t * fancy_string_array_join(fancy_string_array_t const *const self, fancy_string_t const *const separator)
Creates (and returns a pointer to) a fancy_string_t instance and populates it with copies of the arra...
void fancy_string_array_append_and_destroy(fancy_string_array_t *const self, fancy_string_array_t *array)
Appends the elements of another array object (i.e., array) into the current array object (i....
ssize_t fancy_string_array_last_index_of_value(fancy_string_array_t const *const self, char const *const value)
Finds the index of the last element in the array object's internal list whose internal value is equal...
bool fancy_string_contains(fancy_string_t const *const self, fancy_string_t const *const string)
Checks whether the string object's data contains at least one occurrence of string 's internal value.
ssize_t fancy_string_regex_max_number_of_matches(fancy_string_regex_t const *const self)
Retrieves and returns the n_max_matches value (i.e., the maximum number of matches allowed for the re...
fancy_string_t * fancy_string_from_stream(FILE *stream)
Instantiates a string object and fills its internal state with the string data read from stream .
ssize_t fancy_string_array_find_last_index(fancy_string_array_t const *const self, fancy_string_find_t fn, void *context)
Finds the last element in the array object's internal list for which fn returns true and returns that...
fancy_string_t * fancy_string_array_find(fancy_string_array_t const *const self, fancy_string_find_t fn, void *context)
Finds the first element in the array object's internal list for which fn returns true and returns a m...
size_t start
The 'start' position of the match at position index .
Definition: fancy_string.h:101
void fancy_string_trim_right(fancy_string_t *const self)
Trims (i.e., remove all the white spaces from) the right-hand side of the string object's internal va...
void fancy_string_array_shift_and_destroy(fancy_string_array_t *const self)
Removes and destroys the array object's internal list's first element.
void fancy_string_array_push_values(fancy_string_array_t *const self, char const *const first_value,...)
Instantiates a variable number of string objects with internal states set to first_value and ....
void fancy_string_trim(fancy_string_t *const self)
Trims (i.e., remove all the white spaces from) both the right and left-hand sides of the string objec...
bool(* fancy_string_find_t)(fancy_string_t const *const string, size_t index, fancy_string_array_t const *const array, void *context)
The signature a callback function needs to implement to be allowed to be passed as argument to method...
Definition: fancy_string.h:1640
void fancy_string_array_sort(fancy_string_array_t *const self, fancy_string_sort_t fn, void *context)
Sorts the array object's internal list's elements based on the rules established by the fn callback.
bool fancy_string_regex_max_number_of_matches_reached(fancy_string_regex_t const *const self)
Checks, for self , whether a maximum number of matches was set and, if so, whether that number was re...
size_t end
The 'end' position of the match at position index .
Definition: fancy_string.h:108
void fancy_string_array_destroy(fancy_string_array_t *const self)
Destroys the array object; i.e., frees the memory that was allocated for the internal pointers to fan...
void fancy_string_trim_left(fancy_string_t *const self)
Trims (i.e., remove all the white spaces from) the left-hand side of the string object's internal val...
bool fancy_string_starts_with(fancy_string_t const *const self, fancy_string_t const *const string)
Checks whether the string object's internal value starts with string 's internal value.
fancy_string_memory_usage_mode_t fancy_string_memory_usage_mode(void)
Retrieves and returns the current memory usage mode used by the library, for the current process.
fancy_string_t * fancy_string_replaced(fancy_string_t const *const self, fancy_string_t const *const old_substring, fancy_string_t const *const new_substring, ssize_t replace_n)
Creates a string object with the specified number of occurrences (i.e., replace_n ) of old_substring ...
ssize_t fancy_string_array_index_of(fancy_string_array_t const *const self, fancy_string_t const *const string)
Finds the index of the first element in the array object's internal list whose internal value is equa...
void fancy_string_array_remove_and_destroy(fancy_string_array_t *const self, size_t index)
Removes and destroys the fancy_string_t instance located at position index inside the array object.
bool fancy_string_array_every(fancy_string_array_t const *const self, fancy_string_find_t fn, void *context)
Checks whether fn returns true for all of the elements in the array object's internal list.
void fancy_string_memory_usage_debug(FILE *stream)
A "static method" that can be used to "print" a summary of the library's memory usage.
size_t fancy_string_size(fancy_string_t const *const self)
Returns the size of the object's internal string (conceptually the same as strlen() ).
fancy_string_t * fancy_string_array_shift(fancy_string_array_t *const self)
Removes the first element from the array object's internal list and returns a pointer to it.
fancy_string_t * fancy_string_trimmed_right(fancy_string_t const *const self)
Creates a right-hand-trimmed version of the string object (i.e., a version with all the trailing whit...
ssize_t fancy_string_index_of(fancy_string_t const *const self, fancy_string_t const *const string)
Finds and returns the index of the first occurrence of string 's internal value in self 's internal v...
fancy_string_array_t * fancy_string_regex_matches_to_strings(fancy_string_regex_t const *const self)
Creates and returns an array object whose internal components correspond to the regular expression ob...
bool fancy_string_array_some(fancy_string_array_t const *const self, fancy_string_find_t fn, void *context)
Checks whether there is at least one element in the array object's internal list for which fn returns...
void fancy_string_clear(fancy_string_t *const self)
Clears the internal string data (i.e., makes self an empty string object).
fancy_string_t * fancy_string_regex_string(fancy_string_regex_t const *const self)
Retrieves and returns the regular expression object's content string (i.e., the string to be searched...
fancy_string_array_t * fancy_string_array_spliced(fancy_string_array_t const *const self, size_t index, ssize_t delete_count, fancy_string_array_t const *const optional_new_strings)
Clones self and calls fancy_string_array_splice_and_destroy on that clone.
void fancy_string_replace(fancy_string_t *const self, fancy_string_t const *const old_substring, fancy_string_t const *const new_substring, ssize_t replace_n)
Replaces the specified number of occurrences (i.e., replace_n ) of old_substring 's internal value wi...
fancy_string_t * fancy_string_padded_start(fancy_string_t const *const self, size_t target_size, char value)
Creates a string object whose left-hand side has been padded with the specified character (i....
fancy_string_t * fancy_string_array_get(fancy_string_array_t const *const self, size_t index)
Returns a memory-independent copy of the fancy_string_t instance located at position index inside the...
bool fancy_string_ends_with(fancy_string_t const *const self, fancy_string_t const *const string)
Checks whether the string object's internal value ends with string 's internal value.
fancy_string_t * fancy_string_from_stream_next_line(FILE *stream)
Reads the next line from the stream and instantiates a string object with internal state set as the "...
fancy_string_array_t * fancy_string_array_create_with_values(char const *const first_value,...)
Instantiates an array object with a variable list of string values (i.e., pointers to a null-terminat...
void fancy_string_destroy(fancy_string_t *const self)
Destroys the string object; i.e., frees the memory that was allocated for the internal string data,...
void fancy_string_library_version_print(FILE *stream)
Prints (i.e., writes) the library's version to the specified stream.
fancy_string_t * fancy_string_trimmed(fancy_string_t const *const self)
Creates a trimmed version of the string object (i.e., a version with all the leading and trailing whi...
void fancy_string_append(fancy_string_t *const self, fancy_string_t const *const string)
Appends a string object's data (in this case string ) to the current string object's internal state (...
void fancy_string_uppercase(fancy_string_t *const self)
Applies an uppercase transformation to the string object's internal data.
fancy_string_array_t * fancy_string_array_sorted(fancy_string_array_t const *const self, fancy_string_sort_t fn, void *context)
Creates a sorted copy of self .
struct fancy_string_array_s fancy_string_array_t
An opaque type that serves as a container for a list of fancy_string_t instances and which is passed ...
Definition: fancy_string.h:68
ssize_t fancy_string_array_find_index(fancy_string_array_t const *const self, fancy_string_find_t fn, void *context)
Finds the first element in the array object's internal list for which fn returns true and returns tha...
size_t fancy_string_regex_match_count(fancy_string_regex_t const *const self)
Returns the number of matches obtained for the regular expression object pointed to by self .
void fancy_string_array_insert_value(fancy_string_array_t *const self, char const *const value, size_t index)
Instantiates a fancy_string_t object, with its internal state set as value , and inserts it at the sp...
ssize_t index
The index (i.e., the position) of the match inside the fancy_string_regex_t instance.
Definition: fancy_string.h:97
char * fancy_string_array_last_value(fancy_string_array_t const *const self)
Returns a memory-independent copy of the array object's internal list's last string object's internal...
fancy_string_t * fancy_string_array_pop(fancy_string_array_t *const self)
Removes the last element from the array object's internal list and returns a pointer to it.
fancy_string_t * fancy_string_trimmed_left(fancy_string_t const *const self)
Creates a left-hand-trimmed version of the string object (i.e., a version with all the leading white ...
fancy_string_t * fancy_string_lowercased(fancy_string_t const *const self)
Creates a new string object whose internal data corresponds to a copy of self with a lowercase transf...
struct fancy_string_regex_match_info_s fancy_string_regex_match_info_t
A type (i.e., a structure), returned by the fancy_string_regex_match_info_for_index() method,...
fancy_string_t * fancy_string_from_copied_memory(void const *const pointer, size_t n)
Instantiates a string object with initial internal state obtained by copying n bytes from pointer .
ssize_t fancy_string_array_index_of_value(fancy_string_array_t const *const self, char const *const value)
Finds the index of the first element in the array object's internal list whose internal value is equa...
bool fancy_string_array_is_empty(fancy_string_array_t const *const self)
Checks whether the array is empty.
A type (i.e., a structure), returned by the fancy_string_regex_match_info_for_index() method,...
Definition: fancy_string.h:90