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

A class to manage user data. More...

#include <storage.hpp>

Public Member Functions

 Storage ()
 Constructor for the Storage class.
 
 ~Storage ()
 Destructor for the Storage class.
 
bool addUser (const std::string &username, const std::string &password)
 Adds a user to the storage.
 
bool removeUser (std::string username)
 Removes a user from the storage.
 
bool isUserExist (std::string username)
 Checks if a user exists in the storage.
 
std::vector< std::tuple< int, std::string, std::string, std::vector< std::string > > > getUsers ()
 Gets a list of all users.
 
bool authenticateUser (const std::string &username, const std::string &password)
 Authenticates a user.
 
bool addTag (std::string username, std::string tag)
 Adds a tag to a user.
 
std::vector< std::string > getTags (std::string username)
 Gets a list of tags for a user.
 
bool removeTag (std::string username, std::string tag)
 delete tag for certain user
 

Static Public Member Functions

static void reset ()
 

Detailed Description

A class to manage user data.

Member Function Documentation

◆ addTag()

bool Storage::addTag ( std::string username,
std::string tag )

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.

◆ addUser()

bool Storage::addUser ( const std::string & username,
const std::string & password )

Adds a user to the storage.

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

◆ authenticateUser()

bool Storage::authenticateUser ( const std::string & username,
const std::string & password )

Authenticates a user.

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

◆ getTags()

std::vector< std::string > Storage::getTags ( std::string username)

Gets a list of tags for a user.

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

◆ getUsers()

std::vector< std::tuple< int, std::string, std::string, std::vector< std::string > > > Storage::getUsers ( )

Gets a list of all users.

Returns
A vector, whose element is the tuple for each user, including their name password and the tag is return as a vector whose element is string

◆ isUserExist()

bool Storage::isUserExist ( std::string username)

Checks if a user exists in the storage.

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

◆ removeTag()

bool Storage::removeTag ( std::string username,
std::string tag )

delete tag for certain user

Parameters
usernameThe name of user
tagthe tag wanna to remove
Returns
the bool value if successfully remove the tag

◆ removeUser()

bool Storage::removeUser ( std::string username)

Removes a user from the storage.

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

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