aboutsummaryrefslogtreecommitdiff
path: root/query.h
blob: 5018f9d388861e100ec1e2aeabe27a94acaea150 (plain)
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
#pragma once

#include "enginedata.h"
#include <vector>
#include <string>
#include <map>

using namespace std;


struct WhereClause{
	int col;
	RowItem value;
	WhereClause(void);
	WhereClause(const int _c,const RowItem &_v);
};


struct QueryResult{
	int res;
	vector<Row> rows;
	string msg; //empty message indicates success
	QueryResult(void);
	QueryResult(int);
	QueryResult(int,const vector<Row>&);
	QueryResult(int,const vector<Row>&,const string&);
	QueryResult(int,const string&);
};


struct Query{
	string tablename;
	virtual QueryResult execute(map<string,Table>&);
};

struct CreateQuery : public Query{
	int nc;
	ColHeader *header;
	CreateQuery(void);
	void setHeader(const ColHeader *hd);
	QueryResult execute(map<string,Table> &tables);
};

struct FindQuery : public Query{
	unsigned int limit; //-1=unlimited
	int sort; //0=no sort, 1=sort, -1=reverse sort
	vector<WhereClause> where;
	FindQuery(void);
	QueryResult execute(map<string,Table> &tables);
};

struct InsertQuery : public Query{
	Row row;
	InsertQuery(const Row &_r);
	InsertQuery(Row &&_r);
	QueryResult execute(map<string,Table> &tables);
};