Kohi Game Engine
binary_string_table.h
Go to the documentation of this file.
1 
20 #pragma once
21 
22 #include "defines.h"
23 
24 // A single entry in a binary string table.
25 typedef struct binary_string_table_entry {
29 
30 // Header for the binary string table.
35 
36 // The runtime representation of a binary string table.
37 typedef struct binary_string_table {
39  // Entry lookup
41  // The data block holding all string data. Strings are NOT terminated since
42  // thier offset and length is stored in the header entries' lookup.
43  char* data;
45 
52 
61 
68 
77 
85 KAPI const char* binary_string_table_get(const binary_string_table* table, u32 index);
86 
102 KAPI void binary_string_table_get_buffered(const binary_string_table* table, u32 index, char* buffer);
103 
KAPI u32 binary_string_table_length_get(const binary_string_table *table, u32 index)
Returns the length of the string, NOT accounting for null terminator.
struct binary_string_table_header binary_string_table_header
struct binary_string_table binary_string_table
KAPI u32 binary_string_table_add(binary_string_table *table, const char *string)
Adds the given string to the provided table. String MUST be null-terminated.
struct binary_string_table_entry binary_string_table_entry
KAPI void * binary_string_table_serialized(const binary_string_table *table, u64 *out_size)
Serialize table to a single block of memory, tagged with MEMORY_TAG_BINARY_DATA. Should be freed by t...
KAPI void binary_string_table_get_buffered(const binary_string_table *table, u32 index, char *buffer)
Copies string into already-existing buffer. Use binary_string_table_length_get to obtain the length o...
KAPI binary_string_table binary_string_table_create(void)
KAPI const char * binary_string_table_get(const binary_string_table *table, u32 index)
Returns a null-terminated copy of the string from the table. Dynamically allocated and must be freed ...
KAPI void binary_string_table_destroy(binary_string_table *table)
Destroys the provided binary string table.
KAPI binary_string_table binary_string_table_from_block(void *block)
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:209
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:27
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:30
Definition: binary_string_table.h:25
u32 offset
Definition: binary_string_table.h:26
u32 length
Definition: binary_string_table.h:27
Definition: binary_string_table.h:31
u32 entry_count
Definition: binary_string_table.h:32
u64 data_block_size
Definition: binary_string_table.h:33
Definition: binary_string_table.h:37
binary_string_table_entry * lookup
Definition: binary_string_table.h:40
char * data
Definition: binary_string_table.h:43
binary_string_table_header header
Definition: binary_string_table.h:38