-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCSSselectorprint.cpp
67 lines (59 loc) · 1.32 KB
/
CSSselectorprint.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* CSStagprint.cpp
*
* Created on: Apr 29, 2013
* Author: brandon
*/
#include "CSSselectorprint.h"
CSSselectorprint::CSSselectorprint() {}
CSSselectorprint::~CSSselectorprint() {}
std::string CSSselectorprint::formatTag(CSStag tag) {
std::string formatedString = "";
if (tag.getTagExtend() == 0 ) {
formatedString += " ";
}
formatedString += getTagCharacter(tag.getTagType());
formatedString += tag.getTagName();
return formatedString;
}
std::string CSSselectorprint::formatSelector(CSSselector tag) {
std::string formatedString = "";
for (int i = 0; i < (int)tag.getSelectorContainer().size(); i++){
formatedString += formatTag(tag.getSelectorContainer().at(i).getTag());
}
formatedString += "\n";
return formatedString;
}
std::string CSSselectorprint::getTagCharacter(int type) {
std::string formatedString;
switch (type) {
case 0:
formatedString = "";
break;
case 1:
formatedString = ".";
break;
case 2:
formatedString = "#";
break;
case 3:
formatedString = ":";
break;
case 4:
formatedString = "[ ";
break;
case 5:
formatedString = " ]";
break;
case 6:
formatedString = "@media ";
break;
default:
formatedString = "";
break;
}
return formatedString;
}
void CSSselectorprint::sortTags(void) {
// TODO Sort selector tags by type and group.
}