-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathread.cpp
43 lines (38 loc) · 940 Bytes
/
read.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
#include "read.h"
#include "readCircle.h"
#include "readPolyline.h"
#include "readEllipse.h"
#include "readPoint.h"
void readCodes(ifstream& file, string* str) {
for (int i = 0; i < 2; i++) {
file >> str[i];
}
}
void read(ifstream& file, vector<Shape*>& container) {
string* str = new string[2];
while (!file.eof()) {
readCodes(file, str);
if (str[0] == "0" && str[1] == "SECTION") {
readCodes(file, str);
if (str[0] == "2" && str[1] == "ENTITIES") {
readCodes(file, str);
while (str[1] != "ENDSEC") {
if (str[0] == "0") {
if (str[1] == "CIRCLE")
readCircle(file, container);
else if (str[1] == "POLYLINE")
readPolyline(file, container);
else if (str[1] == "ELLIPSE")
readEllipse(file, container);
else if (str[1] == "POINT")
readPoint(file, container);
}
readCodes(file, str);
}
}
}
else
readCodes(file, str);
}
delete[] str;
}