From 86924339a3a50056252a863456a816ecaa1f9620 Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 14 Jul 2008 08:13:06 +0000 Subject: [PATCH] Add some 'const' attributes to various functions No real changes in here, only way more constness... git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1129 726aef4b-f618-498e-8847-2d620e286838 --- Buffer.cpp | 4 ++-- Buffer.h | 6 +++--- Chan.cpp | 4 ++-- Chan.h | 4 ++-- User.cpp | 10 +++++----- User.h | 14 +++++++------- znc.cpp | 6 +++--- znc.h | 6 +++--- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Buffer.cpp b/Buffer.cpp index c2259e37..73e2b442 100644 --- a/Buffer.cpp +++ b/Buffer.cpp @@ -16,7 +16,7 @@ CBufLine::CBufLine(const CString& sPre, const CString& sPost, bool bIncNick=true CBufLine::~CBufLine() {} -void CBufLine::GetLine(const CString& sTarget, CString& sRet) { +void CBufLine::GetLine(const CString& sTarget, CString& sRet) const { if (m_bIncNick) sRet = m_sPre + sTarget + m_sPost; else @@ -54,7 +54,7 @@ int CBuffer::UpdateLine(const CString& sPre, const CString& sPost, bool bIncNick return AddLine(sPre, sPost, bIncNick); } -bool CBuffer::GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) { +bool CBuffer::GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) const { if (uIdx >= size()) { return false; } diff --git a/Buffer.h b/Buffer.h index 17304d04..a48327d0 100644 --- a/Buffer.h +++ b/Buffer.h @@ -18,7 +18,7 @@ class CBufLine { public: CBufLine(const CString& sPre, const CString& sPost, bool bIncNick); virtual ~CBufLine(); - void GetLine(const CString& sTarget, CString& sRet); + void GetLine(const CString& sTarget, CString& sRet) const; const CString& GetPre() const { return m_sPre; } const CString& GetPost() const { return m_sPost; } @@ -44,8 +44,8 @@ public: /// Same as AddLine, but if there is already a line with sPre it is replaced. int UpdateLine(const CString& sPre, const CString& sPost, bool bIncNick = true); bool GetNextLine(const CString& sTarget, CString& sRet); - bool GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx); - bool IsEmpty() { return empty(); } + bool GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) const; + bool IsEmpty() const { return empty(); } void Clear() { clear(); } // Setters diff --git a/Chan.cpp b/Chan.cpp index 3063b0b4..6fa94096 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -486,8 +486,8 @@ bool CChan::AddNick(const CString& sNick) { return true; } -unsigned int CChan::GetPermCount(unsigned char uPerm) { - map::iterator it = m_muuPermCount.find(uPerm); +unsigned int CChan::GetPermCount(unsigned char uPerm) const { + map::const_iterator it = m_muuPermCount.find(uPerm); return (it == m_muuPermCount.end()) ? 0 : it->second; } diff --git a/Chan.h b/Chan.h index 1b509383..693afca2 100644 --- a/Chan.h +++ b/Chan.h @@ -127,7 +127,7 @@ public: bool HasMode(unsigned char uMode) const; CString GetOptions() const; CString GetModeArg(unsigned char uMode) const; - unsigned int GetPermCount(unsigned char uPerm); + unsigned int GetPermCount(unsigned char uPerm) const; bool IsOn() const { return m_bIsOn; } const CString& GetName() const { return m_sName; } const map& GetModes() const { return m_musModes; } @@ -148,7 +148,7 @@ public: bool InConfig() const { return m_bInConfig; } unsigned long GetCreationDate() const { return m_ulCreationDate; } bool IsDisabled() const { return m_bDisabled; } - unsigned int GetJoinTries() { return m_uJoinTries; } + unsigned int GetJoinTries() const { return m_uJoinTries; } // !Getters private: protected: diff --git a/User.cpp b/User.cpp index a98f5e71..e9979585 100644 --- a/User.cpp +++ b/User.cpp @@ -455,7 +455,7 @@ bool CUser::AddAllowedHost(const CString& sHostMask) { return true; } -bool CUser::IsHostAllowed(const CString& sHostMask) { +bool CUser::IsHostAllowed(const CString& sHostMask) const { if (m_ssAllowedHosts.empty()) { return true; } @@ -684,7 +684,7 @@ void CUser::JoinChans() { } } -CServer* CUser::FindServer(const CString& sName) { +CServer* CUser::FindServer(const CString& sName) const { for (unsigned int a = 0; a < m_vServers.size(); a++) { CServer* pServer = m_vServers[a]; if (sName.CaseCmp(pServer->GetName()) == 0) { @@ -785,7 +785,7 @@ bool CUser::AddServer(const CString& sName, unsigned short uPort, const CString& return true; } -bool CUser::IsLastServer() { +bool CUser::IsLastServer() const { return (m_uServerIdx >= m_vServers.size()); } @@ -801,7 +801,7 @@ CServer* CUser::GetNextServer() { return m_vServers[m_uServerIdx++]; // Todo: cycle through these } -CServer* CUser::GetCurrentServer() { +CServer* CUser::GetCurrentServer() const { unsigned int uIdx = (m_uServerIdx) ? m_uServerIdx -1 : 0; if (uIdx >= m_vServers.size()) { @@ -811,7 +811,7 @@ CServer* CUser::GetCurrentServer() { return m_vServers[uIdx]; } -bool CUser::CheckPass(const CString& sPass) { +bool CUser::CheckPass(const CString& sPass) const { if (!m_bPassHashed) { return (sPass == m_sPass); } diff --git a/User.h b/User.h index 4b7e30f4..12cea93d 100644 --- a/User.h +++ b/User.h @@ -42,19 +42,19 @@ public: bool AddChan(const CString& sName, bool bInConfig); bool DelChan(const CString& sName); void JoinChans(); - CServer* FindServer(const CString& sName); + CServer* FindServer(const CString& sName) const; bool DelServer(const CString& sName); bool AddServer(const CString& sName, bool bIPV6 = false); bool AddServer(const CString& sName, unsigned short uPort, const CString& sPass = "", bool bSSL = false, bool bIPV6 = false); CServer* GetNextServer(); - CServer* GetCurrentServer(); - bool CheckPass(const CString& sPass); + CServer* GetCurrentServer() const; + bool CheckPass(const CString& sPass) const; bool AddAllowedHost(const CString& sHostMask); - bool IsHostAllowed(const CString& sHostMask); + bool IsHostAllowed(const CString& sHostMask) const; bool IsValid(CString& sErrMsg, bool bSkipPass = false) const; static bool IsValidUserName(const CString& sUserName); static CString MakeCleanUserName(const CString& sUserName); - bool IsLastServer(); + bool IsLastServer() const; bool ConnectPaused(); void DelClients(); @@ -86,12 +86,12 @@ public: bool PutStatusNotice(const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL); bool PutModule(const CString& sModule, const CString& sLine, CClient* pClient = NULL, CClient* pSkipClient = NULL); - bool IsUserAttached() { return (m_vClients.size() > 0); } + bool IsUserAttached() const { return (m_vClients.size() > 0); } void UserConnected(CClient* pClient); void UserDisconnected(CClient* pClient); CString GetLocalIP(); - bool IsIRCConnected() { return m_bIRCConnected; } + bool IsIRCConnected() const { return m_bIRCConnected; } void IRCConnected(CIRCSock* pIRCSock); void IRCDisconnected(); void CheckIRCConnect(); diff --git a/znc.cpp b/znc.cpp index d5d52d39..43641b34 100644 --- a/znc.cpp +++ b/znc.cpp @@ -94,7 +94,7 @@ CString CZNC::GetTag(bool bIncludeVersion) { return szBuf; } -CString CZNC::GetUptime() { +CString CZNC::GetUptime() const { time_t now = time(NULL); return CString::ToTimeStr(now - TimeStarted()); } @@ -390,8 +390,8 @@ Csock* CZNC::FindSockByName(const CString& sSockName) { return m_Manager.FindSockByName(sSockName); } -bool CZNC::IsHostAllowed(const CString& sHostMask) { - for (map::iterator a = m_msUsers.begin(); a != m_msUsers.end(); a++) { +bool CZNC::IsHostAllowed(const CString& sHostMask) const { + for (map::const_iterator a = m_msUsers.begin(); a != m_msUsers.end(); a++) { if (a->second->IsHostAllowed(sHostMask)) { return true; } diff --git a/znc.h b/znc.h index 26474a7a..d353f49a 100644 --- a/znc.h +++ b/znc.h @@ -100,7 +100,7 @@ public: bool DeletePidFile(); CUser* GetUser(const CString& sUser); Csock* FindSockByName(const CString& sSockName); - bool IsHostAllowed(const CString& sHostMask); + bool IsHostAllowed(const CString& sHostMask) const; void InitDirs(const CString& sArgvPath, const CString& sDataDir); bool OnBoot(); CString ExpandConfigPath(const CString& sConfigFile); @@ -110,7 +110,7 @@ public: bool RehashConfig(CString& sError); static CString GetVersion(); static CString GetTag(bool bIncludeVersion = true); - CString GetUptime(); + CString GetUptime() const; // This returns the path to the .so and to the data dir // which is where static data (webadmin skins) are saved bool FindModPath(const CString& sModule, CString& sModPath, @@ -139,7 +139,7 @@ public: // !Setters // Getters - bool GetNeedRehash() { return m_bNeedRehash; } + bool GetNeedRehash() const { return m_bNeedRehash; } CSockManager& GetManager() { return m_Manager; } #ifdef _MODULES CGlobalModules& GetModules() { return *m_pModules; }