lib<fancy_string> 0.1.0
A C library for easy and fun string manipulation
Loading...
Searching...
No Matches
fancy_string.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2023 BB-301 <fw3dg3@gmail.com>
3
4 Permission is hereby granted, free of charge, to any person
5 obtaining a copy of this software and associated documentation
6 files (the “Software”), to deal in the Software without restriction,
7 including without limitation the rights to use, copy, modify, merge,
8 publish, distribute, sublicense, and/or sell copies of the Software,
9 and to permit persons to whom the Software is furnished to do so,
10 subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included
13 in all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE.
22*/
23
28#ifndef __FANCY_STRING_H__
29#define __FANCY_STRING_H__
30
31#include <string.h>
32#include <stdlib.h>
33#include <stdio.h>
34#include <stdbool.h>
35#include <stdint.h>
36#include <stddef.h>
37#include <sys/types.h>
38
39// -----------------------------------------------
40// OPAQUE TYPES
41// -----------------------------------------------
42
54typedef struct fancy_string_s fancy_string_t;
55
68typedef struct fancy_string_array_s fancy_string_array_t;
69
82typedef struct fancy_string_regex_s fancy_string_regex_t;
83
90{
101 size_t start;
108 size_t end;
110
122{
148
149// -----------------------------------------------
150// MISC
151// -----------------------------------------------
152
161
168
183
195
216
224
225// -----------------------------------------------
226// STRING (methods)
227// -----------------------------------------------
228
236fancy_string_t *fancy_string_create(char const *const value);
237
255
275
285fancy_string_t *fancy_string_create_repeat(char const *const value, size_t n_repeat);
286
294
301
311
321void fancy_string_print(fancy_string_t const *const self, FILE *stream, bool debug);
322
328size_t fancy_string_size(fancy_string_t const *const self);
329
335bool fancy_string_is_empty(fancy_string_t const *const self);
336
342
352void fancy_string_update_value(fancy_string_t *const self, char const *const value);
353
360void fancy_string_update(fancy_string_t *const self, fancy_string_t const *const string);
361
371char *fancy_string_value(fancy_string_t const *const self);
372
381void fancy_string_append_value(fancy_string_t *const self, char const *const value);
382
391void fancy_string_append(fancy_string_t *const self, fancy_string_t const *const string);
392
401void fancy_string_prepend_value(fancy_string_t *const self, char const *const value);
402
411void fancy_string_prepend(fancy_string_t *const self, fancy_string_t const *const string);
412
421bool fancy_string_equals_value(fancy_string_t const *const self, char const *const value);
422
430bool fancy_string_equals(fancy_string_t const *const self, fancy_string_t const *const string);
431
441bool fancy_string_starts_with_value(fancy_string_t const *const self, char const *const value);
442
452bool fancy_string_starts_with(fancy_string_t const *const self, fancy_string_t const *const string);
453
463bool fancy_string_ends_with_value(fancy_string_t const *const self, char const *const value);
464
474bool fancy_string_ends_with(fancy_string_t const *const self, fancy_string_t const *const string);
475
486ssize_t fancy_string_index_of_value(fancy_string_t const *const self, char const *const value);
487
498ssize_t fancy_string_index_of(fancy_string_t const *const self, fancy_string_t const *const string);
499
507bool fancy_string_contains_value(fancy_string_t const *const self, char const *const value);
508
518bool fancy_string_contains(fancy_string_t const *const self, fancy_string_t const *const string);
519
537
544
554
561
571
579
589
603fancy_string_array_t *fancy_string_split_by_value(fancy_string_t const *const self, char const *const separator, ssize_t n_max_splits);
604
620fancy_string_array_t *fancy_string_split(fancy_string_t const *const self, fancy_string_t const *const separator, ssize_t n_max_splits);
621
631void fancy_string_pad_start(fancy_string_t *const self, size_t target_size, char value);
632
643fancy_string_t *fancy_string_padded_start(fancy_string_t const *const self, size_t target_size, char value);
644
652void fancy_string_pad_end(fancy_string_t *const self, size_t target_size, char value);
653
664fancy_string_t *fancy_string_padded_end(fancy_string_t const *const self, size_t target_size, char value);
665
678void fancy_string_replace_value(fancy_string_t *const self, char const *const old_value, char const *const new_value, ssize_t replace_n);
679
690void 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);
691
707fancy_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);
708
722fancy_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);
723
735
750
762
777
778// -----------------------------------------------
779// REGEX (methods)
780// -----------------------------------------------
781
805fancy_string_regex_t *fancy_string_regex_create(fancy_string_t const *const string, fancy_string_t const *const pattern, ssize_t n_max_matches);
806
812
820void fancy_string_regex_debug(fancy_string_regex_t const *const self, FILE *stream, bool verbose);
821
831
846
857
866
876
887
900
909
919
932typedef 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);
933
952
969
970// -----------------------------------------------
971// ARRAY (methods)
972// -----------------------------------------------
973
980
1001
1009
1020
1034
1044
1054void fancy_string_array_print(fancy_string_array_t const *const self, FILE *stream, bool debug);
1055
1062
1071
1078
1087void fancy_string_array_push_value(fancy_string_array_t *const self, char const *const value);
1088
1108void fancy_string_array_push_values(fancy_string_array_t *const self, char const *const first_value, ...);
1109
1118void fancy_string_array_push(fancy_string_array_t *const self, fancy_string_t const *const string);
1119
1132
1145char *fancy_string_array_get_value(fancy_string_array_t const *const self, size_t index);
1146
1161
1173
1185
1193
1205
1213
1227void fancy_string_array_insert_value(fancy_string_array_t *const self, char const *const value, size_t index);
1228
1242void fancy_string_array_insert(fancy_string_array_t *const self, fancy_string_t const *const string, size_t index);
1243
1253
1264
1275
1286
1296fancy_string_t *fancy_string_array_join_by_value(fancy_string_array_t const *const self, char const *const separator);
1297
1309
1317
1326
1337typedef void (*fancy_string_for_each_t)(fancy_string_t *const string, size_t index, fancy_string_array_t const *const array, void *context);
1338
1353
1364typedef 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);
1365
1386
1397typedef bool (*fancy_string_sort_t)(fancy_string_t const *const string_1, fancy_string_t const *const string_2, void *context);
1398
1409
1421
1432
1444
1457typedef bool (*fancy_string_filter_t)(fancy_string_t const *const string, size_t index, fancy_string_array_t const *const array, void *context);
1458
1472
1486
1503
1519
1541fancy_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);
1542
1560void 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);
1561
1580fancy_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);
1581
1594typedef bool (*fancy_string_find_t)(fancy_string_t const *const string, size_t index, fancy_string_array_t const *const array, void *context);
1595
1610
1626
1642
1658
1674bool fancy_string_array_some(fancy_string_array_t const *const self, fancy_string_find_t fn, void *context);
1675
1692bool fancy_string_array_none(fancy_string_array_t const *const self, fancy_string_find_t fn, void *context);
1693
1708bool fancy_string_array_every(fancy_string_array_t const *const self, fancy_string_find_t fn, void *context);
1709
1724
1737ssize_t fancy_string_array_index_of_value(fancy_string_array_t const *const self, char const *const value);
1738
1753
1766ssize_t fancy_string_array_last_index_of_value(fancy_string_array_t const *const self, char const *const value);
1767
1779bool fancy_string_array_includes(fancy_string_array_t const *const self, fancy_string_t const *const string);
1780
1792bool fancy_string_array_includes_value(fancy_string_array_t const *const self, char const *const value);
1793
1794#endif
void void
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:1457
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:1397
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.
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:932
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:1337
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 .
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:1364
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:1594
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,...
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
ssize_t ssize_t