Files
ft_irc/User/User.cpp
2026-05-08 16:37:51 +02:00

76 lines
3.0 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* User.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/05/07 10:22:52 by aortigos #+# #+# */
/* Updated: 2026/05/07 10:22:52 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "User.hpp"
//////////////////
// Constructors //
//////////////////
User::User() : fd(-1), nick(""), username(""), realname(""), buffer(""), authenticated(false), registered(false)
{
// std::cout << "User default constructor called" << std::endl;
}
User::User(int fd) : fd(fd), nick(""), username(""), realname(""), buffer(""), authenticated(false), registered(false)
{
// std::cout << "User with fd constructor called" << std::endl;
}
User::User(const User &other)
{
*this = other;
// std::cout << "User copy constructor called" << std::endl;
}
User& User::operator=(const User &other)
{
if (this != &other)
{
fd = other.fd;
nick = other.nick;
username = other.username;
realname = other.realname;
buffer = other.buffer;
authenticated = other.authenticated;
registered = other.registered;
}
// std::cout << "User copy assignment operator called" << std::endl;
return (*this);
}
User::~User()
{
// std::cout << "User destructor called" << std::endl;
}
// Getters
int User::getFd() const { return (this->fd); };
std::string User::getNick() const { return (this->nick); };
std::string User::getUsername() const { return (this->username); };
std::string User::getRealname() const { return (this->realname); };
std::string &User::getBuffer() { return (this->buffer); };
bool User::isAuthenticated() const { return (this->authenticated); };
bool User::isRegistered() const { return (this->registered); };
// Setters
void User::setNick(std::string nick) { this->nick = nick; }
void User::setUsername(std::string username) { this->username = username; }
void User::setRealname(std::string realname) { this->realname = realname; }
void User::appendBuffer(std::string buff) { this->buffer = buff; }
void User::clearBuffer() { this->buffer.clear(); }
void User::setAuthenticated(bool value) { this->authenticated = value; }
void User::setRegistered(bool value) { this->registered = value; }