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/Assets.cpp | 81 +++---- app/source/Cplt/Model/Assets.hpp | 27 +-- app/source/Cplt/Model/Database.cpp | 42 ++-- app/source/Cplt/Model/Database.hpp | 18 +- app/source/Cplt/Model/Filter.hpp | 3 +- app/source/Cplt/Model/GlobalStates.cpp | 48 ++-- app/source/Cplt/Model/GlobalStates.hpp | 6 +- app/source/Cplt/Model/Items.cpp | 60 ++--- app/source/Cplt/Model/Items.hpp | 69 ++---- app/source/Cplt/Model/Project.cpp | 51 ++--- app/source/Cplt/Model/Project.hpp | 3 +- app/source/Cplt/Model/Template/TableTemplate.cpp | 150 ++++-------- app/source/Cplt/Model/Template/TableTemplate.hpp | 24 +- .../Cplt/Model/Template/TableTemplateIterator.cpp | 27 +-- .../Cplt/Model/Template/TableTemplateIterator.hpp | 6 +- app/source/Cplt/Model/Template/Template.hpp | 9 +- app/source/Cplt/Model/Template/Template_Main.cpp | 39 ++-- app/source/Cplt/Model/Template/Template_RTTI.cpp | 9 +- app/source/Cplt/Model/Workflow/Evaluation.cpp | 51 ++--- app/source/Cplt/Model/Workflow/Evaluation.hpp | 12 +- .../Cplt/Model/Workflow/Nodes/DocumentNodes.cpp | 9 +- .../Cplt/Model/Workflow/Nodes/DocumentNodes.hpp | 3 +- .../Cplt/Model/Workflow/Nodes/NumericNodes.cpp | 24 +- .../Cplt/Model/Workflow/Nodes/NumericNodes.hpp | 9 +- app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp | 51 ++--- app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp | 9 +- .../Cplt/Model/Workflow/Nodes/UserInputNodes.cpp | 18 +- .../Cplt/Model/Workflow/Nodes/UserInputNodes.hpp | 6 +- app/source/Cplt/Model/Workflow/Value.hpp | 18 +- app/source/Cplt/Model/Workflow/Value_Main.cpp | 21 +- app/source/Cplt/Model/Workflow/Value_RTTI.cpp | 18 +- app/source/Cplt/Model/Workflow/Values/Basic.cpp | 54 ++--- app/source/Cplt/Model/Workflow/Values/Basic.hpp | 9 +- app/source/Cplt/Model/Workflow/Values/Database.cpp | 36 +-- app/source/Cplt/Model/Workflow/Values/Database.hpp | 9 +- .../Cplt/Model/Workflow/Values/Dictionary.cpp | 21 +- .../Cplt/Model/Workflow/Values/Dictionary.hpp | 3 +- app/source/Cplt/Model/Workflow/Values/List.cpp | 57 ++--- app/source/Cplt/Model/Workflow/Values/List.hpp | 6 +- app/source/Cplt/Model/Workflow/Workflow.hpp | 33 +-- app/source/Cplt/Model/Workflow/Workflow_Main.cpp | 252 +++++++-------------- app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp | 21 +- 42 files changed, 474 insertions(+), 948 deletions(-) (limited to 'app/source/Cplt/Model') diff --git a/app/source/Cplt/Model/Assets.cpp b/app/source/Cplt/Model/Assets.cpp index 0dfe847..42eacf3 100644 --- a/app/source/Cplt/Model/Assets.cpp +++ b/app/source/Cplt/Model/Assets.cpp @@ -17,27 +17,23 @@ using namespace std::literals::string_view_literals; namespace fs = std::filesystem; template -void OperateStreamForSavedAsset(TSavedAsset& cell, TStream& proxy) -{ +void OperateStreamForSavedAsset(TSavedAsset& cell, TStream& proxy) { proxy.template ObjectAdapted(cell.Name); proxy.template ObjectAdapted(cell.Uuid); proxy.Value(cell.Payload); } -void SavedAsset::ReadFromDataStream(InputDataStream& stream) -{ +void SavedAsset::ReadFromDataStream(InputDataStream& stream) { ::OperateStreamForSavedAsset(*this, stream); } -void SavedAsset::WriteToDataStream(OutputDataStream& stream) const -{ +void SavedAsset::WriteToDataStream(OutputDataStream& stream) const { ::OperateStreamForSavedAsset(*this, stream); } Asset::Asset() = default; -class AssetList::Private -{ +class AssetList::Private { public: Project* ConnectedProject; tsl::array_map Assets; @@ -49,8 +45,7 @@ public: std::string NewName; NameSelectionError NewNameError = NameSelectionError::Empty; - void ShowErrors() const - { + void ShowErrors() const { switch (NewNameError) { case NameSelectionError::None: break; case NameSelectionError::Duplicated: @@ -62,13 +57,11 @@ public: } } - bool HasErrors() const - { + bool HasErrors() const { return NewNameError != NameSelectionError::None; } - void Validate(const AssetList& self) - { + void Validate(const AssetList& self) { if (NewName.empty()) { NewNameError = NameSelectionError::Empty; return; @@ -85,23 +78,19 @@ public: }; AssetList::AssetList(Project& project) - : mPrivate{ std::make_unique() } -{ + : mPrivate{ std::make_unique() } { mPrivate->ConnectedProject = &project; } // Write an empty destructor here so std::unique_ptr's destructor can see AssetList::Private's implementation -AssetList::~AssetList() -{ +AssetList::~AssetList() { } -Project& AssetList::GetConnectedProject() const -{ +Project& AssetList::GetConnectedProject() const { return *mPrivate->ConnectedProject; } -void AssetList::Reload() -{ +void AssetList::Reload() { // TODO fix asset dicovery loading mPrivate->Assets.clear(); mPrivate->Cache.clear(); @@ -110,18 +99,15 @@ void AssetList::Reload() }); } -int AssetList::GetCount() const -{ +int AssetList::GetCount() const { return mPrivate->Assets.size(); } -const tsl::array_map& AssetList::GetAssets() const -{ +const tsl::array_map& AssetList::GetAssets() const { return mPrivate->Assets; } -const SavedAsset* AssetList::FindByName(std::string_view name) const -{ +const SavedAsset* AssetList::FindByName(std::string_view name) const { auto iter = mPrivate->Assets.find(name); if (iter != mPrivate->Assets.end()) { return &iter.value(); @@ -130,8 +116,7 @@ const SavedAsset* AssetList::FindByName(std::string_view name) const } } -const SavedAsset& AssetList::Create(SavedAsset asset) -{ +const SavedAsset& AssetList::Create(SavedAsset asset) { auto [iter, DISCARD] = mPrivate->Assets.insert(asset.Name, SavedAsset{}); auto& savedAsset = iter.value(); @@ -145,15 +130,13 @@ const SavedAsset& AssetList::Create(SavedAsset asset) return savedAsset; } -std::unique_ptr AssetList::CreateAndLoad(SavedAsset assetIn) -{ +std::unique_ptr AssetList::CreateAndLoad(SavedAsset assetIn) { auto& savedAsset = Create(std::move(assetIn)); auto asset = std::unique_ptr(CreateInstance(savedAsset)); return asset; } -std::unique_ptr AssetList::Load(std::string_view name) const -{ +std::unique_ptr AssetList::Load(std::string_view name) const { if (auto savedAsset = FindByName(name)) { auto asset = Load(*savedAsset); return asset; @@ -162,13 +145,11 @@ std::unique_ptr AssetList::Load(std::string_view name) const } } -std::unique_ptr AssetList::Load(const SavedAsset& asset) const -{ +std::unique_ptr AssetList::Load(const SavedAsset& asset) const { return std::unique_ptr(LoadInstance(asset)); } -const SavedAsset* AssetList::Rename(std::string_view oldName, std::string_view newName) -{ +const SavedAsset* AssetList::Rename(std::string_view oldName, std::string_view newName) { auto iter = mPrivate->Assets.find(oldName); if (iter == mPrivate->Assets.end()) return nullptr; @@ -183,8 +164,7 @@ const SavedAsset* AssetList::Rename(std::string_view oldName, std::string_view n return &newIter.value(); } -bool AssetList::Remove(std::string_view name) -{ +bool AssetList::Remove(std::string_view name) { auto iter = mPrivate->Assets.find(name); if (iter == mPrivate->Assets.end()) { return false; @@ -197,29 +177,24 @@ bool AssetList::Remove(std::string_view name) return true; } -int AssetList::GetCacheSizeLimit() const -{ +int AssetList::GetCacheSizeLimit() const { return mPrivate->CacheSizeLimit; } -void AssetList::SetCacheSizeLimit(int limit) -{ +void AssetList::SetCacheSizeLimit(int limit) { mPrivate->CacheSizeLimit = limit; } -void AssetList::DisplayIconsList(ListState& state) -{ +void AssetList::DisplayIconsList(ListState& state) { // TODO } -void AssetList::DisplayDetailsList(ListState& state) -{ +void AssetList::DisplayDetailsList(ListState& state) { // Note: stub function remained here in case any state processing needs to be done before issuing to implementers DisplayDetailsTable(state); } -void AssetList::DisplayControls(ListState& state) -{ +void AssetList::DisplayControls(ListState& state) { auto& ps = mPrivate->PopupPrivateState; bool openedDummy = true; @@ -280,8 +255,7 @@ void AssetList::DisplayControls(ListState& state) } } -void AssetList::DiscoverFilesByExtension(const std::function& callback, const fs::path& containerDir, std::string_view extension) const -{ +void AssetList::DiscoverFilesByExtension(const std::function& callback, const fs::path& containerDir, std::string_view extension) const { for (auto entry : fs::directory_iterator(containerDir)) { if (!entry.is_regular_file()) continue; @@ -300,7 +274,6 @@ void AssetList::DiscoverFilesByExtension(const std::function& } } -void AssetList::DiscoverFilesByHeader(const std::function& callback, const fs::path& containerDir, const std::function& validater) const -{ +void AssetList::DiscoverFilesByHeader(const std::function& callback, const fs::path& containerDir, const std::function& validater) const { // TODO } diff --git a/app/source/Cplt/Model/Assets.hpp b/app/source/Cplt/Model/Assets.hpp index d2f8570..309d967 100644 --- a/app/source/Cplt/Model/Assets.hpp +++ b/app/source/Cplt/Model/Assets.hpp @@ -12,8 +12,7 @@ /// A structure representing a ready-to-be-loaded asset, locating on the disk. /// Each asset should be identified by a unique uuid within the asset category (i.e. a workflow and a template can share the same uuid), /// generated on insertion to an asset list if not given by the caller. -struct SavedAsset -{ +struct SavedAsset { std::string Name; /// UUID of this asset. This field is generated as a random UUID v4 upon insertion into an AssetList, if not already provided by the caller (indicated by !is_nil()). uuids::uuid Uuid; @@ -24,22 +23,19 @@ struct SavedAsset void WriteToDataStream(OutputDataStream& stream) const; }; -class Asset -{ +class Asset { public: Asset(); virtual ~Asset() = default; }; -enum class NameSelectionError -{ +enum class NameSelectionError { None, Duplicated, Empty, }; -class AssetList -{ +class AssetList { private: class Private; std::unique_ptr mPrivate; @@ -71,8 +67,7 @@ public: int GetCacheSizeLimit() const; void SetCacheSizeLimit(int limit); - struct ListState - { + struct ListState { const SavedAsset* SelectedAsset = nullptr; }; void DisplayIconsList(ListState& state); @@ -105,25 +100,21 @@ protected: }; template -class AssetListTyped : public AssetList -{ +class AssetListTyped : public AssetList { public: using AssetList::AssetList; #pragma clang diagnostic push #pragma ide diagnostic ignored "HidingNonVirtualFunction" - std::unique_ptr CreateAndLoad(SavedAsset asset) - { + std::unique_ptr CreateAndLoad(SavedAsset asset) { return std::unique_ptr(static_cast(AssetList::CreateAndLoad(asset).release())); } - std::unique_ptr Load(std::string_view name) const - { + std::unique_ptr Load(std::string_view name) const { return std::unique_ptr(static_cast(AssetList::Load(name).release())); } - std::unique_ptr Load(const SavedAsset& asset) const - { + std::unique_ptr Load(const SavedAsset& asset) const { return std::unique_ptr(static_cast(AssetList::Load(asset).release())); } #pragma clang diagnostic pop diff --git a/app/source/Cplt/Model/Database.cpp b/app/source/Cplt/Model/Database.cpp index 07c6e36..7f78ff4 100644 --- a/app/source/Cplt/Model/Database.cpp +++ b/app/source/Cplt/Model/Database.cpp @@ -13,8 +13,7 @@ SalesTable::SalesTable(MainDatabase& db) // language=SQLite , GetRows(db.GetSQLite(), "SELECT * FROM Sales LIMIT ? OFFSET ?") // language=SQLite - , GetItems(db.GetSQLite(), "SELECT * FROM SalesItems WHERE SaleId == ?") -{ + , GetItems(db.GetSQLite(), "SELECT * FROM SalesItems WHERE SaleId == ?") { } PurchasesTable::PurchasesTable(MainDatabase& db) @@ -23,20 +22,17 @@ PurchasesTable::PurchasesTable(MainDatabase& db) // language=SQLite , GetRows(db.GetSQLite(), "SELECT * FROM Purchases LIMIT ? OFFSET ?") // language=SQLite - , GetItems(db.GetSQLite(), "SELECT * FROM PurchasesItems WHERE PurchaseId == ?") -{ + , GetItems(db.GetSQLite(), "SELECT * FROM PurchasesItems WHERE PurchaseId == ?") { } DeliveryTable::DeliveryTable(MainDatabase& db) // language=SQLite : FilterByTypeAndId(db.GetSQLite(), "SELECT * FROM Deliveries WHERE AssociatedOrder == ? AND Outgoing = ?") // language=SQLite - , GetItems(db.GetSQLite(), "SELECT * FROM DeliveriesItems WHERE DeliveryId == ?") -{ + , GetItems(db.GetSQLite(), "SELECT * FROM DeliveriesItems WHERE DeliveryId == ?") { } -static std::string GetDatabaseFilePath(const Project& project) -{ +static std::string GetDatabaseFilePath(const Project& project) { auto dbsDir = project.GetPath() / "databases"; fs::create_directories(dbsDir); @@ -46,8 +42,7 @@ static std::string GetDatabaseFilePath(const Project& project) /// Wrapper for SQLite::Database that creates the default tables MainDatabase::DatabaseWrapper::DatabaseWrapper(MainDatabase& self) - : mSqlite(GetDatabaseFilePath(*self.mProject), SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE) -{ + : mSqlite(GetDatabaseFilePath(*self.mProject), SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE) { // If this table doesn't exist, the database probably just got initialized if (mSqlite.tableExists("Sales")) { return; @@ -118,46 +113,37 @@ MainDatabase::MainDatabase(Project& project) , mDbWrapper(*this) , mSales(*this) , mPurchases(*this) - , mDeliveries(*this) -{ + , mDeliveries(*this) { } -const SQLite::Database& MainDatabase::GetSQLite() const -{ +const SQLite::Database& MainDatabase::GetSQLite() const { return mDbWrapper.mSqlite; } -SQLite::Database& MainDatabase::GetSQLite() -{ +SQLite::Database& MainDatabase::GetSQLite() { return mDbWrapper.mSqlite; } -const SalesTable& MainDatabase::GetSales() const -{ +const SalesTable& MainDatabase::GetSales() const { return mSales; } -SalesTable& MainDatabase::GetSales() -{ +SalesTable& MainDatabase::GetSales() { return mSales; } -const PurchasesTable& MainDatabase::GetPurchases() const -{ +const PurchasesTable& MainDatabase::GetPurchases() const { return mPurchases; } -PurchasesTable& MainDatabase::GetPurchases() -{ +PurchasesTable& MainDatabase::GetPurchases() { return mPurchases; } -const DeliveryTable& MainDatabase::GetDeliveries() const -{ +const DeliveryTable& MainDatabase::GetDeliveries() const { return mDeliveries; } -DeliveryTable& MainDatabase::GetDeliveries() -{ +DeliveryTable& MainDatabase::GetDeliveries() { return mDeliveries; } diff --git a/app/source/Cplt/Model/Database.hpp b/app/source/Cplt/Model/Database.hpp index 222e43d..7d6509b 100644 --- a/app/source/Cplt/Model/Database.hpp +++ b/app/source/Cplt/Model/Database.hpp @@ -6,8 +6,7 @@ #include #include -enum class TableKind -{ +enum class TableKind { Sales, SalesItems, Purchases, @@ -16,8 +15,7 @@ enum class TableKind DeliveriesItems, }; -class SalesTable -{ +class SalesTable { public: SQLite::Statement GetRowCount; SQLite::Statement GetRows; @@ -27,8 +25,7 @@ public: SalesTable(MainDatabase& db); }; -class PurchasesTable -{ +class PurchasesTable { public: SQLite::Statement GetRowCount; SQLite::Statement GetRows; @@ -38,8 +35,7 @@ public: PurchasesTable(MainDatabase& db); }; -class DeliveryTable -{ +class DeliveryTable { public: SQLite::Statement FilterByTypeAndId; SQLite::Statement GetItems; @@ -48,11 +44,9 @@ public: DeliveryTable(MainDatabase& db); }; -class MainDatabase -{ +class MainDatabase { private: - class DatabaseWrapper - { + class DatabaseWrapper { public: SQLite::Database mSqlite; DatabaseWrapper(MainDatabase& self); diff --git a/app/source/Cplt/Model/Filter.hpp b/app/source/Cplt/Model/Filter.hpp index 1b923e1..53995c1 100644 --- a/app/source/Cplt/Model/Filter.hpp +++ b/app/source/Cplt/Model/Filter.hpp @@ -1,6 +1,5 @@ #pragma once -class TableRowsFilter -{ +class TableRowsFilter { // TODO }; diff --git a/app/source/Cplt/Model/GlobalStates.cpp b/app/source/Cplt/Model/GlobalStates.cpp index 417514f..b21e299 100644 --- a/app/source/Cplt/Model/GlobalStates.cpp +++ b/app/source/Cplt/Model/GlobalStates.cpp @@ -16,13 +16,11 @@ namespace fs = std::filesystem; static std::unique_ptr globalStateInstance; static fs::path globalDataPath; -void GlobalStates::Init() -{ +void GlobalStates::Init() { Init(StandardDirectories::UserData() / "cplt"); } -void GlobalStates::Init(std::filesystem::path userDataDir) -{ +void GlobalStates::Init(std::filesystem::path userDataDir) { globalStateInstance = std::make_unique(); globalDataPath = userDataDir; fs::create_directories(globalDataPath); @@ -53,8 +51,7 @@ void GlobalStates::Init(std::filesystem::path userDataDir) } } -void GlobalStates::Shutdown() -{ +void GlobalStates::Shutdown() { if (!globalStateInstance) return; globalStateInstance->SetCurrentProject(nullptr); @@ -64,29 +61,24 @@ void GlobalStates::Shutdown() } } -GlobalStates& GlobalStates::GetInstance() -{ +GlobalStates& GlobalStates::GetInstance() { return *globalStateInstance; } -const std::filesystem::path& GlobalStates::GetUserDataPath() -{ +const std::filesystem::path& GlobalStates::GetUserDataPath() { return globalDataPath; } -const std::vector& GlobalStates::GetRecentProjects() const -{ +const std::vector& GlobalStates::GetRecentProjects() const { return mRecentProjects; } -void GlobalStates::ClearRecentProjects() -{ +void GlobalStates::ClearRecentProjects() { mRecentProjects.clear(); MarkDirty(); } -void GlobalStates::AddRecentProject(const Project& project) -{ +void GlobalStates::AddRecentProject(const Project& project) { mRecentProjects.push_back(RecentProject{ .Path = project.GetPath(), .CachedUtf8String = project.GetPath().string(), @@ -94,8 +86,7 @@ void GlobalStates::AddRecentProject(const Project& project) MarkDirty(); } -void GlobalStates::MoveProjectToTop(const Project& project) -{ +void GlobalStates::MoveProjectToTop(const Project& project) { for (auto it = mRecentProjects.begin(); it != mRecentProjects.end(); ++it) { if (it->Path == project.GetPath()) { std::rotate(it, it + 1, mRecentProjects.end()); @@ -106,26 +97,22 @@ void GlobalStates::MoveProjectToTop(const Project& project) AddRecentProject(project); } -void GlobalStates::RemoveRecentProject(int idx) -{ +void GlobalStates::RemoveRecentProject(int idx) { assert(idx >= 0 && idx < mRecentProjects.size()); mRecentProjects.erase(mRecentProjects.begin() + idx); MarkDirty(); } -bool GlobalStates::HasCurrentProject() const -{ +bool GlobalStates::HasCurrentProject() const { return mCurrentProject != nullptr; } -Project* GlobalStates::GetCurrentProject() const -{ +Project* GlobalStates::GetCurrentProject() const { return mCurrentProject.get(); } -void GlobalStates::SetCurrentProject(std::unique_ptr project) -{ +void GlobalStates::SetCurrentProject(std::unique_ptr project) { if (mCurrentProject) { mCurrentProject->WriteToDisk(); mCurrentProject = nullptr; @@ -136,8 +123,7 @@ void GlobalStates::SetCurrentProject(std::unique_ptr project) mCurrentProject = std::move(project); } -void GlobalStates::WriteToDisk() const -{ +void GlobalStates::WriteToDisk() const { Json::Value root; auto& recentProjects = root["RecentProjects"] = Json::Value(Json::arrayValue); @@ -151,13 +137,11 @@ void GlobalStates::WriteToDisk() const mDirty = false; } -bool GlobalStates::IsDirty() const -{ +bool GlobalStates::IsDirty() const { return mDirty; } -void GlobalStates::MarkDirty() -{ +void GlobalStates::MarkDirty() { mDirty = true; OnModified(); } diff --git a/app/source/Cplt/Model/GlobalStates.hpp b/app/source/Cplt/Model/GlobalStates.hpp index 1eb47fb..c0b475c 100644 --- a/app/source/Cplt/Model/GlobalStates.hpp +++ b/app/source/Cplt/Model/GlobalStates.hpp @@ -7,8 +7,7 @@ #include #include -class GlobalStates -{ +class GlobalStates { public: static void Init(); static void Init(std::filesystem::path userDataDir); @@ -17,8 +16,7 @@ public: static GlobalStates& GetInstance(); static const std::filesystem::path& GetUserDataPath(); - struct RecentProject - { + struct RecentProject { std::filesystem::path Path; std::string CachedUtf8String; }; diff --git a/app/source/Cplt/Model/Items.cpp b/app/source/Cplt/Model/Items.cpp index 9d2abc6..02a4516 100644 --- a/app/source/Cplt/Model/Items.cpp +++ b/app/source/Cplt/Model/Items.cpp @@ -1,36 +1,29 @@ #include "Items.hpp" -const std::string& ProductItem::GetDescription() const -{ +const std::string& ProductItem::GetDescription() const { return mDescription; } -void ProductItem::SetDescription(std::string description) -{ +void ProductItem::SetDescription(std::string description) { mDescription = std::move(description); } -int ProductItem::GetPrice() const -{ +int ProductItem::GetPrice() const { return mPrice; } -void ProductItem::SetPrice(int price) -{ +void ProductItem::SetPrice(int price) { mPrice = price; } -int ProductItem::GetStock() const -{ +int ProductItem::GetStock() const { return mStock; } -void ProductItem::SetStock(int stock) -{ +void ProductItem::SetStock(int stock) { mStock = stock; } -Json::Value ProductItem::Serialize() const -{ +Json::Value ProductItem::Serialize() const { Json::Value elm; elm["Description"] = mDescription; elm["Price"] = mPrice; @@ -38,77 +31,64 @@ Json::Value ProductItem::Serialize() const return elm; } -void ProductItem::Deserialize(const Json::Value& elm) -{ +void ProductItem::Deserialize(const Json::Value& elm) { mDescription = elm["Description"].asString(); mPrice = elm["Price"].asInt(); mStock = elm["Stock"].asInt(); } -const std::string& FactoryItem::GetDescription() const -{ +const std::string& FactoryItem::GetDescription() const { return mDescription; } -void FactoryItem::SetDescription(std::string description) -{ +void FactoryItem::SetDescription(std::string description) { mDescription = std::move(description); } -const std::string& FactoryItem::GetEmail() const -{ +const std::string& FactoryItem::GetEmail() const { return mEmail; } -void FactoryItem::SetEmail(std::string email) -{ +void FactoryItem::SetEmail(std::string email) { mEmail = std::move(email); } -Json::Value FactoryItem::Serialize() const -{ +Json::Value FactoryItem::Serialize() const { Json::Value elm; elm["Description"] = mDescription; elm["Email"] = mEmail; return elm; } -void FactoryItem::Deserialize(const Json::Value& elm) -{ +void FactoryItem::Deserialize(const Json::Value& elm) { mDescription = elm["Description"].asString(); mEmail = elm["Email"].asString(); } -const std::string& CustomerItem::GetDescription() const -{ +const std::string& CustomerItem::GetDescription() const { return mDescription; } -void CustomerItem::SetDescription(std::string description) -{ +void CustomerItem::SetDescription(std::string description) { mDescription = std::move(description); } -const std::string& CustomerItem::GetEmail() const -{ +const std::string& CustomerItem::GetEmail() const { return mEmail; } -void CustomerItem::SetEmail(std::string email) -{ +void CustomerItem::SetEmail(std::string email) { mEmail = std::move(email); } -Json::Value CustomerItem::Serialize() const -{ +Json::Value CustomerItem::Serialize() const { Json::Value elm; elm["Description"] = mDescription; elm["Email"] = mEmail; return elm; } -void CustomerItem::Deserialize(const Json::Value& elm) -{ +void CustomerItem::Deserialize(const Json::Value& elm) { mDescription = elm["Description"].asString(); mEmail = elm["Email"].asString(); } diff --git a/app/source/Cplt/Model/Items.hpp b/app/source/Cplt/Model/Items.hpp index c00ee59..f3254e2 100644 --- a/app/source/Cplt/Model/Items.hpp +++ b/app/source/Cplt/Model/Items.hpp @@ -15,16 +15,14 @@ #include template -class ItemList -{ +class ItemList { private: std::vector mStorage; tsl::array_map mNameLookup; public: template - T& Insert(std::string name, Args... args) - { + T& Insert(std::string name, Args... args) { auto iter = mNameLookup.find(name); if (iter != mNameLookup.end()) { throw std::runtime_error("Duplicate key."); @@ -44,25 +42,21 @@ public: return mStorage[id]; } - void Remove(size_t index) - { + void Remove(size_t index) { auto& item = mStorage[index]; mNameLookup.erase(item.GetName()); mStorage[index] = T(*this); } - T* Find(size_t id) - { + T* Find(size_t id) { return &mStorage[id]; } - const T* Find(size_t id) const - { + const T* Find(size_t id) const { return &mStorage[id]; } - const T* Find(std::string_view name) const - { + const T* Find(std::string_view name) const { auto iter = mNameLookup.find(name); if (iter != mNameLookup.end()) { return &mStorage[iter.value()]; @@ -71,8 +65,7 @@ public: } } - Json::Value Serialize() const - { + Json::Value Serialize() const { Json::Value items(Json::arrayValue); for (auto& item : mStorage) { if (!item.IsInvalid()) { @@ -92,8 +85,7 @@ public: ItemList() = default; - ItemList(const Json::Value& root) - { + ItemList(const Json::Value& root) { constexpr const char* kMessage = "Failed to load item list from JSON."; auto& itemCount = root["MaxItemId"]; @@ -118,23 +110,19 @@ public: } } - typename decltype(mStorage)::iterator begin() - { + typename decltype(mStorage)::iterator begin() { return mStorage.begin(); } - typename decltype(mStorage)::iterator end() - { + typename decltype(mStorage)::iterator end() { return mStorage.end(); } - typename decltype(mStorage)::const_iterator begin() const - { + typename decltype(mStorage)::const_iterator begin() const { return mStorage.begin(); } - typename decltype(mStorage)::const_iterator end() const - { + typename decltype(mStorage)::const_iterator end() const { return mStorage.end(); } @@ -142,16 +130,14 @@ private: template friend class ItemBase; - void UpdateItemName(const T& item, const std::string& newName) - { + void UpdateItemName(const T& item, const std::string& newName) { mNameLookup.erase(item.GetName()); mNameLookup.insert(newName, item.GetId()); } }; template -class ItemBase -{ +class ItemBase { private: ItemList* mList; size_t mId; @@ -161,39 +147,32 @@ public: ItemBase(ItemList& list, size_t id = std::numeric_limits::max(), std::string name = "") : mList{ &list } , mId{ id } - , mName{ std::move(name) } - { + , mName{ std::move(name) } { } - bool IsInvalid() const - { + bool IsInvalid() const { return mId == std::numeric_limits::max(); } - ItemList& GetList() const - { + ItemList& GetList() const { return *mList; } - size_t GetId() const - { + size_t GetId() const { return mId; } - const std::string& GetName() const - { + const std::string& GetName() const { return mName; } - void SetName(std::string name) - { + void SetName(std::string name) { mList->UpdateItemName(static_cast(*this), name); mName = std::move(name); } }; -class ProductItem : public ItemBase -{ +class ProductItem : public ItemBase { private: std::string mDescription; int mPrice = 0; @@ -216,8 +195,7 @@ public: void Deserialize(const Json::Value& elm); }; -class FactoryItem : public ItemBase -{ +class FactoryItem : public ItemBase { private: std::string mDescription; std::string mEmail; @@ -234,8 +212,7 @@ public: void Deserialize(const Json::Value& elm); }; -class CustomerItem : public ItemBase -{ +class CustomerItem : public ItemBase { private: std::string mDescription; std::string mEmail; diff --git a/app/source/Cplt/Model/Project.cpp b/app/source/Cplt/Model/Project.cpp index a1e9bab..524e508 100644 --- a/app/source/Cplt/Model/Project.cpp +++ b/app/source/Cplt/Model/Project.cpp @@ -14,8 +14,7 @@ namespace fs = std::filesystem; template -static void ReadItemList(ItemList& list, const fs::path& filePath) -{ +static void ReadItemList(ItemList& list, const fs::path& filePath) { std::ifstream ifs(filePath); if (ifs) { Json::Value root; @@ -25,8 +24,7 @@ static void ReadItemList(ItemList& list, const fs::path& filePath) } } -static void CreateProjectSubfolders(const Project& project) -{ +static void CreateProjectSubfolders(const Project& project) { fs::create_directory(project.GetDatabasesDirectory()); fs::create_directory(project.GetItemsDirectory()); fs::create_directory(project.GetWorkflowsDirectory()); @@ -38,8 +36,7 @@ Project::Project(fs::path rootPath) , mRootPathString{ mRootPath.string() } , Workflows(*this) , Templates(*this) - , Database(*this) -{ + , Database(*this) { // TODO better diagnostic const char* kInvalidFormatErr = "Failed to load project: invalid format."; @@ -85,63 +82,51 @@ Project::Project(fs::path rootPath, std::string name) , mName{ std::move(name) } , Workflows(*this) , Templates(*this) - , Database(*this) -{ + , Database(*this) { CreateProjectSubfolders(*this); } -const fs::path& Project::GetPath() const -{ +const fs::path& Project::GetPath() const { return mRootPath; } -const std::string& Project::GetPathString() const -{ +const std::string& Project::GetPathString() const { return mRootPathString; } -fs::path Project::GetDatabasesDirectory() const -{ +fs::path Project::GetDatabasesDirectory() const { return mRootPath / "databases"; } -fs::path Project::GetItemsDirectory() const -{ +fs::path Project::GetItemsDirectory() const { return mRootPath / "items"; } -fs::path Project::GetWorkflowsDirectory() const -{ +fs::path Project::GetWorkflowsDirectory() const { return mRootPath / "workflows"; } -fs::path Project::GetWorkflowPath(std::string_view name) const -{ +fs::path Project::GetWorkflowPath(std::string_view name) const { return (mRootPath / "workflows" / name).concat(".cplt-workflow"); } -fs::path Project::GetTemplatesDirectory() const -{ +fs::path Project::GetTemplatesDirectory() const { return mRootPath / "templates"; } -fs::path Project::GetTemplatePath(std::string_view name) const -{ +fs::path Project::GetTemplatePath(std::string_view name) const { return (mRootPath / "templates" / name).concat(".cplt-template"); } -const std::string& Project::GetName() const -{ +const std::string& Project::GetName() const { return mName; } -void Project::SetName(std::string name) -{ +void Project::SetName(std::string name) { mName = std::move(name); } -Json::Value Project::Serialize() -{ +Json::Value Project::Serialize() { Json::Value root(Json::objectValue); root["Name"] = mName; @@ -150,14 +135,12 @@ Json::Value Project::Serialize() } template -static void WriteItemList(ItemList& list, const fs::path& filePath) -{ +static void WriteItemList(ItemList& list, const fs::path& filePath) { std::ofstream ofs(filePath); ofs << list.Serialize(); } -void Project::WriteToDisk() -{ +void Project::WriteToDisk() { std::ofstream ofs(mRootPath / "cplt_project.json"); ofs << this->Serialize(); diff --git a/app/source/Cplt/Model/Project.hpp b/app/source/Cplt/Model/Project.hpp index 8119a97..c5ca7db 100644 --- a/app/source/Cplt/Model/Project.hpp +++ b/app/source/Cplt/Model/Project.hpp @@ -12,8 +12,7 @@ #include #include -class Project -{ +class Project { private: std::filesystem::path mRootPath; std::string mRootPathString; 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); } diff --git a/app/source/Cplt/Model/Template/TableTemplate.hpp b/app/source/Cplt/Model/Template/TableTemplate.hpp index 3e931d4..e0dea09 100644 --- a/app/source/Cplt/Model/Template/TableTemplate.hpp +++ b/app/source/Cplt/Model/Template/TableTemplate.hpp @@ -11,11 +11,9 @@ #include #include -class TableCell -{ +class TableCell { public: - enum TextAlignment - { + enum TextAlignment { /// For horizontal alignment, this means align left. For vertical alignment, this means align top. AlignAxisMin, /// Align middle of the text to the middle of the axis. @@ -24,8 +22,7 @@ public: AlignAxisMax, }; - enum CellType - { + enum CellType { ConstantCell, SingularParametricCell, ArrayParametricCell, @@ -89,8 +86,7 @@ public: /// \see TableCell /// \see TableInstantiationParameters /// \see TableTemplate -class TableArrayGroup -{ +class TableArrayGroup { public: /// Parameter name mapped to cell location (index from LeftCell). tsl::array_map mName2Cell; @@ -119,8 +115,7 @@ struct lxw_worksheet; /// An object containing the necessary information to instantiate a table template. /// \see TableTemplate -class TableInstantiationParameters -{ +class TableInstantiationParameters { private: const TableTemplate* mTable; @@ -144,8 +139,7 @@ public: /// parametric rows/columns, and grids are also supported. /// /// This current supports exporting to xlsx files. -class TableTemplate : public Template -{ +class TableTemplate : public Template { friend class TableSingleParamsIter; friend class TableArrayGroupsIter; class Private; @@ -201,15 +195,13 @@ public: /// Find an array group by its name. TableArrayGroup* FindArrayGroup(std::string_view name); - enum MergeCellsResult - { + enum MergeCellsResult { MCR_CellAlreadyMerged, MCR_Success, }; MergeCellsResult MergeCells(Vec2i topLeft, Vec2i bottomRight); - enum BreakCellsResult - { + enum BreakCellsResult { BCR_CellNotMerged, BCR_Success, }; diff --git a/app/source/Cplt/Model/Template/TableTemplateIterator.cpp b/app/source/Cplt/Model/Template/TableTemplateIterator.cpp index 19e30b9..3a8e8c2 100644 --- a/app/source/Cplt/Model/Template/TableTemplateIterator.cpp +++ b/app/source/Cplt/Model/Template/TableTemplateIterator.cpp @@ -2,17 +2,14 @@ TableSingleParamsIter::TableSingleParamsIter(TableTemplate& tmpl) : mTemplate{ &tmpl } - , mIter{ tmpl.mName2Parameters.begin() } -{ + , mIter{ tmpl.mName2Parameters.begin() } { } -bool TableSingleParamsIter::HasNext() const -{ +bool TableSingleParamsIter::HasNext() const { return mIter != mTemplate->mName2Parameters.end(); } -TableCell& TableSingleParamsIter::Next() -{ +TableCell& TableSingleParamsIter::Next() { int id = mIter.value(); ++mIter; @@ -21,32 +18,26 @@ TableCell& TableSingleParamsIter::Next() TableArrayGroupsIter::TableArrayGroupsIter(TableTemplate& tmpl) : mTemplate{ &tmpl } - , mIter{ tmpl.mName2ArrayGroups.begin() } -{ + , mIter{ tmpl.mName2ArrayGroups.begin() } { } -bool TableArrayGroupsIter::HasNext() const -{ +bool TableArrayGroupsIter::HasNext() const { return mIter != mTemplate->mName2ArrayGroups.end(); } -TableArrayGroup& TableArrayGroupsIter::Peek() const -{ +TableArrayGroup& TableArrayGroupsIter::Peek() const { int id = mIter.value(); return mTemplate->mArrayGroups[id]; } -std::string_view TableArrayGroupsIter::PeekName() const -{ +std::string_view TableArrayGroupsIter::PeekName() const { return mIter.key_sv(); } -const char* TableArrayGroupsIter::PeekNameCStr() const -{ +const char* TableArrayGroupsIter::PeekNameCStr() const { return mIter.key(); } -void TableArrayGroupsIter::Next() -{ +void TableArrayGroupsIter::Next() { ++mIter; } diff --git a/app/source/Cplt/Model/Template/TableTemplateIterator.hpp b/app/source/Cplt/Model/Template/TableTemplateIterator.hpp index c4b5bf9..d9cb2ad 100644 --- a/app/source/Cplt/Model/Template/TableTemplateIterator.hpp +++ b/app/source/Cplt/Model/Template/TableTemplateIterator.hpp @@ -5,8 +5,7 @@ #include -class TableSingleParamsIter -{ +class TableSingleParamsIter { private: TableTemplate* mTemplate; tsl::array_map::iterator mIter; @@ -18,8 +17,7 @@ public: TableCell& Next(); }; -class TableArrayGroupsIter -{ +class TableArrayGroupsIter { private: TableTemplate* mTemplate; tsl::array_map::iterator mIter; diff --git a/app/source/Cplt/Model/Template/Template.hpp b/app/source/Cplt/Model/Template/Template.hpp index cf926d0..9591eaa 100644 --- a/app/source/Cplt/Model/Template/Template.hpp +++ b/app/source/Cplt/Model/Template/Template.hpp @@ -8,11 +8,9 @@ #include #include -class Template : public Asset -{ +class Template : public Asset { public: - enum Kind - { + enum Kind { KD_Table, InvalidKind, @@ -39,8 +37,7 @@ public: virtual void WriteToDataStream(OutputDataStream& stream) const = 0; }; -class TemplateAssetList final : public AssetListTyped