From 859088dac5b937208c7aff7fd3976bbc63329281 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 22 Oct 2022 20:45:22 +0100 Subject: More const correctness. --- include/channels.h | 11 ++++++----- include/modules.h | 4 ++-- include/modules/sql.h | 2 +- include/users.h | 10 +++++----- 4 files changed, 14 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/channels.h b/include/channels.h index 9b88b7d15..cbc6ce911 100644 --- a/include/channels.h +++ b/include/channels.h @@ -115,15 +115,16 @@ public: * @param mode The mode character to set or unset * @param value True if you want to set the mode or false if you want to remove it */ - void SetMode(ModeHandler* mode, bool value); + void SetMode(const ModeHandler* mode, bool value); + void SetMode(const ModeHandler& mh, bool value) { SetMode(&mh, value); } /** Returns true if a mode is set on a channel * @param mode The mode character you wish to query * @return True if the custom mode is set, false if otherwise */ - bool IsModeSet(ModeHandler* mode) { return ((mode->GetId() != ModeParser::MODEID_MAX) && (modes[mode->GetId()])); } - bool IsModeSet(ModeHandler& mode) { return IsModeSet(&mode); } - bool IsModeSet(ChanModeReference& mode); + bool IsModeSet(const ModeHandler* mode) { return ((mode->GetId() != ModeParser::MODEID_MAX) && (modes[mode->GetId()])); } + bool IsModeSet(const ModeHandler& mode) { return IsModeSet(&mode); } + bool IsModeSet(const ChanModeReference& mode); /** Returns the parameter for a custom mode on a channel. * @param mode The mode character you wish to query @@ -310,7 +311,7 @@ inline std::string Channel::GetModeParameter(ParamModeBase* pm) return out; } -inline bool Channel::IsModeSet(ChanModeReference& mode) +inline bool Channel::IsModeSet(const ChanModeReference& mode) { if (!mode) return false; diff --git a/include/modules.h b/include/modules.h index f9034578d..dfb3a70e5 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1059,7 +1059,7 @@ public: * @param mod Module to attach events to * @param sz The size of the implementation array */ - void Attach(Implementation* i, Module* mod, size_t sz); + void Attach(const Implementation* i, Module* mod, size_t sz); /** Attach all events to a module (used on module load) * @param mod Module to attach to all events @@ -1082,7 +1082,7 @@ public: * @param mod Module to detach events from * @param sz The size of the implementation array */ - void Detach(Implementation* i, Module* mod, size_t sz); + void Detach(const Implementation* i, Module* mod, size_t sz); /** Detach all events from a module (used on unload) * @param mod Module to detach from diff --git a/include/modules/sql.h b/include/modules/sql.h index 2985d1009..2f7557fdd 100644 --- a/include/modules/sql.h +++ b/include/modules/sql.h @@ -183,7 +183,7 @@ public: /** Called when an SQL error happens. * @param error The error that occurred. */ - virtual void OnError(SQL::Error& error) = 0; + virtual void OnError(const SQL::Error& error) = 0; /** Called when a SQL result is received. * @param result The result of the SQL query. diff --git a/include/users.h b/include/users.h index f2c9f979a..08265f83f 100644 --- a/include/users.h +++ b/include/users.h @@ -403,14 +403,14 @@ public: bool IsModeSet(unsigned char m) const; bool IsModeSet(const ModeHandler* mh) const; bool IsModeSet(const ModeHandler& mh) const { return IsModeSet(&mh); } - bool IsModeSet(UserModeReference& moderef) const; + bool IsModeSet(const UserModeReference& moderef) const; /** Set a specific usermode to on or off * @param mh The user mode * @param value On or off setting of the mode */ - void SetMode(ModeHandler* mh, bool value); - void SetMode(ModeHandler& mh, bool value) { SetMode(&mh, value); } + void SetMode(const ModeHandler* mh, bool value); + void SetMode(const ModeHandler& mh, bool value) { SetMode(&mh, value); } /** Returns true or false for if a user can execute a privileged oper command. * This is done by looking up their oper type from User::oper, then referencing @@ -805,14 +805,14 @@ inline bool User::IsModeSet(const ModeHandler* mh) const return ((mh->GetId() != ModeParser::MODEID_MAX) && (modes[mh->GetId()])); } -inline bool User::IsModeSet(UserModeReference& moderef) const +inline bool User::IsModeSet(const UserModeReference& moderef) const { if (!moderef) return false; return IsModeSet(*moderef); } -inline void User::SetMode(ModeHandler* mh, bool value) +inline void User::SetMode(const ModeHandler* mh, bool value) { if (mh && mh->GetId() != ModeParser::MODEID_MAX) modes[mh->GetId()] = value; -- cgit v1.3.1-10-gc9f91