83 lines
2.7 KiB
C++
83 lines
2.7 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),
|
|
authenticated(false),
|
|
registered(false)
|
|
{
|
|
// std::cout << "User default constructor called" << std::endl;
|
|
}
|
|
|
|
User::User(int fd) :
|
|
fd(fd),
|
|
authenticated(false),
|
|
registered(false)
|
|
{
|
|
// std::cout << "User default 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::appendBuffer(std::string buff) { this->buffer.append(buff); }
|
|
void User::clearBuffer() { this->buffer.clear(); }
|
|
|
|
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::setAuthenticated(bool value) { this->authenticated = value; }
|
|
void User::setRegistered(bool value) { this->registered = value; } |