-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.h
More file actions
47 lines (37 loc) · 934 Bytes
/
task.h
File metadata and controls
47 lines (37 loc) · 934 Bytes
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
#ifndef TASK_H
#define TASK_H
#include <fstream>
#include <string>
// 태스크의 종류
enum TaskType { MULTIPLY, PALINDROME };
// 태스크에 대한 설명을 담는 구조체
struct Task {
TaskType type;
std::string filename;
};
// 태스크를 읽어오기 위한 클래스
class TaskSet {
private:
std::ifstream file_;
public:
TaskSet(std::string filename) { file_.open(filename); }
~TaskSet() { file_.close(); }
// 다음 태스크를 읽어 task 객체에 저장하고 true를 반환한다
// 태스크가 없는 경우 false를 반환한다
bool getNext(Task &task) {
if (file_.eof())
return false;
std::string typeText;
file_ >> typeText;
if (typeText == "multiply") {
task.type = MULTIPLY;
} else if (typeText == "palindrome") {
task.type = PALINDROME;
} else {
return getNext(task);
}
file_ >> task.filename;
return true;
}
};
#endif