From 70e00f817e9596a746800ba4afec2b7c4ca25142 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sat, 4 Sep 2021 17:58:56 -0700 Subject: Migrate Template and TableTemplate to use DataStream --- core/src/Model/Template/TableTemplate.cpp | 56 ++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'core/src/Model/Template/TableTemplate.cpp') diff --git a/core/src/Model/Template/TableTemplate.cpp b/core/src/Model/Template/TableTemplate.cpp index adf79fe..a5745c7 100644 --- a/core/src/Model/Template/TableTemplate.cpp +++ b/core/src/Model/Template/TableTemplate.cpp @@ -1,7 +1,14 @@ #include "TableTemplate.hpp" +#include "Utils/IO/StringIntegration.hpp" +#include "Utils/IO/TslArrayIntegration.hpp" +#include "Utils/IO/VectorIntegration.hpp" + #include +#include #include +#include +#include #include #include @@ -20,6 +27,23 @@ bool TableCell::IsMergedCell() const return PrimaryCellLocation.x == -1 || PrimaryCellLocation.y == -1; } +template +void TableCell::OperateIOProxy(TProxy& proxy) +{ + proxy.template ObjectAdapted(Content); + proxy.Object(Location); + proxy.Object(PrimaryCellLocation); + proxy.Value(SpanX); + proxy.Value(SpanY); + proxy.Value(HorizontalAlignment); + proxy.Value(VerticalAlignment); + proxy.Value(Type); + proxy.Value(DataId); +} + +template void TableCell::OperateIOProxy(InputDataStream& adapter); +template void TableCell::OperateIOProxy(OutputDataStream& adapter); + Vec2i TableArrayGroup::GetLeftCell() const { return { Row, LeftCell }; @@ -62,6 +86,17 @@ bool TableArrayGroup::UpdateCellName(std::string_view oldName, std::string_view return ::UpdateElementName(mName2Cell, oldName, newName); } +template +void TableArrayGroup::OperateIOProxy(TProxy& proxy) +{ + proxy.Value(Row); + proxy.Value(LeftCell); + proxy.Value(RightCell); +} + +template void TableArrayGroup::OperateIOProxy(InputDataStream& adapter); +template void TableArrayGroup::OperateIOProxy(OutputDataStream& adapter); + TableInstantiationParameters::TableInstantiationParameters(const TableTemplate& table) : mTable{ &table } { @@ -513,13 +548,24 @@ lxw_worksheet* TableTemplate::InstantiateToExcelWorksheet(lxw_workbook* workbook return worksheet; } -Template::ReadResult TableTemplate::ReadFrom(std::istream& stream) + +void TableTemplate::ReadFromDataStream(InputDataStream& stream) +{ + OperateIOProxy(stream); +} + +void TableTemplate::WriteToDataStream(OutputDataStream& stream) { - // TODO - return ReadResult::RR_Success; + OperateIOProxy(stream); } -void TableTemplate::WriteTo(std::ostream& stream) const +template +void TableTemplate::OperateIOProxy(TProxy& proxy) { - // TODO + proxy.template ObjectAdapted>(mColumnWidths); + proxy.template ObjectAdapted>(mRowHeights); + proxy.template ObjectAdapted>(mCells); + proxy.template ObjectAdapted>(mArrayGroups); + proxy.template ObjectAdapted>(mName2Parameters); + proxy.template ObjectAdapted>(mName2ArrayGroups); } -- cgit v1.2.3-70-g09d2