-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_disability.cpp
69 lines (58 loc) · 2.24 KB
/
process_disability.cpp
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
/*
CSCE 2110.002: Project 3:
Group 19
Major Component 2 - Creating Disability Table
File Name: process_disability.cpp
Author: Cole Hochstrate
*/
#include "main.h"
#include "dis.h"
#include "process_disability.h"
// this funcation handels the calling of insert select delete and update using regex matching
void processDisability(ofstream& out_stream, DisTable& dis, DisList& dislist, string query)
{
//INCREASING SIZE AND HASHING ALL DATA
if(dis.IncreaseSize())
{
dis.HashAll(); // reshash table
dislist.ResetAll(); // reset secondary index
dis.CreateList(dislist); // recreate secondary index
}
// each on of the blacks will use regex to deciver what function (insert, update, select, and delete) to call
//INSERT QUERIES
regex insertpat("INSERT\\(\\((\".*\"|.*),(.*),(.*),(.*),(.*),(.*),(.*)\\),disability\\)");
if(regex_match(query, insertpat))
{
smatch matcher;
regex_search(query, matcher, insertpat);
dis.Insert(make_pair(matcher[1].str(), DisData(stoi(matcher[2].str()), stoi(matcher[3].str()), stoi(matcher[4].str()), stoi(matcher[5].str()), stoi(matcher[6].str()), stoi(matcher[7].str()))), dislist, out_stream);
return;
}
//UPDATE QUERIES
regex updatepat("UPDATE\\(\\((\".*\"|.*),(.*),(.*),(.*),(.*),(.*),(.*)\\),disability\\)");
if(regex_match(query, updatepat))
{
smatch matcher;
regex_search(query, matcher, updatepat);
dis.Update(make_pair(matcher[1].str(), DisData(stoi(matcher[2].str()), stoi(matcher[3].str()), stoi(matcher[4].str()), stoi(matcher[5].str()), stoi(matcher[6].str()), stoi(matcher[7].str()))), dislist, out_stream);
return;
}
//SELECT QUERIES
regex selectpat("SELECT\\(\\((\".*\"|.*),(.*),(.*),(.*),(.*),(.*),(.*)\\),disability\\)");
if(regex_match(query, selectpat))
{
smatch matcher;
regex_search(query, matcher, selectpat);
dis.Select(matcher, query, dislist, out_stream);
return;
}
//DELETE QUERIES
regex deletepat("DELETE\\(\\((\".*\"|.*),(.*),(.*),(.*),(.*),(.*),(.*)\\),disability\\)");
if(regex_match(query, deletepat))
{
smatch matcher;
regex_search(query, matcher, deletepat);
dis.Delete(matcher, query, dislist, out_stream, dis);
return;
}
}