From d20bfc7795b0b237654c61366291b9fc93594441 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 29 May 2024 00:08:16 -0500 Subject: [PATCH] [nostalgia/developer-handbook] Update serialization notes --- developer-handbook.md | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/developer-handbook.md b/developer-handbook.md index cc668ba0..68a20d82 100644 --- a/developer-handbook.md +++ b/developer-handbook.md @@ -546,19 +546,13 @@ a wrapper around the bare formats. ```cpp #include -ox::Result loadPalette1(const Buffer &buff) noexcept { +ox::Result loadPalette1(ox::Buffer const&buff) noexcept { return ox::readMC(buff); } -ox::Result loadPalette2(const Buffer &buff) noexcept { - return ox::readMC(buff.data(), buff.size()); -} - -ox::Result loadPalette3(const Buffer &buff) noexcept { +ox::Result loadPalette2(ox::Buffer const&buff) noexcept { NostalgiaPalette pal; - std::size_t sz = 0; - oxReturnError(ox::readMC(buff.data(), buff.size(), &pal, &sz)); - buffer.resize(sz); + oxReturnError(ox::readMC(buff, pal)); return pal; } ``` @@ -588,17 +582,13 @@ ox::Result writeSpritePalette2(NostalgiaPalette *pal) noexcept { ```cpp #include -ox::Result loadPalette1(const Buffer &buff) noexcept { +ox::Result loadPalette1(ox::Buffer const&buff) noexcept { return ox::readOC(buff); } -ox::Result loadPalette2(const Buffer &buff) noexcept { - return ox::readOC(buff.data(), buff.size()); -} - -ox::Result loadPalette3(const Buffer &buff) noexcept { +ox::Result loadPalette2(ox::Buffer const&buff) noexcept { NostalgiaPalette pal; - oxReturnError(ox::readOC(buff.data(), buff.size(), &pal)); + oxReturnError(ox::readOC(buff, &pal)); return pal; } ``` @@ -608,13 +598,13 @@ ox::Result loadPalette3(const Buffer &buff) noexcept { ```cpp #include -ox::Result writeSpritePalette1(NostalgiaPalette *pal) noexcept { +ox::Result writeSpritePalette1(NostalgiaPalette const&pal) noexcept { ox::Buffer buffer(ox::units::MB); oxReturnError(ox::writeOC(buffer.data(), buffer.size(), pal)); return buffer; } -ox::Result writeSpritePalette2(NostalgiaPalette *pal) noexcept { +ox::Result writeSpritePalette2(NostalgiaPalette const&pal) noexcept { return ox::writeOC(pal); } ``` @@ -626,17 +616,13 @@ ox::Result writeSpritePalette2(NostalgiaPalette *pal) noexcept { ```cpp #include -ox::Result loadPalette1(const Buffer &buff) noexcept { +ox::Result loadPalette1(ox::Buffer const&buff) noexcept { return ox::readClaw(buff); } -ox::Result loadPalette2(const Buffer &buff) noexcept { - return ox::readClaw(buff.data(), buff.size()); -} - -ox::Result loadPalette3(const Buffer &buff) noexcept { +ox::Result loadPalette2(ox::Buffer const&buff) noexcept { NostalgiaPalette pal; - oxReturnError(ox::readClaw(buff.data(), buff.size(), &pal)); + oxReturnError(ox::readClaw(buff, pal)); return pal; } ``` @@ -646,8 +632,8 @@ ox::Result loadPalette3(const Buffer &buff) noexcept { ```cpp #include -ox::Result writeSpritePalette(NostalgiaPalette *pal) noexcept { - return ox::writeClaw(&pal); +ox::Result writeSpritePalette(NostalgiaPalette const&pal) noexcept { + return ox::writeClaw(pal); } ```