comparison dowa/dowa.h @ 72:4532ce6d9eb8

[Seobeo] Added router to the server logic. Few dowa string manipulation logics.
author June Park <parkjune1995@gmail.com>
date Mon, 29 Dec 2025 07:50:07 -0800
parents 75de5903355c
children 4b96794c8d59
comparison
equal deleted inserted replaced
71:75de5903355c 72:4532ce6d9eb8
64 } Dowa_Arena; 64 } Dowa_Arena;
65 65
66 DLAPI Dowa_Arena *Dowa_Arena_Create(size_t capacity); 66 DLAPI Dowa_Arena *Dowa_Arena_Create(size_t capacity);
67 DLAPI void *Dowa_Arena_Allocate(Dowa_Arena *p_arena, size_t size); 67 DLAPI void *Dowa_Arena_Allocate(Dowa_Arena *p_arena, size_t size);
68 DLAPI void *Dowa_Arena_Allocate_Aligned(Dowa_Arena *p_arena, size_t size, size_t alignment); 68 DLAPI void *Dowa_Arena_Allocate_Aligned(Dowa_Arena *p_arena, size_t size, size_t alignment);
69 DLAPI void Dowa_Arena_Destroy(Dowa_Arena *p_arena); 69 DLAPI void Dowa_Arena_Free(Dowa_Arena *p_arena);
70 DLAPI void *Dowa_Arena_Copy(Dowa_Arena *p_arena, const void *p_src, size_t size); 70 DLAPI void *Dowa_Arena_Copy(Dowa_Arena *p_arena, const void *p_src, size_t size);
71 DLAPI void Dowa_Arena_Reset(Dowa_Arena *p_arena); 71 DLAPI void Dowa_Arena_Reset(Dowa_Arena *p_arena);
72 DLAPI size_t Dowa_Arena_Get_Used(Dowa_Arena *p_arena); 72 DLAPI size_t Dowa_Arena_Get_Used(Dowa_Arena *p_arena);
73 DLAPI size_t Dowa_Arena_Get_Remaining(Dowa_Arena *p_arena); 73 DLAPI size_t Dowa_Arena_Get_Remaining(Dowa_Arena *p_arena);
74 74
209 DLAPI void dowa__hashmap_delete(void* p_map, size_t element_size, void* p_key, size_t key_size); 209 DLAPI void dowa__hashmap_delete(void* p_map, size_t element_size, void* p_key, size_t key_size);
210 DLAPI void dowa__hashmap_clear(void* p_map, size_t element_size); 210 DLAPI void dowa__hashmap_clear(void* p_map, size_t element_size);
211 DLAPI void dowa__hashmap_free(void* p_map); 211 DLAPI void dowa__hashmap_free(void* p_map);
212 DLAPI size_t dowa__hashmap_count(void* p_map); 212 DLAPI size_t dowa__hashmap_count(void* p_map);
213 213
214 // --- OLD API (kept for reference, will be removed after migration) --- //
215 /*
216
217
218 OLD HashMap API - Commented out for migration
219 typedef enum {
220 DOWA_HASH_MAP_TYPE_BUFFER,
221 DOWA_HASH_MAP_TYPE_STRING,
222 DOWA_HASH_MAP_TYPE_HASHMAP,
223 DOWA_HASH_MAP_TYPE_INT
224 } Dowa_HashMap_ValueType;
225
226 typedef struct Dowa_HashEntry {
227 char *key;
228 void *buffer;
229 size_t capacity;
230 Dowa_HashMap_ValueType type;
231 struct Dowa_HashEntry *next;
232 } Dowa_HashEntry;
233
234 typedef struct {
235 Dowa_HashEntry **entries;
236 size_t capacity;
237 uint32 current_capacity;
238 Dowa_Arena *p_arena;
239 } Dowa_HashMap;
240
241 extern Dowa_HashMap *Dowa_HashMap_Create(size_t capacity);
242 extern Dowa_HashMap *Dowa_HashMap_Create_With_Arena(size_t capacity, Dowa_Arena *arena);
243 extern void Dowa_HashMap_Destroy(Dowa_HashMap *p_hash_map);
244 extern int32 Dowa_HashMap_Get_Position(Dowa_HashMap *p_hash_map, const char *key);
245 extern void *Dowa_HashMap_Get(Dowa_HashMap *p_hash_map, const char *key);
246 extern void Dowa_HashMap_Push_Value(Dowa_HashMap *p_hash_map, const char *key, void *value, size_t value_size);
247 extern int32 Dowa_HashMap_Push_Value_With_Type(Dowa_HashMap *p_hash_map, const char *key, void *value, size_t value_size, Dowa_HashMap_ValueType type);
248 extern int32 Dowa_HashMap_Push_Value_With_Type_NoCopy(Dowa_HashMap *p_hash_map, const char *key, void *value, size_t value_size, Dowa_HashMap_ValueType type);
249 extern void Dowa_HashMap_Pop_Key(Dowa_HashMap *p_hash_map, const char *key);
250 extern boolean Dowa_HashMap_Has_Key(Dowa_HashMap *p_hash_map, const char *key);
251 extern void Dowa_HashMap_Clear(Dowa_HashMap *p_hash_map);
252 extern uint32 Dowa_HashMap_Get_Count(Dowa_HashMap *p_hash_map);
253
254 OLD Array API - Commented out for migration
255 #define DOWA_ARRAY_DEFAULT_CAPACITY 256
256
257 typedef struct {
258 void *value;
259 uint32 length;
260 } Dowa_Array_Item;
261
262 typedef struct {
263 uint32 capacity;
264 uint32 current_length;
265 Dowa_Array_Item *items;
266 } Dowa_Array;
267
268 #define Dowa_Array_Push_Value(dowa_array, buffer, length) ...
269 Dowa_Array *Dowa_Array_Init();
270
271 OLD Utility Functions - Will be migrated
272 extern void Dowa_HashMap_Print(Dowa_HashMap *map);
273 extern int Dowa_HashMap_Cache_Folder(Dowa_HashMap *map, const char *folder_path);
274 */
275
276 // --- String Manipulation --- // 214 // --- String Manipulation --- //
277 215
278 DLAPI const char *Dowa_String_Slice(const char *p_from, size_t start, size_t end); 216 DLAPI char *Dowa_String_Slice(char *from, size_t start, size_t end, Dowa_Arena *p_arena);
217 DLAPI char **Dowa_String_Split(char *from, char *token, int32 from_length, int32 token_length, Dowa_Arena *p_arena);
218 DLAPI char *Dowa_String_Copy_Arena(char *from, Dowa_Arena *p_arena);
279 DLAPI int32 Dowa_String_Pos_Find(const char *p_from, const char *p_value, const size_t from_length, const size_t value_length); 219 DLAPI int32 Dowa_String_Pos_Find(const char *p_from, const char *p_value, const size_t from_length, const size_t value_length);
280 DLAPI char *Dowa_String_Find(const char *p_from, const char *p_value, const size_t from_length, const size_t value_length); 220 DLAPI char *Dowa_String_Find(const char *p_from, const char *p_value, const size_t from_length, const size_t value_length);
281 DLAPI int32 Dowa_String_Pos_Find_Char(const char *p_from, int c, int32 from_len); 221 DLAPI int32 Dowa_String_Pos_Find_Char(const char *p_from, int c, int32 from_length);
282 DLAPI char *Dowa_String_Find_Char(const char *p_from, int c, int32 from_len); 222 DLAPI char *Dowa_String_Find_Char(const char *p_from, int c, int32 from_length);
283 DLAPI char *Dowa_Int32ToString(uint32 value, char *p_buffer);
284 223
285 224
286 #endif 225 #endif