-
Notifications
You must be signed in to change notification settings - Fork 0
/
requestLib.h
executable file
·66 lines (55 loc) · 1.74 KB
/
requestLib.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
/*
* =========================================================================================
* Name : requestLib.h
* Author : Duc Dung Nguyen
* Email : [email protected]
* Copyright : Faculty of Computer Science and Engineering - Bach Khoa University
* Description : library for Assignment 2 - Data structures and Algorithms - Fall 2017
* This library contains functions used for event management
* =========================================================================================
*/
#ifndef DSA171A2_REQUESTLIB_H
#define DSA171A2_REQUESTLIB_H
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <sstream>
#include "dsaLib.h"
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#define REQUEST_CODE_SIZE 16
#define MAX_PARAM_SIZE 6
using namespace std;
typedef struct VM_Request {
char code[REQUEST_CODE_SIZE];
double params[MAX_PARAM_SIZE];
VM_Request() {
*code = '0';// default event is "0"
code[1] = 0;
}
VM_Request(char* str) {
strncpy(code, str, REQUEST_CODE_SIZE - 1);
}
VM_Request(string& str) {
strncpy(code, str.data(), REQUEST_CODE_SIZE - 1);
}
VM_Request(VM_Request& a) { // copy constructor
memcpy(code, a.code, REQUEST_CODE_SIZE);
memcpy(params, a.params, MAX_PARAM_SIZE * sizeof(double));
}
VM_Request(VM_Request&& a) { // move constructor
int i = 0;
while(a.code[i]) {
code[i] = a.code[i];
i++;
}
code[i] = 0;
}
bool operator==(VM_Request &b) {
return strcmp(code, b.code) == 0;
}
};
void loadRequests(char* fName, L1List<VM_Request> &);
#endif //DSA171A2_REQUESTLIB_H