EHM DAL 0.2.3
Data abstraction layer for Eastside Hockey Manager
Loading...
Searching...
No Matches
ehm_dal::Database Class Reference

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::AbstractTabletable (const ehm_dal::tables::TableIndex table_id)
 Returns a shared pointer to a Table with a ehm_dal::tables::TableIndex of table_id.
 

Detailed Description

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).

Member Function Documentation

◆ read() [1/3]

bool ehm_dal::Database::read ( const QString &  file_path)

Reads a database.db from the file_path and parses each of the tables.

Parameters
file_pathPath to the database.db file; e.g. "C:\Users\archibalduk\Desktop\database.db"
Returns
whether the file was successfully opened and parsed.

◆ read() [2/3]

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.

Parameters
inQDataStream attached to database.db file
Returns
whether the file was successfully opened and parsed.

◆ read() [3/3]

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.

Parameters
inQDataStream attached to database.db file
file_sizeFile size in bytes to be read.
Returns

◆ table()

static std::shared_ptr< ehm_dal::tables::AbstractTable > ehm_dal::Database::table ( const ehm_dal::tables::TableIndex  table_id)
static

Returns a shared pointer to a Table with a ehm_dal::tables::TableIndex of table_id.

Parameters
table_idehm_dal::tables::TableIndex of the desired Table.
Returns
a shared_ptr to the Table or nullptr if the ehm_dal::tables::TableIndex is invalid.

◆ tableCount()

qint32 ehm_dal::Database::tableCount ( ) const

Returns the number of database tables.

Returns
the number of database tables