From ceaa3ba6e4fef983d4d8ac61cafb61f8b80a5ef5 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquemin Date: Fri, 23 Aug 2024 17:10:00 +0200 Subject: [PATCH] Add [[nodiscard]] specifiers as recommended by CLion. --- src/BinaryIo/Writer.h | 2 ++ src/Configuration/Configuration.h | 9 +++++++++ src/GameObjects/Mass.h | 1 + src/Gvas/File.h | 2 ++ src/Managers/BackupManager.h | 2 ++ src/Managers/ProfileManager.h | 1 + src/Managers/StagedMassManager.h | 3 +++ src/Managers/Vfs/Directory.h | 1 + src/UpdateChecker/UpdateChecker.h | 4 ++++ 9 files changed, 25 insertions(+) diff --git a/src/BinaryIo/Writer.h b/src/BinaryIo/Writer.h index 763622e..5d2b9f7 100644 --- a/src/BinaryIo/Writer.h +++ b/src/BinaryIo/Writer.h @@ -45,7 +45,9 @@ class Writer { auto position() -> std::int64_t; + [[nodiscard]] auto array() const -> Containers::ArrayView; + [[nodiscard]] auto arrayPosition() const -> std::size_t; bool flushToFile(); diff --git a/src/Configuration/Configuration.h b/src/Configuration/Configuration.h index 79ec469..37161dd 100644 --- a/src/Configuration/Configuration.h +++ b/src/Configuration/Configuration.h @@ -28,30 +28,39 @@ class Configuration { ~Configuration(); + [[nodiscard]] bool valid() const; + [[nodiscard]] auto lastError() const -> Containers::StringView; void save(); + [[nodiscard]] auto swapInterval() const -> int; void setSwapInterval(int interval); + [[nodiscard]] auto fpsCap() const -> float; void setFpsCap(float cap); + [[nodiscard]] bool cheatMode() const; void setCheatMode(bool enabled); + [[nodiscard]] bool advancedMode() const; void setAdvancedMode(bool enabled); + [[nodiscard]] bool checkUpdatesOnStartup() const; void setCheckUpdatesOnStartup(bool mode); + [[nodiscard]] bool skipDisclaimer() const; void setSkipDisclaimer(bool mode); + [[nodiscard]] bool isRunningInWine() const; void setRunningInWine(bool wine); diff --git a/src/GameObjects/Mass.h b/src/GameObjects/Mass.h index 6a4390b..c876b5b 100644 --- a/src/GameObjects/Mass.h +++ b/src/GameObjects/Mass.h @@ -70,6 +70,7 @@ class Mass { auto state() -> State; + [[nodiscard]] bool dirty() const; void setDirty(bool dirty = true); diff --git a/src/Gvas/File.h b/src/Gvas/File.h index 0dce428..05fc255 100644 --- a/src/Gvas/File.h +++ b/src/Gvas/File.h @@ -34,7 +34,9 @@ class File { public: explicit File(Containers::String filepath); + [[nodiscard]] bool valid() const; + [[nodiscard]] auto lastError() const -> Containers::StringView; bool reloadData(); diff --git a/src/Managers/BackupManager.h b/src/Managers/BackupManager.h index 292ee26..c87cb83 100644 --- a/src/Managers/BackupManager.h +++ b/src/Managers/BackupManager.h @@ -39,8 +39,10 @@ class BackupManager { void refresh(); + [[nodiscard]] auto backups() const -> Containers::ArrayView; + [[nodiscard]] auto vfs() const -> const Vfs::Directory&; bool create(const GameObjects::Profile& profile); diff --git a/src/Managers/ProfileManager.h b/src/Managers/ProfileManager.h index 8418ddf..e1ec0cd 100644 --- a/src/Managers/ProfileManager.h +++ b/src/Managers/ProfileManager.h @@ -29,6 +29,7 @@ class ProfileManager { public: explicit ProfileManager(); + [[nodiscard]] auto ready() const -> bool; auto lastError() -> Containers::StringView; diff --git a/src/Managers/StagedMassManager.h b/src/Managers/StagedMassManager.h index 87b1630..66ae85a 100644 --- a/src/Managers/StagedMassManager.h +++ b/src/Managers/StagedMassManager.h @@ -33,7 +33,10 @@ class StagedMassManager { auto lastError() -> Containers::StringView; + [[nodiscard]] auto stagedMasses() const -> Containers::ArrayView; + + [[nodiscard]] auto at(Containers::StringView filename) const -> const StagedMass&; void refresh(); diff --git a/src/Managers/Vfs/Directory.h b/src/Managers/Vfs/Directory.h index afc8fd7..d85912a 100644 --- a/src/Managers/Vfs/Directory.h +++ b/src/Managers/Vfs/Directory.h @@ -44,6 +44,7 @@ class Directory { Directory(Directory&& other) = default; Directory& operator=(Directory&& other) = default; + [[nodiscard]] auto name() const -> Containers::StringView { return _name; } diff --git a/src/UpdateChecker/UpdateChecker.h b/src/UpdateChecker/UpdateChecker.h index 5da13dc..f67a302 100644 --- a/src/UpdateChecker/UpdateChecker.h +++ b/src/UpdateChecker/UpdateChecker.h @@ -35,12 +35,16 @@ class UpdateChecker { auto check() -> Result; + [[nodiscard]] auto error() const -> Containers::StringView; + [[nodiscard]] bool updateAvailable() const; + [[nodiscard]] auto version() const -> const Version&; + [[nodiscard]] auto downloadLink() const -> Containers::StringView; private: