-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml_tag.cpp
44 lines (36 loc) · 1.02 KB
/
html_tag.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
#include "html_tag.h"
#include <sstream>
#include <string>
namespace patch {
template <typename T>
std::string to_string(const T& n) {
std::ostringstream stm;
stm << n;
return stm.str();
}
} // namespace patch
HTML_Tag::HTML_Tag(std::string name, int tag_type, std::string value) {
this->name = name;
this->tag_type = tag_type;
this->value = value;
}
std::string HTML_Tag::getString() {
std::string return_string = "";
if (tag_type == SINGLE_TAG) {
return_string = "<" + name + " " + value + ">";
} else if (tag_type == DOUBLE_TAG) {
std::string child_string = "";
for (int i = 0; i < list.getSize(); i++) {
child_string += list.getElement(i)->getString();
}
return_string = "<" + name + ">" + child_string + value + "</" + name + ">";
}
return return_string;
}
void HTML_Tag::addChild(HTML_Tag* child) {
//this->child = child;
list.addElement(child);
}
void HTML_Tag::setValue(std::string value){
this->value = value;
}