The complete source code of IdealIRC
http://www.idealirc.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.3 KiB
59 lines
1.3 KiB
#ifndef IRCPREFIX_H
|
|
#define IRCPREFIX_H
|
|
|
|
#include <string>
|
|
|
|
class IRCPrefix
|
|
{
|
|
public:
|
|
explicit IRCPrefix(const std::string& prefix);
|
|
IRCPrefix(const IRCPrefix& other);
|
|
IRCPrefix(IRCPrefix&& other) noexcept;
|
|
IRCPrefix() = delete;
|
|
~IRCPrefix() = default;
|
|
|
|
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;
|
|
[[nodiscard]] const std::string& nickname() const;
|
|
[[nodiscard]] const std::string& user() const;
|
|
[[nodiscard]] const std::string& host() const;
|
|
|
|
void setNickname(const std::string& nickname);
|
|
void setHost(const std::string& host);
|
|
|
|
[[nodiscard]] std::string composite() const;
|
|
|
|
enum class Type
|
|
{
|
|
server,
|
|
user
|
|
};
|
|
|
|
[[nodiscard]] Type type() const;
|
|
|
|
[[nodiscard]] static IRCPrefix fromNickname(const std::string& nickname);
|
|
|
|
private:
|
|
explicit IRCPrefix(Type t);
|
|
|
|
// Used for :irc.server.name prefix
|
|
std::string m_servername;
|
|
|
|
/* Used for :nickname!user@host prefix */
|
|
std::string m_nickname;
|
|
std::string m_user;
|
|
std::string m_host;
|
|
|
|
Type m_type;
|
|
};
|
|
|
|
bool operator!=(const IRCPrefix& lhs, const IRCPrefix& rhs);
|
|
bool operator==(const IRCPrefix& lhs, const IRCPrefix& rhs);
|
|
|
|
#endif // IRCPREFIX_H
|
|
|