From 182c8f8357739f905bbd721006480502435b6b43 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 27 Nov 2022 12:04:31 -0800 Subject: Update brace style to match rest of my projects --- app/source/Cplt/Model/Template/TableTemplate.cpp | 150 ++++++++--------------- 1 file changed, 50 insertions(+), 100 deletions(-) (limited to 'app/source/Cplt/Model/Template/TableTemplate.cpp') diff --git a/app/source/Cplt/Model/Template/TableTemplate.cpp b/app/source/Cplt/Model/Template/TableTemplate.cpp index 5cd9ed8..c7faf24 100644 --- a/app/source/Cplt/Model/Template/TableTemplate.cpp +++ b/app/source/Cplt/Model/Template/TableTemplate.cpp @@ -12,24 +12,20 @@ #include #include -bool TableCell::IsDataHoldingCell() const -{ +bool TableCell::IsDataHoldingCell() const { return IsPrimaryCell() || !IsMergedCell(); } -bool TableCell::IsPrimaryCell() const -{ +bool TableCell::IsPrimaryCell() const { return PrimaryCellLocation == Location; } -bool TableCell::IsMergedCell() const -{ +bool TableCell::IsMergedCell() const { return PrimaryCellLocation.x == -1 || PrimaryCellLocation.y == -1; } template -void OperateStreamForTableCell(TTableCell& cell, TStream& proxy) -{ +void OperateStreamForTableCell(TTableCell& cell, TStream& proxy) { proxy.template ObjectAdapted(cell.Content); proxy.Object(cell.Location); proxy.Object(cell.PrimaryCellLocation); @@ -41,40 +37,33 @@ void OperateStreamForTableCell(TTableCell& cell, TStream& proxy) proxy.Value(cell.DataId); } -void TableCell::ReadFromDataStream(InputDataStream& stream) -{ +void TableCell::ReadFromDataStream(InputDataStream& stream) { ::OperateStreamForTableCell(*this, stream); } -void TableCell::WriteToDataStream(OutputDataStream& stream) const -{ +void TableCell::WriteToDataStream(OutputDataStream& stream) const { ::OperateStreamForTableCell(*this, stream); } -Vec2i TableArrayGroup::GetLeftCell() const -{ +Vec2i TableArrayGroup::GetLeftCell() const { return { Row, LeftCell }; } -Vec2i TableArrayGroup::GetRightCell() const -{ +Vec2i TableArrayGroup::GetRightCell() const { return { Row, RightCell }; } -int TableArrayGroup::GetCount() const -{ +int TableArrayGroup::GetCount() const { return RightCell - LeftCell + 1; } -Vec2i TableArrayGroup::FindCell(std::string_view name) -{ +Vec2i TableArrayGroup::FindCell(std::string_view name) { // TODO return Vec2i{}; } template -static bool UpdateElementName(TMap& map, std::string_view oldName, std::string_view newName) -{ +static bool UpdateElementName(TMap& map, std::string_view oldName, std::string_view newName) { auto iter = map.find(oldName); if (iter == map.end()) { return false; @@ -90,75 +79,62 @@ static bool UpdateElementName(TMap& map, std::string_view oldName, std::string_v return true; } -bool TableArrayGroup::UpdateCellName(std::string_view oldName, std::string_view newName) -{ +bool TableArrayGroup::UpdateCellName(std::string_view oldName, std::string_view newName) { return ::UpdateElementName(mName2Cell, oldName, newName); } template -void OperateStreamForTableArrayGroup(TTableArrayGroup& group, TStream& stream) -{ +void OperateStreamForTableArrayGroup(TTableArrayGroup& group, TStream& stream) { stream.Value(group.Row); stream.Value(group.LeftCell); stream.Value(group.RightCell); } -void TableArrayGroup::ReadFromDataStream(InputDataStream& stream) -{ +void TableArrayGroup::ReadFromDataStream(InputDataStream& stream) { ::OperateStreamForTableArrayGroup(*this, stream); } -void TableArrayGroup::WriteToDataStream(OutputDataStream& stream) const -{ +void TableArrayGroup::WriteToDataStream(OutputDataStream& stream) const { ::OperateStreamForTableArrayGroup(*this, stream); } TableInstantiationParameters::TableInstantiationParameters(const TableTemplate& table) - : mTable{ &table } -{ + : mTable{ &table } { } -TableInstantiationParameters& TableInstantiationParameters::ResetTable(const TableTemplate& newTable) -{ +TableInstantiationParameters& TableInstantiationParameters::ResetTable(const TableTemplate& newTable) { mTable = &newTable; return *this; } -TableInstantiationParameters TableInstantiationParameters::RebindTable(const TableTemplate& newTable) const -{ +TableInstantiationParameters TableInstantiationParameters::RebindTable(const TableTemplate& newTable) const { TableInstantiationParameters result(newTable); result.SingularCells = this->SingularCells; result.ArrayGroups = this->ArrayGroups; return result; } -const TableTemplate& TableInstantiationParameters::GetTable() const -{ +const TableTemplate& TableInstantiationParameters::GetTable() const { return *mTable; } -bool TableTemplate::IsInstance(const Template* tmpl) -{ +bool TableTemplate::IsInstance(const Template* tmpl) { return tmpl->GetKind() == KD_Table; } TableTemplate::TableTemplate() - : Template(KD_Table) -{ + : Template(KD_Table) { } -int TableTemplate::GetTableWidth() const -{ +int TableTemplate::GetTableWidth() const { return mColumnWidths.size(); } -int TableTemplate::GetTableHeight() const -{ +int TableTemplate::GetTableHeight() const { return mRowHeights.size(); } -void TableTemplate::Resize(int newWidth, int newHeight) -{ +void TableTemplate::Resize(int newWidth, int newHeight) { // TODO this doesn't gracefully handle resizing to a smaller size which trims some merged cells std::vector cells; @@ -190,39 +166,32 @@ void TableTemplate::Resize(int newWidth, int newHeight) mRowHeights.resize(newHeight, 20); } -int TableTemplate::GetRowHeight(int row) const -{ +int TableTemplate::GetRowHeight(int row) const { return mRowHeights[row]; } -void TableTemplate::SetRowHeight(int row, int height) -{ +void TableTemplate::SetRowHeight(int row, int height) { mRowHeights[row] = height; } -int TableTemplate::GetColumnWidth(int column) const -{ +int TableTemplate::GetColumnWidth(int column) const { return mColumnWidths[column]; } -void TableTemplate::SetColumnWidth(int column, int width) -{ +void TableTemplate::SetColumnWidth(int column, int width) { mColumnWidths[column] = width; } -const TableCell& TableTemplate::GetCell(Vec2i pos) const -{ +const TableCell& TableTemplate::GetCell(Vec2i pos) const { int tableWidth = GetTableWidth(); return mCells[pos.y * tableWidth + pos.x]; } -TableCell& TableTemplate::GetCell(Vec2i pos) -{ +TableCell& TableTemplate::GetCell(Vec2i pos) { return const_cast(const_cast(this)->GetCell(pos)); } -void TableTemplate::SetCellType(Vec2i pos, TableCell::CellType type) -{ +void TableTemplate::SetCellType(Vec2i pos, TableCell::CellType type) { auto& cell = GetCell(pos); if (cell.Type == type) { return; @@ -274,28 +243,23 @@ void TableTemplate::SetCellType(Vec2i pos, TableCell::CellType type) cell.Type = type; } -bool TableTemplate::UpdateParameterName(std::string_view oldName, std::string_view newName) -{ +bool TableTemplate::UpdateParameterName(std::string_view oldName, std::string_view newName) { return ::UpdateElementName(mName2Parameters, oldName, newName); } -int TableTemplate::GetArrayGroupCount() const -{ +int TableTemplate::GetArrayGroupCount() const { return mArrayGroups.size(); } -const TableArrayGroup& TableTemplate::GetArrayGroup(int id) const -{ +const TableArrayGroup& TableTemplate::GetArrayGroup(int id) const { return mArrayGroups[id]; } -TableArrayGroup& TableTemplate::GetArrayGroup(int id) -{ +TableArrayGroup& TableTemplate::GetArrayGroup(int id) { return mArrayGroups[id]; } -TableArrayGroup* TableTemplate::AddArrayGroup(int row, int left, int right) -{ +TableArrayGroup* TableTemplate::AddArrayGroup(int row, int left, int right) { // size_t max value: 18446744073709551615 // ^~~~~~~~~~~~~~~~~~~~ 20 chars char name[20]; @@ -305,8 +269,7 @@ TableArrayGroup* TableTemplate::AddArrayGroup(int row, int left, int right) return AddArrayGroup(nameStr, row, left, right); } -TableArrayGroup* TableTemplate::AddArrayGroup(std::string_view name, int row, int left, int right) -{ +TableArrayGroup* TableTemplate::AddArrayGroup(std::string_view name, int row, int left, int right) { assert(row >= 0 && row < GetTableHeight()); assert(left >= 0 && left < GetTableWidth()); assert(right >= 0 && right < GetTableWidth()); @@ -349,13 +312,11 @@ TableArrayGroup* TableTemplate::AddArrayGroup(std::string_view name, int row, in return &ag; } -bool TableTemplate::UpdateArrayGroupName(std::string_view oldName, std::string_view newName) -{ +bool TableTemplate::UpdateArrayGroupName(std::string_view oldName, std::string_view newName) { return ::UpdateElementName(mName2ArrayGroups, oldName, newName); } -bool TableTemplate::ExtendArrayGroupLeft(int id, int n) -{ +bool TableTemplate::ExtendArrayGroupLeft(int id, int n) { assert(n > 0); auto& ag = mArrayGroups[id]; @@ -364,8 +325,7 @@ bool TableTemplate::ExtendArrayGroupLeft(int id, int n) return false; } -bool TableTemplate::ExtendArrayGroupRight(int id, int n) -{ +bool TableTemplate::ExtendArrayGroupRight(int id, int n) { assert(n > 0); auto& ag = mArrayGroups[id]; @@ -374,8 +334,7 @@ bool TableTemplate::ExtendArrayGroupRight(int id, int n) return false; } -TableCell* TableTemplate::FindCell(std::string_view name) -{ +TableCell* TableTemplate::FindCell(std::string_view name) { auto iter = mName2Parameters.find(name); if (iter != mName2Parameters.end()) { return &mCells[iter.value()]; @@ -384,8 +343,7 @@ TableCell* TableTemplate::FindCell(std::string_view name) } } -TableArrayGroup* TableTemplate::FindArrayGroup(std::string_view name) -{ +TableArrayGroup* TableTemplate::FindArrayGroup(std::string_view name) { auto iter = mName2ArrayGroups.find(name); if (iter != mName2ArrayGroups.end()) { return &mArrayGroups[iter.value()]; @@ -394,8 +352,7 @@ TableArrayGroup* TableTemplate::FindArrayGroup(std::string_view name) } } -TableTemplate::MergeCellsResult TableTemplate::MergeCells(Vec2i topLeft, Vec2i bottomRight) -{ +TableTemplate::MergeCellsResult TableTemplate::MergeCells(Vec2i topLeft, Vec2i bottomRight) { auto SortTwo = [](int& a, int& b) { if (a > b) { std::swap(a, b); @@ -432,8 +389,7 @@ TableTemplate::MergeCellsResult TableTemplate::MergeCells(Vec2i topLeft, Vec2i b return MCR_Success; } -TableTemplate::BreakCellsResult TableTemplate::BreakCells(Vec2i topLeft) -{ +TableTemplate::BreakCellsResult TableTemplate::BreakCells(Vec2i topLeft) { auto& primaryCell = GetCell(topLeft); if (!primaryCell.IsMergedCell()) { return BCR_CellNotMerged; @@ -452,15 +408,13 @@ TableTemplate::BreakCellsResult TableTemplate::BreakCells(Vec2i topLeft) return BCR_Success; } -lxw_workbook* TableTemplate::InstantiateToExcelWorkbook(const TableInstantiationParameters& params) const -{ +lxw_workbook* TableTemplate::InstantiateToExcelWorkbook(const TableInstantiationParameters& params) const { auto workbook = workbook_new("Table.xlsx"); InstantiateToExcelWorksheet(workbook, params); return workbook; } -lxw_worksheet* TableTemplate::InstantiateToExcelWorksheet(lxw_workbook* workbook, const TableInstantiationParameters& params) const -{ +lxw_worksheet* TableTemplate::InstantiateToExcelWorksheet(lxw_workbook* workbook, const TableInstantiationParameters& params) const { auto worksheet = workbook_add_worksheet(workbook, "CpltExport.xlsx"); // Map: row number -> length of generated ranges @@ -565,12 +519,10 @@ lxw_worksheet* TableTemplate::InstantiateToExcelWorksheet(lxw_workbook* workbook return worksheet; } -class TableTemplate::Private -{ +class TableTemplate::Private { public: template - static void OperateStream(TTableTemplate& table, TProxy& proxy) - { + static void OperateStream(TTableTemplate& table, TProxy& proxy) { proxy.template ObjectAdapted>(table.mColumnWidths); proxy.template ObjectAdapted>(table.mRowHeights); proxy.template ObjectAdapted>(table.mCells); @@ -580,12 +532,10 @@ public: } }; -void TableTemplate::ReadFromDataStream(InputDataStream& stream) -{ +void TableTemplate::ReadFromDataStream(InputDataStream& stream) { Private::OperateStream(*this, stream); } -void TableTemplate::WriteToDataStream(OutputDataStream& stream) const -{ +void TableTemplate::WriteToDataStream(OutputDataStream& stream) const { Private::OperateStream(*this, stream); } -- cgit v1.2.3-70-g09d2