pairpal
Loading...
Searching...
No Matches
Client Class Reference

A class to manage the API gateway operations. More...

#include <client.hpp>

Public Member Functions

 Client (std::string serverAddr)
 Constructor for the Client class.
 
 Client (const Client &other)
 Copy constructor for the Client class.
 
 Client (Client &&other) noexcept
 Move constructor for the Client class.
 
auto operator= (const Client &other) -> Client &
 Copy assignment operator for the Client class.
 
auto operator= (Client &&other) noexcept -> Client &
 Move assignment operator for the Client class.
 
 ~Client ()
 Destructor for the Client class.
 
auto start () noexcept -> bool
 Starts the client.
 
auto stop () noexcept -> bool
 Stops the client.
 
auto restart () noexcept -> bool
 Restarts the client.
 
auto addUser (const std::string &username, const std::string &password) noexcept -> bool
 Adds a user to the system.
 
auto removeUser (const std::string &username) noexcept -> bool
 Removes a user from the system.
 
auto isExistUser (const std::string &username) noexcept -> bool
 Checks if a user exists in the system.
 
auto listAllUsers () -> std::vector< std::string >
 Gets a list of all users.
 
auto authenticateUser (const std::string &username, const std::string &password) noexcept -> bool
 Authenticates a user.
 
auto addUserTag (const std::string &username, const std::string &tag) noexcept -> bool
 Adds a tag to a user.
 
auto removeUserTag (const std::string &username, const std::string &tag) noexcept -> bool
 Removes a tag from a user.
 
auto getUserTags (const std::string &username) -> std::vector< std::string >
 Gets the tags of a user.
 
auto sendMessage (const std::string &from, const std::string &to, const std::string &message) noexcept -> bool
 Sends a message from one user to another.
 
auto getSentMessages (const std::string &username) -> std::vector< std::string >
 Gets the messages sent by a user.
 
auto getReceivedMessages (const std::string &username) -> std::vector< std::string >
 Gets the messages received by a user.
 
auto getPair (const std::string &username) -> std::vector< std::string >
 Gets the pair of a user.
 

Detailed Description

A class to manage the API gateway operations.

Constructor & Destructor Documentation

◆ Client() [1/3]

Client::Client ( std::string serverAddr)
explicit

Constructor for the Client class.

Parameters
serverAddrThe address of the server to connect to.

◆ Client() [2/3]

Client::Client ( const Client & other)

Copy constructor for the Client class.

Parameters
otherThe other Client object to copy from.

◆ Client() [3/3]

Client::Client ( Client && other)
noexcept

Move constructor for the Client class.

Parameters
otherThe other Client object to move from.

Member Function Documentation

◆ addUser()

auto Client::addUser ( const std::string & username,
const std::string & password ) -> bool
noexcept

Adds a user to the system.

Parameters
usernameThe username of the user.
passwordThe password of the user.
Returns
True if the user was added successfully, false otherwise.

◆ addUserTag()

auto Client::addUserTag ( const std::string & username,
const std::string & tag ) -> bool
noexcept

Adds a tag to a user.

Parameters
usernameThe username of the user.
tagThe tag to add.
Returns
True if the tag was added successfully, false otherwise.

◆ authenticateUser()

auto Client::authenticateUser ( const std::string & username,
const std::string & password ) -> bool
noexcept

Authenticates a user.

Parameters
usernameThe username of the user.
passwordThe password of the user.
Returns
True if the authentication was successful, false otherwise.

◆ getPair()

auto Client::getPair ( const std::string & username) -> std::vector< std::string >
nodiscard

Gets the pair of a user.

Parameters
usernameThe username of the user.
Returns
A vector containing the pair of the user.

◆ getReceivedMessages()

auto Client::getReceivedMessages ( const std::string & username) -> std::vector< std::string >
nodiscard

Gets the messages received by a user.

Parameters
usernameThe username of the user.
Returns
A vector of received messages.

◆ getSentMessages()

auto Client::getSentMessages ( const std::string & username) -> std::vector< std::string >
nodiscard

Gets the messages sent by a user.

Parameters
usernameThe username of the user.
Returns
A vector of sent messages.

◆ getUserTags()

auto Client::getUserTags ( const std::string & username) -> std::vector< std::string >
nodiscard

Gets the tags of a user.

Parameters
usernameThe username of the user.
Returns
A vector of tags.

◆ isExistUser()

auto Client::isExistUser ( const std::string & username) -> bool
noexcept

Checks if a user exists in the system.

Parameters
usernameThe username to check.
Returns
True if the user exists, false otherwise.

◆ listAllUsers()

auto Client::listAllUsers ( ) -> std::vector< std::string >
nodiscard

Gets a list of all users.

Returns
A vector of usernames.

◆ operator=() [1/2]

auto Client::operator= ( Client && other) -> Client &
noexcept

Move assignment operator for the Client class.

Parameters
otherThe other Client object to move from.
Returns
A reference to the assigned Client object.

◆ operator=() [2/2]

auto Client::operator= ( const Client & other) -> Client &

Copy assignment operator for the Client class.

Parameters
otherThe other Client object to copy from.
Returns
A reference to the assigned Client object.

◆ removeUser()

auto Client::removeUser ( const std::string & username) -> bool
noexcept

Removes a user from the system.

Parameters
usernameThe username of the user to remove.
Returns
True if the user was removed successfully, false otherwise.

◆ removeUserTag()

auto Client::removeUserTag ( const std::string & username,
const std::string & tag ) -> bool
noexcept

Removes a tag from a user.

Parameters
usernameThe username of the user.
tagThe tag to remove.
Returns
True if the tag was removed successfully, false otherwise.

◆ restart()

auto Client::restart ( ) -> bool
noexcept

Restarts the client.

Returns
True if the client restarted successfully, false otherwise.

◆ sendMessage()

auto Client::sendMessage ( const std::string & from,
const std::string & to,
const std::string & message ) -> bool
noexcept

Sends a message from one user to another.

Parameters
fromThe username of the sender.
toThe username of the receiver.
messageThe message to send.
Returns
True if the message was sent successfully, false otherwise.

◆ start()

auto Client::start ( ) -> bool
noexcept

Starts the client.

Returns
True if the client started successfully, false otherwise.

◆ stop()

auto Client::stop ( ) -> bool
noexcept

Stops the client.

Returns
True if the client stopped successfully, false otherwise.

The documentation for this class was generated from the following file: