-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTable.h
92 lines (64 loc) · 1.43 KB
/
Table.h
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
#pragma once
#ifndef TABLE_H
#define TABLE_H
#include "Protocol.h"
#include <string>
#include <vector>
#include <iostream>
#include "ext/json.hpp"
#include "ext/picosha2.h"
#include <fstream>
#include <math.h>
#define MAX_ROW_SIZE 100
using json = nlohmann::json;
int primaryHashFunction(std::string s);
int secondaryHashFunction(std::string s);
enum bg{A,B,AB,O};
enum sex { M, F };;
class Element {
public:
std::string name;
std::string pswd;
int blood_group;
std::string phoneNo;
std::string donorName;
std::string donorFather;
std::string transferDate;
int age;
int sex;
Element();
Element(std::string n,std::string pass, std::string phone,
std::string dname, std::string dfather, std::string tdate,
int _bg, int _age, int _sex);
};
class Field {
public:
std::vector< Element> vec;
int noOfChains;
Field();
Element getElement(int );
};
class Table
{
public:
Field row[MAX_ROW_SIZE];
json ReadProtocol(json&& j);
Table();
~Table();
void registerSchema(json& j);
json addEntry(json& j);
json addEntryCheckup(json& j);
json findAll(json& j);
json findOne(json& j);
json deleteEntry(json& j);
json findOneAndUpdate(json& j);
json findAllAndUpdate(json& j);
json commitToDisk();
json readFromDisk();
private:
void writeToInfo(size_t rownum, size_t rec);
bool copyExists(std::vector<Element>vec, Element e);
void fillObj(json& j, Element *e);
void filljson(json& j, Element e);
};
#endif // !TABLE_H