From efc4ed8de4f4ee51245fbf3c7cecb9981422c389 Mon Sep 17 00:00:00 2001 From: Christian Seiler Date: Fri, 29 May 2026 20:14:55 +0200 Subject: [PATCH] C++: parser code: propagate format version into individual parsing methods This allows us to differentiate once we introduce new formats. --- cpp/src/monoformat_parseonly.cpp | 77 +++++++++++++++++------------ cpp/src/monoformat_structured.cpp | 82 ++++++++++++++++++++----------- cpp/src/monoformat_structured.hpp | 22 ++++----- 3 files changed, 109 insertions(+), 72 deletions(-) diff --git a/cpp/src/monoformat_parseonly.cpp b/cpp/src/monoformat_parseonly.cpp index bb7d3a8..3d2ae27 100644 --- a/cpp/src/monoformat_parseonly.cpp +++ b/cpp/src/monoformat_parseonly.cpp @@ -23,16 +23,18 @@ struct TimeBasedDrawnSectionMetaData { std::int64_t endTimestamp{}; }; -static std::expected handleImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts); -static std::expected handleAnimation(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts); -static std::expected handleHScrollImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts); -static std::expected handleVScrollImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts); -static std::expected handleLine(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts); -static std::expected handleClippedText(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts); -static std::expected handleHScrollText(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts); -static std::expected handleCurrentTime(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts); - -static std::expected parseAlwaysDrawnSection(std::span& data) { +static std::expected handleImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion); +static std::expected handleAnimation(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion); +static std::expected handleHScrollImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion); +static std::expected handleVScrollImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion); +static std::expected handleLine(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion); +static std::expected handleClippedText(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion); +static std::expected handleHScrollText(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion); +static std::expected handleCurrentTime(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion); + +static std::expected parseAlwaysDrawnSection(std::span& data, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU8LE(data); if (!type) { return std::unexpected(type.error()); @@ -71,7 +73,9 @@ static std::expected parseAlwaysDrawnSec return result; } -static std::expected parseTimeBasedDrawnSection(std::span& data) { +static std::expected parseTimeBasedDrawnSection(std::span& data, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU8LE(data); if (!type) { return std::unexpected(type.error()); @@ -120,7 +124,9 @@ static std::expected parseTimeBasedDr return result; } -static std::expected, ParseError> parseCustomFontSection(std::span& data) { +static std::expected, ParseError> parseCustomFontSection(std::span& data, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU8LE(data); if (!type) { return std::unexpected(type.error()); @@ -197,7 +203,7 @@ std::expected parseAndApply(std::span data, O } if (static_cast(*sectionType) == SectionType::CustomFont) { - auto fontData = parseCustomFontSection(*rawSectionData); + auto fontData = parseCustomFontSection(*rawSectionData, *version); if (!fontData) { return std::unexpected(fontData.error()); } @@ -209,13 +215,13 @@ std::expected parseAndApply(std::span data, O AlwaysDrawnSectionMetaData section; if (static_cast(*sectionType) == SectionType::AlwaysDrawn) { - auto metaData = parseAlwaysDrawnSection(*rawSectionData); + auto metaData = parseAlwaysDrawnSection(*rawSectionData, *version); if (!metaData) { return std::unexpected(metaData.error()); } section = *metaData; } else if (static_cast(*sectionType) == SectionType::TimeBasedDrawn) { - auto metaData = parseTimeBasedDrawnSection(*rawSectionData); + auto metaData = parseTimeBasedDrawnSection(*rawSectionData, *version); if (!metaData) { return std::unexpected(metaData.error()); } @@ -249,14 +255,14 @@ std::expected parseAndApply(std::span data, O auto eType = static_cast(*type); std::expected parseResult; switch (eType) { - case ElementType::Image: parseResult = handleImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; - case ElementType::Animation: parseResult = handleAnimation(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; - case ElementType::HScrollImage: parseResult = handleHScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; - case ElementType::VScrollImage: parseResult = handleVScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; - case ElementType::Line: parseResult = handleLine(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; - case ElementType::ClippedText: parseResult = handleClippedText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; - case ElementType::HScrollText: parseResult = handleHScrollText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; - case ElementType::CurrentTime: parseResult = handleCurrentTime(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex)); break; + case ElementType::Image: parseResult = handleImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; + case ElementType::Animation: parseResult = handleAnimation(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; + case ElementType::HScrollImage: parseResult = handleHScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; + case ElementType::VScrollImage: parseResult = handleVScrollImage(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; + case ElementType::Line: parseResult = handleLine(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; + case ElementType::ClippedText: parseResult = handleClippedText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; + case ElementType::HScrollText: parseResult = handleHScrollText(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; + case ElementType::CurrentTime: parseResult = handleCurrentTime(section.elementData, screen, animationTick, currentTimestamp, std::span{customFonts}.subspan(0, customFontIndex), *version); break; default: parseResult = std::unexpected(ParseError::InvalidValue); } @@ -269,7 +275,9 @@ std::expected parseAndApply(std::span data, O return {}; } -std::expected handleImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts) { +std::expected handleImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU16LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -324,7 +332,8 @@ std::expected handleImage(std::span& buffer, return {}; } -std::expected handleAnimation(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts) { +std::expected handleAnimation(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion) { + std::ignore = formatVersion; std::ignore = currentTimestamp; std::ignore = customFonts; @@ -396,7 +405,8 @@ std::expected handleAnimation(std::span& buff return {}; } -std::expected handleHScrollImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts) { +std::expected handleHScrollImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion) { + std::ignore = formatVersion; std::ignore = currentTimestamp; std::ignore = customFonts; @@ -561,7 +571,8 @@ std::expected handleHScrollImage(std::span& b return {}; } -std::expected handleVScrollImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts) { +std::expected handleVScrollImage(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion) { + std::ignore = formatVersion; std::ignore = currentTimestamp; std::ignore = customFonts; @@ -726,7 +737,8 @@ std::expected handleVScrollImage(std::span& b return {}; } -std::expected handleLine(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts) { +std::expected handleLine(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion) { + std::ignore = formatVersion; std::ignore = animationTick; std::ignore = currentTimestamp; std::ignore = customFonts; @@ -798,7 +810,8 @@ std::expected handleLine(std::span& buffer, O return {}; } -std::expected handleClippedText(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts) { +std::expected handleClippedText(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion) { + std::ignore = formatVersion; std::ignore = animationTick; std::ignore = currentTimestamp; @@ -867,7 +880,8 @@ std::expected handleClippedText(std::span& bu return {}; } -std::expected handleHScrollText(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts) { +std::expected handleHScrollText(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion) { + std::ignore = formatVersion; std::ignore = currentTimestamp; auto type = readU16LE(buffer); @@ -1028,7 +1042,8 @@ std::expected handleHScrollText(std::span& bu return {}; } -std::expected handleCurrentTime(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts) { +std::expected handleCurrentTime(std::span& buffer, OneBitBufferInterface* screen, std::size_t animationTick, std::int64_t currentTimestamp, std::span> customFonts, std::uint32_t formatVersion) { + std::ignore = formatVersion; std::ignore = animationTick; auto type = readU16LE(buffer); diff --git a/cpp/src/monoformat_structured.cpp b/cpp/src/monoformat_structured.cpp index e7a5845..5d28259 100644 --- a/cpp/src/monoformat_structured.cpp +++ b/cpp/src/monoformat_structured.cpp @@ -85,7 +85,9 @@ void ImageElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t animat } } -std::expected, ParseError> ImageElement::parse(std::span& buffer) { +std::expected, ParseError> ImageElement::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU16LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -242,7 +244,9 @@ void AnimationElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t an } } -std::expected, ParseError> AnimationElement::parse(std::span& buffer) { +std::expected, ParseError> AnimationElement::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU16LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -482,7 +486,9 @@ void HScrollImageElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t } } -std::expected, ParseError> HScrollImageElement::parse(std::span& buffer) { +std::expected, ParseError> HScrollImageElement::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU16LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -726,7 +732,9 @@ void VScrollImageElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t } } -std::expected, ParseError> VScrollImageElement::parse(std::span& buffer) { +std::expected, ParseError> VScrollImageElement::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU16LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -861,7 +869,9 @@ void LineElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t animati } } -std::expected, ParseError> LineElement::parse(std::span& buffer) { +std::expected, ParseError> LineElement::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU16LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -978,7 +988,9 @@ void ClippedTextElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t renderer.render(m_text, Point{0, static_cast(renderer.lineHeight() - 1)}, target, true, false); } -std::expected, ParseError> ClippedTextElement::parse(std::span& buffer) { +std::expected, ParseError> ClippedTextElement::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU16LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -1190,7 +1202,9 @@ void HScrollTextElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t } } -std::expected, ParseError> HScrollTextElement::parse(std::span& buffer) { +std::expected, ParseError> HScrollTextElement::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU16LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -1356,7 +1370,9 @@ void CurrentTimeElement::drawTo(OneBitBufferInterface* imageBuffer, std::size_t renderer.render(text, Point{0, static_cast(renderer.lineHeight() - 1)}, target, true, false); } -std::expected, ParseError> CurrentTimeElement::parse(std::span& buffer) { +std::expected, ParseError> CurrentTimeElement::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU16LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -1492,7 +1508,9 @@ std::size_t AlwaysDrawnSection::serializeTo(std::span target) const { return pos; } -std::expected, ParseError> AlwaysDrawnSection::parse(std::span& buffer) { +std::expected, ParseError> AlwaysDrawnSection::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU8LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -1529,14 +1547,14 @@ std::expected, ParseError> AlwaysDrawnSectio } std::expected, ParseError> element; switch (static_cast(*type)) { - case ElementType::Image: element = ImageElement::parse(sectionData); break; - case ElementType::Animation: element = AnimationElement::parse(sectionData); break; - case ElementType::HScrollImage: element = HScrollImageElement::parse(sectionData); break; - case ElementType::VScrollImage: element = VScrollImageElement::parse(sectionData); break; - case ElementType::Line: element = LineElement::parse(sectionData); break; - case ElementType::ClippedText: element = ClippedTextElement::parse(sectionData); break; - case ElementType::HScrollText: element = HScrollTextElement::parse(sectionData); break; - case ElementType::CurrentTime: element = CurrentTimeElement::parse(sectionData); break; + case ElementType::Image: element = ImageElement::parse(sectionData, formatVersion); break; + case ElementType::Animation: element = AnimationElement::parse(sectionData, formatVersion); break; + case ElementType::HScrollImage: element = HScrollImageElement::parse(sectionData, formatVersion); break; + case ElementType::VScrollImage: element = VScrollImageElement::parse(sectionData, formatVersion); break; + case ElementType::Line: element = LineElement::parse(sectionData, formatVersion); break; + case ElementType::ClippedText: element = ClippedTextElement::parse(sectionData, formatVersion); break; + case ElementType::HScrollText: element = HScrollTextElement::parse(sectionData, formatVersion); break; + case ElementType::CurrentTime: element = CurrentTimeElement::parse(sectionData, formatVersion); break; default: return std::unexpected(ParseError::InvalidValue); } @@ -1662,7 +1680,9 @@ std::size_t TimeBasedDrawnSection::serializeTo(std::span target) cons return pos; } -std::expected, ParseError> TimeBasedDrawnSection::parse(std::span& buffer) { +std::expected, ParseError> TimeBasedDrawnSection::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU8LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -1709,14 +1729,14 @@ std::expected, ParseError> TimeBasedDrawn } std::expected, ParseError> element; switch (static_cast(*type)) { - case ElementType::Image: element = ImageElement::parse(sectionData); break; - case ElementType::Animation: element = AnimationElement::parse(sectionData); break; - case ElementType::HScrollImage: element = HScrollImageElement::parse(sectionData); break; - case ElementType::VScrollImage: element = VScrollImageElement::parse(sectionData); break; - case ElementType::Line: element = LineElement::parse(sectionData); break; - case ElementType::ClippedText: element = ClippedTextElement::parse(sectionData); break; - case ElementType::HScrollText: element = HScrollTextElement::parse(sectionData); break; - case ElementType::CurrentTime: element = CurrentTimeElement::parse(sectionData); break; + case ElementType::Image: element = ImageElement::parse(sectionData, formatVersion); break; + case ElementType::Animation: element = AnimationElement::parse(sectionData, formatVersion); break; + case ElementType::HScrollImage: element = HScrollImageElement::parse(sectionData, formatVersion); break; + case ElementType::VScrollImage: element = VScrollImageElement::parse(sectionData, formatVersion); break; + case ElementType::Line: element = LineElement::parse(sectionData, formatVersion); break; + case ElementType::ClippedText: element = ClippedTextElement::parse(sectionData, formatVersion); break; + case ElementType::HScrollText: element = HScrollTextElement::parse(sectionData, formatVersion); break; + case ElementType::CurrentTime: element = CurrentTimeElement::parse(sectionData, formatVersion); break; default: return std::unexpected(ParseError::InvalidValue); } @@ -1757,7 +1777,9 @@ std::size_t CustomFontSection::serializeTo(std::span target) const { return pos; } -std::expected, ParseError> CustomFontSection::parse(std::span& buffer) { +std::expected, ParseError> CustomFontSection::parse(std::span& buffer, std::uint32_t formatVersion) { + std::ignore = formatVersion; + auto type = readU8LE(buffer); if (!type) { return std::unexpected(type.error()); @@ -1849,9 +1871,9 @@ std::expected parseFile(std::span data) { std::expected, ParseError> section; switch (static_cast(*sectionType)) { - case SectionType::AlwaysDrawn: section = AlwaysDrawnSection::parse(data); break; - case SectionType::TimeBasedDrawn: section = TimeBasedDrawnSection::parse(data); break; - case SectionType::CustomFont: section = CustomFontSection::parse(data); break; + case SectionType::AlwaysDrawn: section = AlwaysDrawnSection::parse(data, *version); break; + case SectionType::TimeBasedDrawn: section = TimeBasedDrawnSection::parse(data, *version); break; + case SectionType::CustomFont: section = CustomFontSection::parse(data, *version); break; default: return std::unexpected(ParseError::InvalidValue); } diff --git a/cpp/src/monoformat_structured.hpp b/cpp/src/monoformat_structured.hpp index 83df0f2..56ffbae 100644 --- a/cpp/src/monoformat_structured.hpp +++ b/cpp/src/monoformat_structured.hpp @@ -51,7 +51,7 @@ struct ImageElement : public Element { virtual std::size_t serializeTo(std::span target) const override; virtual void drawTo(OneBitBufferInterface* imageBuffer, std::size_t animationTick, std::int64_t currentTimestamp, std::span customFonts) override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::uint16_t m_x{}; @@ -83,7 +83,7 @@ struct AnimationElement : public Element { virtual std::size_t serializeTo(std::span target) const override; virtual void drawTo(OneBitBufferInterface* imageBuffer, std::size_t animationTick, std::int64_t currentTimestamp, std::span customFonts) override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::uint16_t m_x{}; @@ -116,7 +116,7 @@ struct HScrollImageElement : public Element { virtual std::size_t serializeTo(std::span target) const override; virtual void drawTo(OneBitBufferInterface* imageBuffer, std::size_t animationTick, std::int64_t currentTimestamp, std::span customFonts) override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::uint16_t m_x{}; @@ -150,7 +150,7 @@ struct VScrollImageElement : public Element { virtual std::size_t serializeTo(std::span target) const override; virtual void drawTo(OneBitBufferInterface* imageBuffer, std::size_t animationTick, std::int64_t currentTimestamp, std::span customFonts) override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::uint16_t m_x{}; @@ -178,7 +178,7 @@ struct LineElement : public Element { virtual std::size_t serializeTo(std::span target) const override; virtual void drawTo(OneBitBufferInterface* imageBuffer, std::size_t animationTick, std::int64_t currentTimestamp, std::span customFonts) override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::uint16_t m_originX{}; @@ -204,7 +204,7 @@ struct ClippedTextElement : public Element { virtual std::size_t serializeTo(std::span target) const override; virtual void drawTo(OneBitBufferInterface* imageBuffer, std::size_t animationTick, std::int64_t currentTimestamp, std::span customFonts) override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::uint16_t m_x{}; @@ -232,7 +232,7 @@ struct HScrollTextElement : public Element { virtual std::size_t serializeTo(std::span target) const override; virtual void drawTo(OneBitBufferInterface* imageBuffer, std::size_t animationTick, std::int64_t currentTimestamp, std::span customFonts) override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::uint16_t m_x{}; @@ -261,7 +261,7 @@ struct CurrentTimeElement : public Element { virtual std::size_t serializeTo(std::span target) const override; virtual void drawTo(OneBitBufferInterface* imageBuffer, std::size_t animationTick, std::int64_t currentTimestamp, std::span customFonts) override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::uint16_t m_x{}; @@ -296,7 +296,7 @@ struct AlwaysDrawnSection : public Section { virtual SectionType sectionType() const override; virtual std::size_t serializeTo(std::span target) const override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::vector> m_elements; @@ -333,7 +333,7 @@ struct TimeBasedDrawnSection : public Section { virtual SectionType sectionType() const override; virtual std::size_t serializeTo(std::span target) const override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::vector> m_elements; @@ -354,7 +354,7 @@ struct CustomFontSection : public Section { virtual SectionType sectionType() const override; virtual std::size_t serializeTo(std::span target) const override; - static std::expected, ParseError> parse(std::span& buffer); + static std::expected, ParseError> parse(std::span& buffer, std::uint32_t formatVersion); private: std::vector m_fontData;