aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/Template/TableTemplate.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2021-09-04 17:58:56 -0700
committerrtk0c <[email protected]>2021-09-04 17:58:56 -0700
commit70e00f817e9596a746800ba4afec2b7c4ca25142 (patch)
tree52ca5f993034c6dcb7353805450e66cefc5a0481 /core/src/Model/Template/TableTemplate.cpp
parent500aa5130f3f5ad211749018d7be9b0ab46c12b4 (diff)
Migrate Template and TableTemplate to use DataStream
Diffstat (limited to 'core/src/Model/Template/TableTemplate.cpp')
-rw-r--r--core/src/Model/Template/TableTemplate.cpp56
1 files changed, 51 insertions, 5 deletions
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 <xlsxwriter.h>
+#include <algorithm>
#include <charconv>
+#include <cstddef>
+#include <cstdint>
#include <iostream>
#include <map>
@@ -20,6 +27,23 @@ bool TableCell::IsMergedCell() const
return PrimaryCellLocation.x == -1 || PrimaryCellLocation.y == -1;
}
+template <class TProxy>
+void TableCell::OperateIOProxy(TProxy& proxy)
+{
+ proxy.template ObjectAdapted<DataStreamAdapters::String>(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 <class TProxy>
+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 <class TProxy>
+void TableTemplate::OperateIOProxy(TProxy& proxy)
{
- // TODO
+ proxy.template ObjectAdapted<DataStreamAdapters::Vector<>>(mColumnWidths);
+ proxy.template ObjectAdapted<DataStreamAdapters::Vector<>>(mRowHeights);
+ proxy.template ObjectAdapted<DataStreamAdapters::Vector<>>(mCells);
+ proxy.template ObjectAdapted<DataStreamAdapters::Vector<>>(mArrayGroups);
+ proxy.template ObjectAdapted<DataStreamAdapters::TslArrayMap<>>(mName2Parameters);
+ proxy.template ObjectAdapted<DataStreamAdapters::TslArrayMap<>>(mName2ArrayGroups);
}