-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.cpp
More file actions
70 lines (65 loc) · 1.35 KB
/
Utils.cpp
File metadata and controls
70 lines (65 loc) · 1.35 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
#include "Utils.h"
#include <iostream>
#include <string>
#include <fstream>
#include "CMUgraphicsLib/colors.h"
#include "Figures/CFigure.h"
#include "Figures/CCircle.h"
//CFigure* NameToFigure(std::string id) {
// if (id == "circle")
// return CCircle();
// else if (id == "hexa")
// return RED;
// else if (id == "rectangle")
// return BLUE;
// else if (id == "square")
// return BLACK;
// else if (id == "triangle")
// return YELLOW;
//}
std::string ColorToName(color color) {
if (color == GREEN)
return "GREEN";
else if (color == RED)
return "RED";
else if (color == BLUE)
return "BLUE";
else if (color == BLACK)
return "BLACK";
else if (color == YELLOW)
return "YELLOW";
else if (color == ORANGE)
return "ORANGE";
else if (color == WHITE)
return "WHITE";
else
return "NONE";
}
color NameToColor(std::string id) {
if (id == "GREEN")
return GREEN;
else if (id == "RED")
return RED;
else if (id == "BLUE")
return BLUE;
else if (id == "BLACK")
return BLACK;
else if (id == "YELLOW")
return YELLOW;
else if (id == "ORANGE")
return ORANGE;
else if (id == "WHITE")
return WHITE;
else
return PINK;
}
std::ofstream& operator<<(std::ofstream& out, color& color) {
out << ColorToName(color);
return out;
}
std::ifstream& operator>>(std::ifstream& in, color& color) {
std::string id;
in >> id;
color = NameToColor(id);
return in;
}