EHM DAL 0.2.3
Data abstraction layer for Eastside Hockey Manager
Loading...
Searching...
No Matches
database.h
1#pragma once
2
3
4// Application headers
5namespace ehm_dal::tables {
6class AbstractTable;
7enum class TableIndex : char;
8} // namespace ehm_dal::tables
9
10// Qt headers
11class QByteArray;
12class QDataStream;
13#include <QtGlobal>
14#include <memory>
15class QString;
16
17namespace ehm_dal {
28{
29public:
34
35 // Close database
39 void clearAll();
40
41 // File i/o
47 bool read(const QString &file_path);
54 bool read(QDataStream &in);
62 bool read(QDataStream &in, const qsizetype file_size);
63
64 // Get data
70 static std::shared_ptr<ehm_dal::tables::AbstractTable> table(const ehm_dal::tables::TableIndex table_id);
75 qint32 tableCount() const;
76
77private:
78 // Tables
79 struct TableData;
80 static TableData table_data_;
81
82 // End of the file
83 static QByteArray end_of_file_data_;
84
85 // File i/o
86 qsizetype remainingBytes(QDataStream &in,
87 const qsizetype file_start_pos,
88 const qsizetype file_size);
89 bool readEndOfFile(QDataStream &in, const qsizetype bytes_to_read);
90
91 // Initialisation
92 void init();
93 void initChildTables();
94};
95
96} // namespace ehm_dal
97
98
The Database class parses the database.db file and provides access to its tables.
Definition: database.h:28
bool read(const QString &file_path)
Reads a database.db from the file_path and parses each of the tables.
bool read(QDataStream &in, const qsizetype file_size)
Reads file_size bytes a database.db file from QDataStream and parses each of the tables....
void clearAll()
Clear all of the database tables.
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.
bool read(QDataStream &in)
Reads a database.db file from QDataStream and parses each of the tables. The QDataStream is parsed fr...
Database()
Default constructor.
qint32 tableCount() const
Returns the number of database tables.
namespace ehm_dal::tables
Definition: column.h:4
TableIndex
The TableIndex enum represents the id number of each table within the database.
Definition: table_index.h:14