Fixes compile errors
This commit is contained in:
parent
baf7e47c25
commit
09e0c5b9fa
5 changed files with 25 additions and 11 deletions
|
@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD 17)
|
|||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
# Add source files
|
||||
file(GLOB SOURCES "src/utils/*.cpp" "src/types/*.cpp")
|
||||
file(GLOB SOURCES "src/utils/*.cpp" "src/types/*.cpp" "src/nbt/*.cpp")
|
||||
|
||||
# Add an shared library target
|
||||
add_library(ac SHARED ${SOURCES})
|
||||
|
|
2
Makefile
2
Makefile
|
@ -9,7 +9,7 @@ all: clean build
|
|||
|
||||
build:
|
||||
mkdir build
|
||||
cd build && cmake .. && make && mv libac.so ..
|
||||
cd build && cmake .. && make && mv libac.so .. && cd ..
|
||||
|
||||
# Clean up build artifacts
|
||||
clean:
|
||||
|
|
|
@ -81,8 +81,7 @@ namespace nbt
|
|||
_parentTagType = type;
|
||||
}
|
||||
|
||||
virtual void writeValue(ByteLayer &data) const = 0;
|
||||
virtual void readValue(ByteLayer &data) = 0;
|
||||
virtual void readValue(ByteLayer &data);
|
||||
|
||||
std::string getKey() const
|
||||
{
|
||||
|
@ -95,7 +94,6 @@ namespace nbt
|
|||
}
|
||||
|
||||
virtual void writeStringifiedValue(StringBuilder &stream, int indent, bool isList) const = 0;
|
||||
virtual void readStringifiedValue(StringReader &reader) = 0;
|
||||
virtual void writeValue(ByteLayer &data) const;
|
||||
virtual void setValue(const dynamic &val);
|
||||
virtual void prettyPrint(int indent, bool recurse) const;
|
||||
|
|
|
@ -7,8 +7,22 @@ using namespace std;
|
|||
|
||||
namespace libac
|
||||
{
|
||||
|
||||
dynamic::~dynamic()
|
||||
{
|
||||
// Properly destroy the union members if needed.
|
||||
if (Type == 8)
|
||||
{ // Assuming type 8 is std::string
|
||||
x.str.~basic_string();
|
||||
}
|
||||
else if (Type == 9)
|
||||
{ // Assuming type 9 is std::vector<uint8_t>
|
||||
x.u8l.~vector();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
dynamic::dynamic(T y)
|
||||
dynamic::dynamic(T y) : Type(0)
|
||||
{
|
||||
if constexpr (std::is_same_v<T, char>)
|
||||
{
|
||||
|
@ -55,15 +69,11 @@ namespace libac
|
|||
Type = 9;
|
||||
x.u8 = y;
|
||||
}
|
||||
else if constexpr (std::is_same_v < T, vector<uint8_t>)
|
||||
else if constexpr (std::is_same_v<T, vector<uint8_t>>)
|
||||
{
|
||||
Type = 10;
|
||||
x.u8l = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert(!std::is_same_v<T, T>, "Unsupported type for dynamic");
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -115,6 +125,7 @@ namespace libac
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
template dynamic::dynamic(char);
|
||||
template dynamic::dynamic(unsigned char);
|
||||
template dynamic::dynamic(short);
|
||||
|
@ -136,4 +147,6 @@ namespace libac
|
|||
template std::string dynamic::get<std::string>() const;
|
||||
template uint8_t dynamic::get<uint8_t>() const;
|
||||
template vector<uint8_t> dynamic::get<vector<uint8_t>>() const;
|
||||
|
||||
*/
|
||||
}
|
|
@ -23,6 +23,9 @@ namespace libac
|
|||
string str;
|
||||
uint8_t u8;
|
||||
vector<uint8_t> u8l;
|
||||
|
||||
all() {} // Default constructor
|
||||
~all() {} // Default destructor
|
||||
};
|
||||
|
||||
class dynamic
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue