TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
tm_stm32f4_string.h
1 
30 #ifndef TM_STRING_H
31 #define TM_STRING_H 110
32 
33 /* C++ detection */
34 #ifdef __cplusplus
35 extern C {
36 #endif
37 
77 #include "stm32f4xx.h"
78 #include "defines.h"
79 
80 #include "string.h"
81 #include "stdlib.h"
82 
89 /* Memory allocation function */
90 #ifndef LIB_ALLOC_FUNC
91 #define LIB_ALLOC_FUNC malloc
92 #endif
93 
94 /* Memory free function */
95 #ifndef LIB_FREE_FUNC
96 #define LIB_FREE_FUNC free
97 #endif
98 
112 typedef struct {
113  char** Strings;
114  uint32_t Count;
115  uint32_t Size;
116 } TM_STRING_t;
117 
136 TM_STRING_t* TM_STRING_Create(uint16_t count);
137 
146 uint16_t TM_STRING_AddString(TM_STRING_t* String, char* str);
147 
157 TM_STRING_t* TM_STRING_ReplaceString(TM_STRING_t* String, uint16_t pos, char* str);
158 
166 TM_STRING_t* TM_STRING_DeleteString(TM_STRING_t* String, uint16_t pos);
167 
175 char* TM_STRING_GetString(TM_STRING_t* String, uint16_t pos);
176 
183 void TM_STRING_FreeAll(TM_STRING_t* String);
184 
191 #define TM_STRING_GetCount(str) ((str)->Count)
192 
200 void TM_STRING_Free(TM_STRING_t* String);
201 
214 /* C++ detection */
215 #ifdef __cplusplus
216 }
217 #endif
218 
219 #endif
void TM_STRING_Free(TM_STRING_t *String)
Free main structure and pointer to all pointers.
uint32_t Size
Definition: tm_stm32f4_string.h:115
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_stm32f4_string.h:114
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_stm32f4_string.h:113
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_stm32f4_string.h:112