apparently that's not how cpp works (I stole it from somewhere lol)
parent
8594f4cbb0
commit
12e9533772
|
@ -43,29 +43,29 @@ int endianness_example() {
|
||||||
|
|
||||||
namespace NBT {
|
namespace NBT {
|
||||||
namespace helper {
|
namespace helper {
|
||||||
ErrorOr<int8_t> readInt8(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition) {
|
ErrorOr<int8_t> readInt8(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
return ErrorOr<int8_t>((int8_t) 0);
|
return ErrorOr<int8_t>((int8_t) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<int16_t> readInt16(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition) {
|
ErrorOr<int16_t> readInt16(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
return ErrorOr<int16_t>((int16_t) 0);
|
return ErrorOr<int16_t>((int16_t) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<int32_t> readInt32(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition) {
|
ErrorOr<int32_t> readInt32(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
return ErrorOr<int32_t>((int32_t) 0);
|
return ErrorOr<int32_t>((int32_t) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<int64_t> readInt64(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition) {
|
ErrorOr<int64_t> readInt64(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
return ErrorOr<int64_t>((int64_t) 0);
|
return ErrorOr<int64_t>((int64_t) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: we just assume that float is a single-precision IEEE754
|
//FIXME: we just assume that float is a single-precision IEEE754
|
||||||
// floating point number
|
// floating point number
|
||||||
ErrorOr<float> readFloat32(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition) {
|
ErrorOr<float> readFloat32(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
//TODO: implement assuming standard single-precision IEEE754 float
|
//TODO: implement assuming standard single-precision IEEE754 float
|
||||||
// Alternatively, maybe calculate a floating point number by using
|
// Alternatively, maybe calculate a floating point number by using
|
||||||
// the stored value as math instructions?
|
// the stored value as math instructions?
|
||||||
|
@ -74,14 +74,14 @@ namespace NBT {
|
||||||
|
|
||||||
//FIXME: we just assume that double is a double-precision IEEE754
|
//FIXME: we just assume that double is a double-precision IEEE754
|
||||||
// floating point number
|
// floating point number
|
||||||
ErrorOr<double> readFloat64(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition) {
|
ErrorOr<double> readFloat64(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
//TODO: implement assuming standard double-precision IEEE754 float
|
//TODO: implement assuming standard double-precision IEEE754 float
|
||||||
// Alternatively, maybe calculate a floating point number by using
|
// Alternatively, maybe calculate a floating point number by using
|
||||||
// the stored value as math instructions?
|
// the stored value as math instructions?
|
||||||
return ErrorOr<double>(0.0);
|
return ErrorOr<double>(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<std::vector<int8_t>> readInt8Array(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition) {
|
ErrorOr<std::vector<int8_t>> readInt8Array(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
return ErrorOr<std::vector<int8_t>>({0});
|
return ErrorOr<std::vector<int8_t>>({0});
|
||||||
}
|
}
|
||||||
|
@ -89,23 +89,23 @@ namespace NBT {
|
||||||
// Maybe use a struct that holds decoded (de-Java-fied) string
|
// Maybe use a struct that holds decoded (de-Java-fied) string
|
||||||
// data, decoded size, and original size? Original size is needed
|
// data, decoded size, and original size? Original size is needed
|
||||||
// so the parser knows where to continue.
|
// so the parser knows where to continue.
|
||||||
//ErrorOr<> readString(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition) {
|
//ErrorOr<> readString(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
// return ErrorOr<>("");
|
// return ErrorOr<>("");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
ErrorOr<std::vector<int32_t>> readInt32Array(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition) {
|
ErrorOr<std::vector<int32_t>> readInt32Array(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
return ErrorOr<std::vector<int32_t>>({0});
|
return ErrorOr<std::vector<int32_t>>({0});
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<std::vector<int64_t>> readInt64Array(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition) {
|
ErrorOr<std::vector<int64_t>> readInt64Array(uint8_t data[], uint64_t dataSize, uint64_t currentPosition) {
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
return ErrorOr<std::vector<int64_t>>({0});
|
return ErrorOr<std::vector<int64_t>>({0});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool validateRawNBTData(uint8_t* data[], uint64_t dataSize){
|
bool validateRawNBTData(uint8_t data[], uint64_t dataSize){
|
||||||
//state machine?
|
//state machine?
|
||||||
//TODO: implement
|
//TODO: implement
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -41,30 +41,30 @@
|
||||||
|
|
||||||
namespace NBT {
|
namespace NBT {
|
||||||
namespace helper {
|
namespace helper {
|
||||||
ErrorOr<int8_t> readInt8(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition);
|
ErrorOr<int8_t> readInt8(uint8_t data[], uint64_t dataSize, uint64_t currentPosition);
|
||||||
|
|
||||||
ErrorOr<int16_t> readInt16(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition);
|
ErrorOr<int16_t> readInt16(uint8_t data[], uint64_t dataSize, uint64_t currentPosition);
|
||||||
|
|
||||||
ErrorOr<int32_t> readInt32(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition);
|
ErrorOr<int32_t> readInt32(uint8_t data[], uint64_t dataSize, uint64_t currentPosition);
|
||||||
|
|
||||||
ErrorOr<int64_t> readInt64(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition);
|
ErrorOr<int64_t> readInt64(uint8_t data[], uint64_t dataSize, uint64_t currentPosition);
|
||||||
|
|
||||||
//FIXME: we just assume that float is a single-precision IEEE754
|
//FIXME: we just assume that float is a single-precision IEEE754
|
||||||
// floating point number
|
// floating point number
|
||||||
ErrorOr<float> readFloat32(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition);
|
ErrorOr<float> readFloat32(uint8_t data[], uint64_t dataSize, uint64_t currentPosition);
|
||||||
|
|
||||||
//FIXME: we just assume that double is a double-precision IEEE754
|
//FIXME: we just assume that double is a double-precision IEEE754
|
||||||
// floating point number
|
// floating point number
|
||||||
ErrorOr<double> readFloat64(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition);
|
ErrorOr<double> readFloat64(uint8_t data[], uint64_t dataSize, uint64_t currentPosition);
|
||||||
|
|
||||||
ErrorOr<std::vector<int8_t>> readInt8Array(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition);
|
ErrorOr<std::vector<int8_t>> readInt8Array(uint8_t data[], uint64_t dataSize, uint64_t currentPosition);
|
||||||
|
|
||||||
//ErrorOr<> readString(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition);
|
//ErrorOr<> readString(uint8_t data[], uint64_t dataSize, uint64_t currentPosition);
|
||||||
|
|
||||||
ErrorOr<std::vector<int32_t>> readInt32Array(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition);
|
ErrorOr<std::vector<int32_t>> readInt32Array(uint8_t data[], uint64_t dataSize, uint64_t currentPosition);
|
||||||
|
|
||||||
ErrorOr<std::vector<int64_t>> readInt64Array(uint8_t* data[], uint64_t dataSize, uint64_t currentPosition);
|
ErrorOr<std::vector<int64_t>> readInt64Array(uint8_t data[], uint64_t dataSize, uint64_t currentPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool validateRawNBTData(uint8_t* data[], int length);
|
bool validateRawNBTData(uint8_t data[], int length);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue