-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
70 lines (70 loc) · 1.86 KB
/
Copy pathMain.cpp
File metadata and controls
70 lines (70 loc) · 1.86 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 "DOMParser.h"
#include "TagElement.h"
#include "FindSimple.h"
#include "ExeptionHandler.h"
#include <iostream>
#include <thread>
#include <set>
using namespace std;
set<unsigned int> FindSimple::simples = {};
int main()
{
DOMParser MyParser;
TagElement* Root;
vector<FindSimple> simples;
vector<thread> t;
try {
Root = MyParser.StartParsing("XMLFile.xml");
}
catch (ExeptionHandler& e) {
e.what();
return 0;
}
try {
if (Root->children.size() != 1)
{
throw ExeptionHandler("Root have more than one children");
}
else if (Root->children[0]->name != "intervals") {
throw ExeptionHandler("Roots doesn't contain intervals");
}
for (auto i : Root->children[0]->children) {
if (i->name != "interval") {
throw ExeptionHandler("Intervals contains wrong tag type");
}
else if (i->children.size() != 2)
{
throw ExeptionHandler("Interval contains more than two tags");
}
else if ((i->children[0]->name != "low") || (i->children[1]->name != "high"))
{
throw ExeptionHandler("Interval doesn't contains low or high tags, or contains them in wrong order");
}
else {
if (i->children[0]->InnerText == "") {
throw ExeptionHandler("Low tag has no info");
}
else if (i->children[1]->InnerText == "") {
throw ExeptionHandler("High tag has no info");
}
else {
unsigned int low = std::stoul(i->children[0]->InnerText);
unsigned int high = std::stoul(i->children[1]->InnerText);
simples.push_back(FindSimple(low, high));
}
}
}
}
catch(ExeptionHandler& e) {
e.what();
}
for (auto& r : simples)
t.push_back(std::thread(std::bind(&FindSimple::FindSimples, &r)));
for (auto& th : t)
th.join();
for (auto i = FindSimple::simples.begin(); i != FindSimple::simples.end(); ++i)
{
cout << *i << endl;
}
system("pause");
}