TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle
tm_stm32_string.h
1 
37 #ifndef TM_STRING_H
38 #define TM_STRING_H 100
39 
40 /* C++ detection */
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
81 #include "stm32fxxx_hal.h"
82 #include "defines.h"
83 
84 #include "string.h"
85 #include "stdlib.h"
86 
93 /* Memory allocation function */
94 #ifndef LIB_ALLOC_FUNC
95 #define LIB_ALLOC_FUNC malloc
96 #endif
97 
98 /* Memory free function */
99 #ifndef LIB_FREE_FUNC
100 #define LIB_FREE_FUNC free
101 #endif
102 
116 typedef struct {
117  char** Strings;
118  uint32_t Count;
119  uint32_t Size;
120 } TM_STRING_t;
121 
140 TM_STRING_t* TM_STRING_Create(uint16_t count);
141 
150 uint16_t TM_STRING_AddString(TM_STRING_t* String, char* str);
151 
161 TM_STRING_t* TM_STRING_ReplaceString(TM_STRING_t* String, uint16_t pos, char* str);
162 
170 TM_STRING_t* TM_STRING_DeleteString(TM_STRING_t* String, uint16_t pos);
171 
179 char* TM_STRING_GetString(TM_STRING_t* String, uint16_t pos);
180 
187 void TM_STRING_FreeAll(TM_STRING_t* String);
188 
195 #define TM_STRING_GetCount(str) ((str)->Count)
196 
204 void TM_STRING_Free(TM_STRING_t* String);
205 
218 /* C++ detection */
219 #ifdef __cplusplus
220 }
221 #endif
222 
223 #endif
void TM_STRING_Free(TM_STRING_t *String)
Free main structure and pointer to all pointers.
uint32_t Size
Definition: tm_stm32_string.h:119
TM_STRING_t * TM_STRING_Create(uint16_t count)
Creates and allocated string structure and memory for pointers for desired number of strings...
uint32_t Count
Definition: tm_stm32_string.h:118
TM_STRING_t * TM_STRING_ReplaceString(TM_STRING_t *String, uint16_t pos, char *str)
Replaces already added string with new string.
void TM_STRING_FreeAll(TM_STRING_t *String)
Free all. It will free all strings, all pointers to strings and also main string structure.
char * TM_STRING_GetString(TM_STRING_t *String, uint16_t pos)
Gets pointer to string at desired position.
char ** Strings
Definition: tm_stm32_string.h:117
uint16_t TM_STRING_AddString(TM_STRING_t *String, char *str)
Adds new string to main string structure.
TM_STRING_t * TM_STRING_DeleteString(TM_STRING_t *String, uint16_t pos)
Deletes string from strings array.
Main string structure.
Definition: tm_stm32_string.h:116