mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 07:35:45 +01:00
add a function for checking whether a tag is primitive or not
mainly for niche uses
This commit is contained in:
@@ -98,3 +98,17 @@ int nbt_prim_tagsize(u8 tag) {
|
|||||||
default: return -1;
|
default: return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nbt_isprim(u8 tag) {
|
||||||
|
switch (tag) {
|
||||||
|
case NBT_I8:
|
||||||
|
case NBT_I16:
|
||||||
|
case NBT_I32:
|
||||||
|
case NBT_F32:
|
||||||
|
case NBT_I64:
|
||||||
|
case NBT_F64:
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,5 +36,10 @@ enum nbt_tagid {
|
|||||||
|
|
||||||
int nbt_proc(void **restrict datout, u8 const *restrict buf, size_t len);
|
int nbt_proc(void **restrict datout, u8 const *restrict buf, size_t len);
|
||||||
|
|
||||||
|
/* checks whether the tag is a primitive data tag. (not recommended for filtering tags, use a `switch`)
|
||||||
|
* returns a boolean value. */
|
||||||
|
atrb_const int nbt_isprim(u8 tag);
|
||||||
|
|
||||||
|
|
||||||
/* gets the tag size of primitive types, returns `>0` on success, `<0` on failure */
|
/* gets the tag size of primitive types, returns `>0` on success, `<0` on failure */
|
||||||
atrb_const int nbt_prim_tagsize(u8 tag);
|
atrb_const int nbt_prim_tagsize(u8 tag);
|
||||||
|
|||||||
Reference in New Issue
Block a user