libcproject
C static library easier to use than libc (C standard library).
string.h
Go to the documentation of this file.
1 #ifndef __LIBCPROJECT_STRING__
2 #define __LIBCPROJECT_STRING__
3 
4 #include <errno.h>
5 #include <stdbool.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 
9 #include "character.h"
10 #include "convert.h"
11 #include "hash_map.h"
12 #include "types.h"
13 
21 size_t string_get_length(const string_t string);
22 
32 
42 
53 void string_replace(string_t string, char search, char replace);
54 
64 void string_remove_character(string_t string, char search);
65 
74 void string_trim_start(string_t string, char character);
75 
84 void string_trim_end(string_t string, char character);
85 
94 void string_trim(string_t string, char character);
95 
104 
114 
123 size_t string_total_occurrences_of_character(string_t string, char character);
124 
133 void string_reverse(const string_t string);
134 
144 bool string_equals(const string_t string1, const string_t string2);
145 
154 bool string_get_is_integer(const string_t string);
155 
165 string_t* string_split(const string_t string, char separator, size_t* result_size);
166 
176 string_t string_join(string_t* array, const char separator, size_t array_length);
177 
187 void string_concatenate(string_t* destination, string_t source);
188 
198 
208 string_t string_substring(const string_t string, size_t index_start, size_t index_end);
209 
219 bool string_get_is_substring(const string_t string, const string_t substring);
220 
235 string_t string_get_formatted_number(const int64_t number, string_t separator);
236 
246 
256 bool string_starts_with(const string_t string, const string_t prefix);
257 
267 bool string_ends_with(const string_t string, const string_t prefix);
268 
281 size_t string_position_of(const string_t string, const char character);
282 
295 size_t string_last_position_of(const string_t string, const char character);
296 
310 string_t string_pad_start(const string_t string, const string_t pad_string, size_t target_length);
311 
326 string_t string_zero_pad(uint64_t number, size_t places);
327 
328 #endif
string_t string_get_last_occurence_of_character(const string_t string, char character)
Returns a pointer to the last occurrence of character in the string.
void string_to_lowercase(string_t string)
Converts all the alphabetic characters in a string to lowercase.
void string_trim(string_t string, char character)
Removes all character from the start and end of a string.
string_t * string_split(const string_t string, char separator, size_t *result_size)
Split a string into substrings using the specified separator and return them as an array and update t...
bool string_equals(const string_t string1, const string_t string2)
Check if two strings are equals.
bool string_get_is_substring(const string_t string, const string_t substring)
Check if a string contains a substring.
string_t string_get_formatted_number(const int64_t number, string_t separator)
Format a number to a string with specified separator.
size_t string_last_position_of(const string_t string, const char character)
Returns the position (index + 1) within the string of the last occurrence of the specified substring ...
string_t string_pad_start(const string_t string, const string_t pad_string, size_t target_length)
Pads a string with another pad_string (multiple times, if needed) until the resulting string reaches ...
void string_replace(string_t string, char search, char replace)
Replace all the occurrences of search value into replace value in the string.
void string_concatenate(string_t *destination, string_t source)
Concatenate two strings.
void string_to_uppercase(string_t string)
Converts all the alphabetic characters in a string to uppercase.
string_t string_join(string_t *array, const char separator, size_t array_length)
Adds all the elements of an array into a string, separated by the specified separator string.
size_t string_total_occurrences_of_character(string_t string, char character)
Returns the total number of occurrences of the given character in the string.
bool string_starts_with(const string_t string, const string_t prefix)
Check if a string starts with a substring.
string_t string_zero_pad(uint64_t number, size_t places)
Pad a number with zeros.
bool string_get_is_integer(const string_t string)
Check if the string is an integer.
void string_capitalize(string_t string)
Capitalizes the string.
bool string_ends_with(const string_t string, const string_t prefix)
Check if a string ends with a substring.
void string_trim_end(string_t string, char character)
Removes all character from the end of a string.
void string_reverse(const string_t string)
Reverse the characters in a string.
void string_trim_start(string_t string, char character)
Removes all character from the start of a string.
size_t string_get_length(const string_t string)
Return the length of a string (excluding '\0').
bool string_get_has_unique_characters(const string_t string)
Check if a string contains only unique characters.
string_t string_copy(const string_t string)
Return the copy of a string.
string_t string_substring(const string_t string, size_t index_start, size_t index_end)
Returns the part of the string between the start and end indexes (both included).
void string_remove_character(string_t string, char search)
Removes all the occurrences of a character in a string.
size_t string_position_of(const string_t string, const char character)
Returns the position (index + 1) within the string of the first occurrence of the specified substring...
char * string_t
Definition: types.h:8