Still haven't properly tested MetaTree. But have all of the current features working together.

This commit is contained in:
2022-09-08 19:35:16 +10:00
parent abc9cf6a61
commit 392e226013
5 changed files with 195 additions and 94 deletions

View File

@@ -75,6 +75,7 @@ extern "C" {
typedef struct record Record;
typedef struct field Field;
typedef struct meta_node MetaNode;
typedef struct meta_tree MetaTree;
//
@@ -215,6 +216,11 @@ extern "C" {
void *data;
};
struct meta_callbacks {
void (*pre)(MetaNode *m, void *data);
void *data;
};
/* Meta Nodes are used for constructing a more flexible tree structure
* on top of the natural structure of ESP/ESM files.
*
@@ -249,6 +255,11 @@ extern "C" {
MetaNode *next;
};
struct meta_tree {
MetaNode *root;
size_t size;
};
//
// === BINARY DATA OVERLAYS ===
//
@@ -340,8 +351,7 @@ extern "C" {
* increasing in terms of memory location within the buffer.
*/
void espr_walk(
char *data,
size_t size,
struct sized_buf esp,
struct walker_callbacks cb,
void *from_parent
);
@@ -349,13 +359,13 @@ extern "C" {
/* `espr_print` prints the header of every group and record in the given
* esp/esm binary data.
*/
void espr_print(char *data, size_t size);
void espr_print(struct sized_buf esp);
/* Calculates the number of groups and records in the esp/esm file and
* the size of the esp/esm if all of the compressed records were
* decompressed.
*/
struct esp_stats espr_stats(char *data, size_t size);
struct esp_stats espr_stats(struct sized_buf esp);
// Calculates the number of formid's in an esm/esp from the stats
inline uint32_t espr_formid_count(struct esp_stats stats) {
@@ -378,10 +388,8 @@ extern "C" {
* `espr_decompressed_size`, and `buf` should be at least of that size.
*/
void espr_decompress(
char *data,
size_t size,
char *buf,
size_t buf_size
struct sized_buf esp,
struct sized_buf decom
);
/* Constructs a MetaNode tree in `tree` over the esp/esm data in `in`.
@@ -390,7 +398,13 @@ extern "C" {
* data, and also allow for modifications that add, remove, or change
* the size of groups/records/fields.
*/
MetaNode *espr_create_tree(struct sized_buf in, struct sized_buf tree);
MetaTree espr_create_tree(struct sized_buf in, struct sized_buf tree);
void espr_meta_walk(MetaTree tree, struct meta_callbacks cb);
void espr_meta_node_walk(MetaNode *m, struct meta_callbacks cb);
void espr_serialize(MetaTree tree, struct sized_buf out);
// End C++ guard
#ifdef __cplusplus