-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.h
More file actions
51 lines (47 loc) · 1.59 KB
/
table.h
File metadata and controls
51 lines (47 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef TABLE_H
#define TABLE_H
#include <QHash>
#include <QString>
#include "record.h"
//#include "index.h"
#include <QFile>
class Index;
using namespace std;
class Table
{
public:
struct List_node
{
Record* record ;
List_node* previous ;
List_node* next ;
};
private:
int times_used ;
QString table_name ;
QList<QString> primary_key ;
QList<Index*> indices ;
List_node* first_record ;
List_node* last_record ;
QHash<QString, QString> attribute_type_hash ; // [attribute => attribute_type]
public:
Table(QString val_table_name, QHash<QString , QString> val_attribute_type_hash);
void addIndex(Index* val_index) ;
bool createRecord(Record* val_record) ;
QHash<QString, QString> readRecord(QList<QString> attributes, QString where_attribute, QString equals_value) ;
bool updateRecord(QString attribute_to_change,QString new_value, QString where_attribute, QString has_value) ;
bool deleteRecord(QString where_attribute, QString equals_value) ;
QString getTable_name() const;
void setTable_name(const QString &value);
void print_table() ;
List_node* get_first_record_pointer() ;
List_node* get_last_record_pointer() ;
void insertAtStart(List_node* val_record) ;
void insertAtEnd(List_node* val_record) ;
void insertAfter(List_node* val_record, List_node* current) ;
void insertBefore(List_node* val_record, List_node* current) ;
void deleteNode(List_node* current) ;
void replaceNode(List_node* to_replace, List_node* with) ;
void serialized_to_file(QFile* filehandle) ;
};
#endif // TABLE_H