Foundations
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#ifndef INCLUDED_C_STRUTIL_H
|
||||
#define INCLUDED_C_STRUTIL_H
|
||||
|
||||
#ifndef INCLUDED_C_TYPES_H
|
||||
#include <c_Types.h>
|
||||
#endif /*INCLUDED_C_TYPES_H*/
|
||||
|
||||
#ifndef INCLUDED_C_ARRAYLIST_H
|
||||
#include <c_ArrayList.h>
|
||||
#endif /*INCLUDED_C_ARRAYLIST_H*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
#ifndef C_STR_TOKEN_MAX_LEN
|
||||
#define C_STR_TOKEN_MAX_LEN 64
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
char text[C_STR_TOKEN_MAX_LEN];
|
||||
} c_StrToken_t;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
void c_StrUtil_Reverse(char* str);
|
||||
c_err_t c_StrUtil_ToLower(char* out_dest, const char* src, c_size_t dest_capacity);
|
||||
c_err_t c_StrUtil_ToUpper(char* out_dest, const char* src, c_size_t dest_capacity);
|
||||
|
||||
// Trimming whitespace (' ', '\t', '\r', '\n')
|
||||
c_err_t c_StrUtil_Trim(char* out_dest, const char* src, c_size_t dest_capacity);
|
||||
|
||||
// Search & Matching operations
|
||||
c_bool_t c_StrUtil_StartsWith(const char* str, const char* prefix);
|
||||
c_bool_t c_StrUtil_EndsWith(const char* str, const char* suffix);
|
||||
|
||||
// Substring extraction (Safe, boundary checked)
|
||||
c_err_t c_StrUtil_Substring(char* out_dest, const char* src, c_size_t start, c_size_t len, c_size_t dest_capacity);
|
||||
|
||||
// String replacements (Safely handles different length replacements)
|
||||
c_err_t c_StrUtil_Replace(char* out_dest, const char* src, const char* find, const char* replace_with, c_size_t dest_capacity);
|
||||
|
||||
// Tokenizer that breaks down a source string and appends results to an initialized ArrayList
|
||||
c_err_t c_StrUtil_Split(c_ArrayList_t* out_list, const char* src, const char* delimiter) ;
|
||||
|
||||
#endif /*INCLUDED_C_STRUTIL_H*/
|
||||
Reference in New Issue
Block a user