summaryrefslogtreecommitdiffstats
path: root/src/nbt.internal.h
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2024-02-03 16:58:23 -0600
committerLibravatar bigfoot547 <[email protected]>2024-02-03 22:26:55 -0600
commit962f5efdf1af9f07395c28df7a2181733e3e5125 (patch)
tree790bd875d37d6f2a78bf93eb35e4dd11718f6379 /src/nbt.internal.h
parentfix using the wrong free function (diff)
add lists
Diffstat (limited to 'src/nbt.internal.h')
-rw-r--r--src/nbt.internal.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/nbt.internal.h b/src/nbt.internal.h
new file mode 100644
index 0000000..88f636b
--- /dev/null
+++ b/src/nbt.internal.h
@@ -0,0 +1,78 @@
+#ifndef LIBWORLD_NBT_INTERNAL_H_INCLUDED
+#define LIBWORLD_NBT_INTERNAL_H_INCLUDED
+
+#include "nbt.h"
+#include "nbt/nbtht.internal.h"
+
+typedef struct {
+ size_t len;
+ nbt_byte_t *data;
+} nbt__byte_array_t;
+
+typedef struct {
+ size_t len;
+ nbt_int_t *data;
+} nbt__int_array_t;
+
+typedef struct {
+ size_t len;
+ nbt_long_t *data;
+} nbt__long_array_t;
+
+typedef struct {
+ size_t len;
+ char *data;
+} nbt__string_t;
+
+typedef struct nbt__compound_tag {
+ nbt__ht_t *hash;
+} nbt__compound_t;
+
+typedef struct nbt__list_tag {
+ size_t cap, len;
+ nbt_tag_t **ptags;
+} nbt__list_t;
+
+typedef union {
+ nbt_byte_t nbt_byte;
+ nbt_short_t nbt_short;
+ nbt_int_t nbt_int;
+ nbt_long_t nbt_long;
+
+ nbt_float_t nbt_float;
+ nbt_double_t nbt_double;
+
+ nbt__byte_array_t nbt_byte_array;
+
+ nbt__string_t nbt_string;
+
+ nbt__list_t nbt_list;
+ nbt__compound_t nbt_compound;
+
+ nbt__int_array_t nbt_int_array;
+ nbt__long_array_t nbt_long_array;
+} nbt__any_t;
+
+struct nbt__tag_tag {
+ size_t ref;
+ nbt_type_t type;
+ nbt__any_t value;
+};
+
+/* a named tag */
+typedef struct {
+ nbt_tag_t tag;
+
+ size_t name_length;
+ char *name; /* nullable if there is no name (will be written as if the name is empty) */
+} nbt__ntag_t;
+
+#define NBT__CHECK_TYPE(_tag, _t, _r, ...) do { \
+ if (!(_tag) || (_tag)->type != _t) { _r(__VA_ARGS__); } \
+} while (0)
+
+/* functions */
+
+void nbt__tag_free(nbt_tag_t *tag);
+
+#endif /* include guard */