My Project
Public Member Functions | List of all members
Db Class Reference

#include <db.hpp>

Public Member Functions

 Db (std::string filename)
 
int addUser (std::string username, std::string password)
 
bool authUser (std::string username, std::string password)
 
int updateTaste (std::string username, bool vote)
 
int getTaste (std::string uname)
 
void closeDatabase (void)
 

Detailed Description

Db class is for all sqlite3 database interactions

Member Function Documentation

◆ addUser()

int Db::addUser ( std::string  username,
std::string  password 
)

Attempts to add a username with the given password to the database.

Parameters
usernameusername of the new user
passwordthe password of the new user
Returns
the return code of the SQL query.

◆ authUser()

bool Db::authUser ( std::string  username,
std::string  password 
)

Authenticates a user based on their username and password

Parameters
usernameof the user to authernticate
passwordpassword of the given user
Returns
true if the user is authenticated, false otherwise

◆ closeDatabase()

void Db::closeDatabase ( void  )

Closes the sqlite3 database object

◆ getTaste()

int Db::getTaste ( std::string  uname)

Gets the taste of a given user from the database

Parameters
unameusername of the user
Returns
taste of the user

◆ updateTaste()

int Db::updateTaste ( std::string  username,
bool  vote 
)

Updates the taste for the given user depending on a given vote

Parameters
username- username of taste to update
vote- true for an upvote, false for a downvote
Returns
int - the return code of the database query

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