[ox] Add Reader_c and make MetalClawReader use it

This commit is contained in:
2023-10-22 16:37:08 -05:00
parent 4ab710b155
commit 1f78ea1f37
16 changed files with 533 additions and 285 deletions

View File

@@ -5,7 +5,6 @@ add_library(
write.cpp
)
if(NOT MSVC)
target_compile_options(OxClaw PRIVATE -Wsign-conversion)
target_compile_options(OxClaw PRIVATE -Wconversion)
@@ -17,6 +16,17 @@ target_link_libraries(
$<$<BOOL:${OX_USE_STDLIB}>:OxOrganicClaw>
)
if(OX_USE_STDLIB)
add_executable(
readclaw
readclaw.cpp
)
target_link_libraries(
readclaw PUBLIC
OxClaw
)
endif()
install(TARGETS OxClaw
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib

View File

@@ -80,7 +80,8 @@ Result<ModelObject> readClaw(TypeStore *ts, const char *buff, std::size_t buffSz
switch (header.fmt) {
case ClawFormat::Metal:
{
MetalClawReader reader(reinterpret_cast<const uint8_t*>(header.data), header.dataSize);
ox::BufferReader br(header.data, header.dataSize);
MetalClawReader reader(br);
ModelHandlerInterface handler(&reader);
oxReturnError(model(&handler, &obj));
return obj;

View File

@@ -51,7 +51,8 @@ Error readClaw(const char *buff, std::size_t buffLen, T *val) {
switch (header.fmt) {
case ClawFormat::Metal:
{
MetalClawReader reader(reinterpret_cast<const uint8_t*>(header.data), header.dataSize);
ox::BufferReader br(header.data, header.dataSize);
MetalClawReader reader(br);
ModelHandlerInterface handler(&reader);
return model(&handler, val);
}