From 04653742243e4bb6452108cfd0fef2f4afd8f23b Mon Sep 17 00:00:00 2001 From: rtk0c Date: Mon, 6 Sep 2021 00:15:35 -0700 Subject: Fix all compile errors, remove OperateIOProxy requirement from DataStream api --- core/src/Model/Template/TableTemplate.cpp | 84 +++++++++++++++++++------------ 1 file changed, 51 insertions(+), 33 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 a5745c7..16cd333 100644 --- a/core/src/Model/Template/TableTemplate.cpp +++ b/core/src/Model/Template/TableTemplate.cpp @@ -27,22 +27,29 @@ bool TableCell::IsMergedCell() const return PrimaryCellLocation.x == -1 || PrimaryCellLocation.y == -1; } -template -void TableCell::OperateIOProxy(TProxy& proxy) +template +void OperateStreamForTableCell(TTableCell& cell, TStream& 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); + proxy.template ObjectAdapted(cell.Content); + proxy.Object(cell.Location); + proxy.Object(cell.PrimaryCellLocation); + proxy.Value(cell.SpanX); + proxy.Value(cell.SpanY); + proxy.Enum(cell.HorizontalAlignment); + proxy.Enum(cell.VerticalAlignment); + proxy.Enum(cell.Type); + proxy.Value(cell.DataId); } -template void TableCell::OperateIOProxy(InputDataStream& adapter); -template void TableCell::OperateIOProxy(OutputDataStream& adapter); +void TableCell::ReadFromDataStream(InputDataStream& stream) +{ + ::OperateStreamForTableCell(*this, stream); +} + +void TableCell::WriteToDataStream(OutputDataStream& stream) const +{ + ::OperateStreamForTableCell(*this, stream); +} Vec2i TableArrayGroup::GetLeftCell() const { @@ -86,16 +93,23 @@ bool TableArrayGroup::UpdateCellName(std::string_view oldName, std::string_view return ::UpdateElementName(mName2Cell, oldName, newName); } -template -void TableArrayGroup::OperateIOProxy(TProxy& proxy) +template +void OperateStreamForTableArrayGroup(TTableArrayGroup& group, TStream& stream) +{ + stream.Value(group.Row); + stream.Value(group.LeftCell); + stream.Value(group.RightCell); +} + +void TableArrayGroup::ReadFromDataStream(InputDataStream& stream) { - proxy.Value(Row); - proxy.Value(LeftCell); - proxy.Value(RightCell); + ::OperateStreamForTableArrayGroup(*this, stream); } -template void TableArrayGroup::OperateIOProxy(InputDataStream& adapter); -template void TableArrayGroup::OperateIOProxy(OutputDataStream& adapter); +void TableArrayGroup::WriteToDataStream(OutputDataStream& stream) const +{ + ::OperateStreamForTableArrayGroup(*this, stream); +} TableInstantiationParameters::TableInstantiationParameters(const TableTemplate& table) : mTable{ &table } @@ -549,23 +563,27 @@ lxw_worksheet* TableTemplate::InstantiateToExcelWorksheet(lxw_workbook* workbook return worksheet; } -void TableTemplate::ReadFromDataStream(InputDataStream& stream) +class TableTemplate::Private { - OperateIOProxy(stream); -} +public: + template + static void OperateStream(TTableTemplate& table, TProxy& proxy) + { + proxy.template ObjectAdapted>(table.mColumnWidths); + proxy.template ObjectAdapted>(table.mRowHeights); + proxy.template ObjectAdapted>(table.mCells); + proxy.template ObjectAdapted>(table.mArrayGroups); + proxy.template ObjectAdapted>(table.mName2Parameters); + proxy.template ObjectAdapted>(table.mName2ArrayGroups); + } +}; -void TableTemplate::WriteToDataStream(OutputDataStream& stream) +void TableTemplate::ReadFromDataStream(InputDataStream& stream) { - OperateIOProxy(stream); + Private::OperateStream(*this, stream); } -template -void TableTemplate::OperateIOProxy(TProxy& proxy) +void TableTemplate::WriteToDataStream(OutputDataStream& stream) const { - proxy.template ObjectAdapted>(mColumnWidths); - proxy.template ObjectAdapted>(mRowHeights); - proxy.template ObjectAdapted>(mCells); - proxy.template ObjectAdapted>(mArrayGroups); - proxy.template ObjectAdapted>(mName2Parameters); - proxy.template ObjectAdapted>(mName2ArrayGroups); + Private::OperateStream(*this, stream); } -- cgit v1.2.3-70-g09d2