Added comparison operator overloads for IRCPrefix

master
Tomatix 5 years ago
parent c77dd1cb4f
commit 89f2b86be7
  1. 20
      IRCClient/IRCPrefix.cpp
  2. 7
      IRCClient/IRCPrefix.h

@ -109,3 +109,23 @@ IRCPrefix IRCPrefix::fromNickname(const std::string& nickname)
p.m_nickname = nickname;
return p;
}
bool IRCPrefix::operator!=(const IRCPrefix& other)
{
return other.type() != m_type || other.toString() != toString();
}
bool IRCPrefix::operator==(const IRCPrefix& other)
{
return other.type() == m_type && other.toString() == toString();
}
bool operator!=(const IRCPrefix& lhs, const IRCPrefix& rhs)
{
return lhs.type() != rhs.type() || lhs.toString() != rhs.toString();
}
bool operator==(const IRCPrefix& lhs, const IRCPrefix& rhs)
{
return lhs.type() == rhs.type() && lhs.toString() == rhs.toString();
}

@ -14,6 +14,9 @@ public:
IRCPrefix& operator=(const IRCPrefix& other);
bool operator!=(const IRCPrefix& other);
bool operator==(const IRCPrefix& other);
[[nodiscard]] const std::string& toString() const; //!< Returns either a servername or nickname.
[[nodiscard]] const std::string& servername() const;
@ -49,4 +52,8 @@ private:
Type m_type;
};
bool operator!=(const IRCPrefix& lhs, const IRCPrefix& rhs);
bool operator==(const IRCPrefix& lhs, const IRCPrefix& rhs);
#endif // IRCPREFIX_H

Loading…
Cancel
Save