refactor(string): add docs

This commit is contained in:
2025-09-10 16:51:45 +02:00
parent 8957d565f8
commit 7b6da3fdc3

View File

@@ -117,17 +117,43 @@ int string_tolower(string_s *string);
*/ */
int string_find(string_s *string, const char *substring); int string_find(string_s *string, const char *substring);
/**
* @brief Create a formatted string (like printf).
*
* @param fmt Format string.
* @param ... Arguments for format.
* @return New string, or NULL on failure.
*/
string_s *string_format(const char *fmt, ...); string_s *string_format(const char *fmt, ...);
/**
* @brief Insert text at a specific position.
*
* @param string String to modify.
* @param index Position where to insert.
* @param text Text to insert.
* @return 0 on success, -1 on failure.
*/
int string_insert(string_s *string, size_t index, const char *text); int string_insert(string_s *string, size_t index, const char *text);
/**
* @brief Replace all occurrences of a substring with another.
*
* @param string String to modify.
* @param old_text Substring to replace.
* @param new_text Replacement text.
* @return 0 on success, -1 on failure.
*/
int string_replace(string_s *string, const char *old_text, const char *new_text); int string_replace(string_s *string, const char *old_text, const char *new_text);
/**
* @brief Remove part of the string.
*
* @param string String to modify.
* @param index Starting position.
* @param length Number of characters to remove.
* @return 0 on success, -1 on failure.
*/
int string_remove(string_s *string, size_t index, size_t length); int string_remove(string_s *string, size_t index, size_t length);
// TODO
// string_trim(string_s *string)
// string_reverse(string_s *string)
// string_split(string_s *string, const char *delim, string_s ***out, size_t *count) ??
#endif /* MYCLIB_STRING_H */ #endif /* MYCLIB_STRING_H */