EHM DAL 0.2.3
Data abstraction layer for Eastside Hockey Manager
|
The Database class parses the database.db file and provides access to its tables. More...
#include <database.h>
Public Member Functions | |
Database () | |
Default constructor. | |
void | clearAll () |
Clear all of the database tables. | |
bool | read (const QString &file_path) |
Reads a database.db from the file_path and parses each of the tables. | |
bool | read (QDataStream &in) |
Reads a database.db file from QDataStream and parses each of the tables. The QDataStream is parsed from the current position of the stream until the end of the stream is reached. | |
bool | read (QDataStream &in, const qsizetype file_size) |
Reads file_size bytes a database.db file from QDataStream and parses each of the tables. The QDataStream is parsed from the current position of the stream until until file_size bytes are parsed. | |
qint32 | tableCount () const |
Returns the number of database tables. | |
Static Public Member Functions | |
static std::shared_ptr< ehm_dal::tables::AbstractTable > | table (const ehm_dal::tables::TableIndex table_id) |
Returns a shared pointer to a Table with a ehm_dal::tables::TableIndex of table_id . | |
The Database class parses the database.db file and provides access to its tables.
The parsed tables are static members of Database, allowing easy access via the static table(const TableIndex table_id) function without the need to continually construct or pass an instantation of Database to functions.
A database is typically parsed by passing the file path of the database.db file to read(const QString &file_path). Alternatively, a QDataStream
attached to a database.db file can be parsed using read(QDataStream &in).
bool ehm_dal::Database::read | ( | const QString & | file_path | ) |
Reads a database.db from the file_path
and parses each of the tables.
file_path | Path to the database.db file; e.g. "C:\Users\archibalduk\Desktop\database.db" |
bool ehm_dal::Database::read | ( | QDataStream & | in | ) |
Reads a database.db file from QDataStream
and parses each of the tables. The QDataStream
is parsed from the current position of the stream until the end of the stream is reached.
in | QDataStream attached to database.db file |
bool ehm_dal::Database::read | ( | QDataStream & | in, |
const qsizetype | file_size | ||
) |
Reads file_size
bytes a database.db file from QDataStream
and parses each of the tables. The QDataStream
is parsed from the current position of the stream until until file_size
bytes are parsed.
in | QDataStream attached to database.db file |
file_size | File size in bytes to be read. |
|
static |
Returns a shared pointer to a Table with a ehm_dal::tables::TableIndex of table_id
.
table_id | ehm_dal::tables::TableIndex of the desired Table. |
shared_ptr
to the Table or nullptr
if the ehm_dal::tables::TableIndex is invalid. qint32 ehm_dal::Database::tableCount | ( | ) | const |
Returns the number of database tables.