aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/common/table.cpp
blob: 20a9864103c1e64f099949e66fbb5c9763536408 (plain) (blame)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "table.h"
#include <QHash>

Table::Table()
{
}

Table::Table(const QString& database, const QString& table)
{
    setDatabase(database);
    setTable(table);
}

Table::Table(const Table& other)
{
    database = other.database;
    table = other.table;
}

Table::~Table()
{
}

int Table::operator ==(const Table &other) const
{
    return other.database == this->database && other.table == this->table;
}

QString Table::getTable() const
{
    return table;
}

void Table::setTable(const QString& value)
{
    table = value;
}

QString Table::getDatabase() const
{
    return database;
}

void Table::setDatabase(const QString& value)
{
    database = value.isEmpty() ? "main" : value;
}

int qHash(Table table)
{
    return qHash(table.getDatabase() + "." + table.getTable());
}

AliasedTable::AliasedTable()
{
}

AliasedTable::AliasedTable(const QString& database, const QString& table, const QString& alias) :
    Table(database, table)
{
    setTableAlias(alias);
}

AliasedTable::AliasedTable(const AliasedTable& other) :
    Table(other.database, other.table)
{
    tableAlias = other.tableAlias;
}

AliasedTable::~AliasedTable()
{
}

int AliasedTable::operator ==(const AliasedTable& other) const
{
    return other.database == this->database && other.table == this->table && other.tableAlias == this->tableAlias;
}

QString AliasedTable::getTableAlias() const
{
    return tableAlias;
}

void AliasedTable::setTableAlias(const QString& value)
{
    tableAlias = value;
}

int qHash(AliasedTable table)
{
    return qHash(table.getDatabase() + "." + table.getTable() + " " + table.getTableAlias());
}

DbAndTable::DbAndTable() :
    Table()
{
}

DbAndTable::DbAndTable(Db *db, const QString &database, const QString &table) :
    Table(database, table), db(db)
{
}

DbAndTable::DbAndTable(const DbAndTable &other) :
    Table(other), db(other.db)
{
}

int DbAndTable::operator ==(const DbAndTable &other) const
{
    return other.database == this->database && other.table == this->table && other.db == this->db;
}

Db *DbAndTable::getDb() const
{
    return db;
}

void DbAndTable::setDb(Db *value)
{
    db = value;
}