#ifndef _H_MCU_STR #define _H_MCU_STR #include "mcutil.h" #include #include #include #define mcu_str_append_cstr(to, from) mc_str_append((to), mc_str_new(from)) #define mcu_str_free(str) MCU_FREE((str)->inner) typedef struct mcu_str_s { char* inner; uint8_t _null; size_t len; size_t cap; } mcu_str_t; /// Creates a new owned string /// You can just use printf as normal with this cause you can safely cast this into char* MCU_API mcu_str_t mcu_str_new(const char* str); /// Append the string 'from' onto string 'to' MCU_API void mcu_str_append(mcu_str_t* to, const mcu_str_t* from); /// Strip the whitespace from the front of the string MCU_API void mcu_str_trim_front(mcu_str_t* str); /// Strip the whitespace from the front of the string MCU_API void mcu_str_trim_end(mcu_str_t* str); /// Strip the whitespace from the front and end of the string MCU_API void mcu_str_trim(mcu_str_t* str); /// Replace string 'from' to string 'to' /// Hopefully this works, i hope MCU_API void mcu_str_replace(mcu_str_t* str, const mcu_str_t* from, const mcu_str_t* to); #endif // _H_MCU_STR