-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManager.cpp
More file actions
148 lines (123 loc) · 2.67 KB
/
Copy pathManager.cpp
File metadata and controls
148 lines (123 loc) · 2.67 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include "Manager.h"
Manager::Manager()
{
}
Manager::~Manager()
{
}
void Manager::run(const char* command)
{
// Open command & log file
fcmd.open(command);
flog.open("log.txt");
if (!fcmd)
{
flog << "Fail to open command file" << endl;
exit(-1);
}
// Run command
char comm[8] = { 0 };
char string[36] = { 0 };
while (!fcmd.eof())
{
fcmd >> comm;
if (!strcmp(comm, "LOAD"))
LOAD();
else if (!strcmp(comm, "ADD"))
{
fcmd.ignore();
fcmd.getline(string, 36);
ADD(string);
}
else if (!strcmp(comm, "QPOP"))
;
else if (!strcmp(comm, "SEARCH"))
;
else if (!strcmp(comm, "PRINT"))
;
else if (!strcmp(comm, "DELETE"))
;
else if (!strcmp(comm, "EXIT"))
{
PrintSuccess("EXIT");
exit(0);
}
else
PrintErrorCode(1000);
}
fcmd.close();
flog.close();
return;
}
void Manager::PrintSuccess(const char* cmd)
{
flog << "===== " << cmd << " =====" << endl;
flog << "Success" << endl;
flog << "===============" << endl << endl;
}
void Manager::PrintErrorCode(int num)
{
flog << "===== ERROR =====" << endl;
flog << num << endl;
flog << "===============" << endl << endl;
}
void Manager::LOAD()
{
char name[20] = { 0 };
int age;
char collectday[16] = { 0 };
char type;
ifstream fdata;
fdata.open("data.txt");
if (!fcmd)
{
flog << "100" << endl;
exit(-1);
}
MemberQueue q;
flog << "===== " << "LOAD" << " =====" << endl;
while (fdata >> name)
{
fdata >> age;
fdata >> collectday;
fdata >> type;
//searchÇØ¼ °°Àº À̸§ ½Ã error
q.push(name, age, collectday, type);
flog << name << "/" << age << "/" << collectday << "/" << type << endl;
}
flog << "===============" << endl << endl;
}
void Manager::ADD(const char* string)
{
MemberQueue q;
char name[20] = { 0 };
int age = 0;
char collectday[16] = { 0 };
char type = 0;
int i = 0;
//data È®ÀÎ
for (; i < 36; i++)
{
if (string[i] == '\n')
if (string[i] == ' ')
break;
else
name[i] = string[i];
}
q.push(name, age, collectday, type);
flog << "===== " << "ADD" << " =====" << endl;
flog << name << "/" << age << "/" << collectday << "/" << type << endl;
flog << "===============" << endl << endl;
}
void Manager::QPOP()
{
}
void Manager::SEARCH()
{
}
void Manager::PRINT()
{
}
void Manager::DELETE()
{
}