-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelement_test.cpp
More file actions
47 lines (36 loc) · 982 Bytes
/
Copy pathelement_test.cpp
File metadata and controls
47 lines (36 loc) · 982 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
//@ {
//@ "targets":[{"name":"element_test","type":"application"}]
//@ }
#include "element.hpp"
#include <cassert>
static void show(const std::string& str)
{printf("%s",str.c_str());}
static void show(const CoIN::Element& element)
{
printf("<%s",element.name().c_str());
element.visitAttributes([](const auto& attrib)
{printf(" %s=\"%s\"",attrib.first.c_str(),attrib.second.c_str());});
printf(">");
element.visitChildren([](const auto& node)
{show(node);});
printf("</%s>",element.name().c_str());
}
int main()
{
{
CoIN::Element test_a("html");
test_a.append(CoIN::Element("head"));
CoIN::Element test_b("body");
test_a.append(test_b);
show(test_a);
putchar('\n');
}
CoIN::Element test_b("html");
auto head=test_b.create(CoIN::Element("head"));
head->create(CoIN::Element("meta"))
->attributeAdd({"charset","UTF-8"});
head->create(CoIN::Element("title"))
->append("Hello, World").append(" More stuff");
show(test_b);
return 0;
}