Code cleanup
This commit is contained in:
@@ -9,10 +9,8 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/AlbumFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class AlbumRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class AlbumRepository : public BaseRepository {
|
||||
public:
|
||||
AlbumRepository(const model::BinaryPath&);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef ARTISTREPOSITORY_H_
|
||||
#define ARTISTREPOSITORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -8,16 +9,15 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/ArtistFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class ArtistRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class ArtistRepository : public BaseRepository {
|
||||
public:
|
||||
ArtistRepository(const model::BinaryPath&);
|
||||
|
||||
std::vector<model::Artist> retrieveRecords();
|
||||
|
||||
std::pair<model::Artist, int> retrieveRecordWithSongCount(model::Artist&, type::ArtistFilter);
|
||||
std::pair<model::Artist, int> retrieveRecordWithSongCount(
|
||||
model::Artist&, type::ArtistFilter);
|
||||
|
||||
model::Artist retrieveRecord(model::Artist&, type::ArtistFilter);
|
||||
|
||||
@@ -30,9 +30,13 @@ namespace database
|
||||
|
||||
std::pair<model::Artist, int> parseRecordWithSongCount(MYSQL_STMT*);
|
||||
|
||||
// TODO: After parseRecord(MYSQL_STMT*) is implemented
|
||||
// remove parseRecord(MYSQL_RES*)
|
||||
model::Artist parseRecord(MYSQL_RES*);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::Artist&,
|
||||
std::tuple<char*>&);
|
||||
std::shared_ptr<MYSQL_BIND> valueBindWithSongCount(model::Artist&,
|
||||
std::tuple<char*>&, int&);
|
||||
|
||||
std::tuple<char*> metadataBuffer();
|
||||
|
||||
model::Artist parseRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,12 +7,10 @@
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class BaseRepository {
|
||||
public:
|
||||
BaseRepository();
|
||||
BaseRepository() = default;
|
||||
BaseRepository(const std::string&);
|
||||
BaseRepository(const model::BinaryPath&);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef COVERARTREPOSITORY_H_
|
||||
#define COVERARTREPOSITORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <mysql/mysql.h>
|
||||
@@ -9,12 +10,9 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/CoverFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class CoverArtRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class CoverArtRepository : public BaseRepository {
|
||||
public:
|
||||
CoverArtRepository(const std::string&);
|
||||
CoverArtRepository(const model::BinaryPath&);
|
||||
|
||||
std::vector<model::Cover> retrieveRecords();
|
||||
@@ -23,15 +21,17 @@ namespace database
|
||||
|
||||
bool doesCoverArtExist(const model::Cover&, type::CoverFilter);
|
||||
|
||||
void deleteRecord(const model::Cover&);
|
||||
void deleteRecord(const model::Cover&, type::CoverFilter = type::CoverFilter::id);
|
||||
void saveRecord(const model::Cover&);
|
||||
void updateRecord(const model::Cover&);
|
||||
private:
|
||||
std::vector<model::Cover> parseRecords(MYSQL_STMT*);
|
||||
|
||||
// TODO: After parseRecord(MYSQL_STMT*) is implemented
|
||||
// remove parseRecord(MYSQL_RES*)
|
||||
model::Cover parseRecord(MYSQL_RES*);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::Cover&,
|
||||
std::tuple<char*, char*>&);
|
||||
|
||||
std::tuple<char*, char*> metadataBuffer();
|
||||
|
||||
model::Cover parseRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef GENREREPOSITORY_H_
|
||||
#define GENREREPOSITORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -8,10 +9,8 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/GenreFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class GenreRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class GenreRepository : public BaseRepository {
|
||||
public:
|
||||
GenreRepository(const model::BinaryPath&);
|
||||
|
||||
@@ -30,9 +29,13 @@ namespace database
|
||||
|
||||
std::pair<model::Genre, int> parseRecordWithSongCount(MYSQL_STMT*);
|
||||
|
||||
// TODO: After parseRecord(MYSQL_STMT*) is implemented
|
||||
// remove parseRecord(MYSQL_RES*)
|
||||
model::Genre parseRecord(MYSQL_RES*);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::Genre&,
|
||||
std::tuple<char*>&);
|
||||
std::shared_ptr<MYSQL_BIND> valueBindWithSongCount(model::Genre&,
|
||||
std::tuple<char*>&, int&);
|
||||
|
||||
std::tuple<char*> metadataBuffer();
|
||||
|
||||
model::Genre parseRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,18 +11,16 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/SongFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class SongRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class SongRepository : public BaseRepository {
|
||||
public:
|
||||
SongRepository(const model::BinaryPath&);
|
||||
|
||||
std::vector<model::Song> retrieveRecords();
|
||||
|
||||
model::Song retrieveRecord(const model::Song&, type::SongFilter);
|
||||
model::Song retrieveRecord(const model::Song&, type::SongFilter = type::SongFilter::id);
|
||||
|
||||
bool doesSongExist(const model::Song&, type::SongFilter);
|
||||
bool doesSongExist(const model::Song&, type::SongFilter = type::SongFilter::id);
|
||||
bool deleteRecord(const model::Song&);
|
||||
|
||||
void saveRecord(const model::Song&);
|
||||
|
||||
@@ -11,48 +11,48 @@
|
||||
#include "type/UserFilter.h"
|
||||
|
||||
namespace database {
|
||||
class UserRepository : BaseRepository {
|
||||
public:
|
||||
UserRepository(const model::BinaryPath&);
|
||||
class UserRepository : BaseRepository {
|
||||
public:
|
||||
UserRepository(const model::BinaryPath&);
|
||||
|
||||
model::User retrieveUserRecord(model::User&, type::UserFilter);
|
||||
model::PassSec retrieverUserSaltRecord(model::PassSec&, type::SaltFilter);
|
||||
model::User retrieveUserRecord(model::User&, type::UserFilter);
|
||||
model::PassSec retrieverUserSaltRecord(model::PassSec&, type::SaltFilter);
|
||||
|
||||
bool doesUserRecordExist(const model::User&, type::UserFilter);
|
||||
bool doesUserRecordExist(const model::User&, type::UserFilter);
|
||||
|
||||
void saveUserRecord(const model::User&);
|
||||
void saveUserSalt(const model::PassSec&);
|
||||
private:
|
||||
struct UserLengths;
|
||||
struct SaltLengths;
|
||||
void saveUserRecord(const model::User&);
|
||||
void saveUserSalt(const model::PassSec&);
|
||||
private:
|
||||
struct UserLengths;
|
||||
struct SaltLengths;
|
||||
|
||||
struct UserLengths
|
||||
{
|
||||
unsigned long firstnameLength;
|
||||
unsigned long lastnameLength;
|
||||
unsigned long phoneLength;
|
||||
unsigned long emailLength;
|
||||
unsigned long usernameLength;
|
||||
unsigned long passwordLength;
|
||||
struct UserLengths {
|
||||
unsigned long firstnameLength;
|
||||
unsigned long lastnameLength;
|
||||
unsigned long phoneLength;
|
||||
unsigned long emailLength;
|
||||
unsigned long usernameLength;
|
||||
unsigned long passwordLength;
|
||||
};
|
||||
struct SaltLengths {
|
||||
unsigned long saltLength;
|
||||
};
|
||||
|
||||
std::shared_ptr<MYSQL_BIND> insertUserValues(const model::User&,
|
||||
std::shared_ptr<UserLengths>);
|
||||
std::shared_ptr<MYSQL_BIND> insertSaltValues(const model::PassSec&,
|
||||
std::shared_ptr<SaltLengths>);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::User&,
|
||||
std::tuple<char*, char*, char*, char*, char*, char*>&);
|
||||
std::shared_ptr<MYSQL_BIND> saltValueBind(model::PassSec&, char*);
|
||||
std::shared_ptr<UserLengths> fetchUserLengths(const model::User&);
|
||||
std::shared_ptr<SaltLengths> fetchSaltLengths(const model::PassSec&);
|
||||
|
||||
std::tuple<char*, char*, char*, char*, char*, char*> fetchUV();
|
||||
|
||||
model::User parseRecord(MYSQL_STMT*);
|
||||
model::PassSec parseSaltRecord(MYSQL_STMT*);
|
||||
};
|
||||
struct SaltLengths
|
||||
{
|
||||
unsigned long saltLength;
|
||||
};
|
||||
|
||||
std::shared_ptr<MYSQL_BIND> insertUserValues(const model::User&, std::shared_ptr<UserLengths>);
|
||||
std::shared_ptr<MYSQL_BIND> insertSaltValues(const model::PassSec&, std::shared_ptr<SaltLengths>);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::User&, std::tuple<char*, char*, char*, char*, char*, char*>&);
|
||||
std::shared_ptr<MYSQL_BIND> saltValueBind(model::PassSec&, char*);
|
||||
std::shared_ptr<UserLengths> fetchUserLengths(const model::User&);
|
||||
std::shared_ptr<SaltLengths> fetchSaltLengths(const model::PassSec&);
|
||||
|
||||
std::tuple<char*, char*, char*, char*, char*, char*> fetchUV();
|
||||
|
||||
model::User parseRecord(MYSQL_STMT*);
|
||||
model::PassSec parseSaltRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef YEARREPOSITORY_H_
|
||||
#define YEARREPOSITORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -8,31 +9,31 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/YearFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class YearRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class YearRepository : public BaseRepository {
|
||||
public:
|
||||
YearRepository(const model::BinaryPath&);
|
||||
|
||||
std::vector<model::Year> retrieveRecords();
|
||||
|
||||
std::pair<model::Year, int> retrieveRecordWithSongCount(model::Year&, type::YearFilter);
|
||||
std::pair<model::Year, int> retrieveRecordWithSongCount(model::Year&,
|
||||
type::YearFilter = type::YearFilter::id);
|
||||
|
||||
model::Year retrieveRecord(model::Year&, type::YearFilter);
|
||||
model::Year retrieveRecord(model::Year&, type::YearFilter = type::YearFilter::id);
|
||||
|
||||
bool doesYearExist(const model::Year&, type::YearFilter);
|
||||
bool doesYearExist(const model::Year&, type::YearFilter = type::YearFilter::id);
|
||||
|
||||
void saveRecord(const model::Year&);
|
||||
void deleteYear(const model::Year&, type::YearFilter);
|
||||
void deleteYear(const model::Year&, type::YearFilter = type::YearFilter::id);
|
||||
private:
|
||||
std::vector<model::Year> parseRecords(MYSQL_STMT*);
|
||||
|
||||
std::pair<model::Year, int> parseRecordWithSongCount(MYSQL_STMT*);
|
||||
|
||||
// TODO: After parseRecord(MYSQL_STMT*) is implemented
|
||||
// remove parseRecord(MYSQL_RES*)
|
||||
model::Year parseRecord(MYSQL_RES*);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::Year&);
|
||||
std::shared_ptr<MYSQL_BIND> valueBindWithSongCount(model::Year&,
|
||||
int&);
|
||||
|
||||
model::Year parseRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user