4 |
|
// |
5 |
|
// $Id$ |
6 |
|
|
7 |
< |
#include "Matcher.hpp" |
8 |
< |
#include "Page.hpp" |
7 |
> |
#include "Matcher/Matcher.hpp" |
8 |
> |
#include "SiteMapper.hpp" |
9 |
|
|
10 |
< |
Page::Page(const string& address, const string& path, const string& title) |
11 |
< |
{ |
12 |
< |
setAddress(address); |
13 |
< |
setPath(path); |
14 |
< |
setTitle(title); |
15 |
< |
|
16 |
< |
tab = 0; |
17 |
< |
} |
10 |
> |
Page::Page(const std::string& address, const std::string& path, const std::string& title) : address(address), path(path), title(title), tab(0) {} |
11 |
|
|
12 |
< |
Page::Page(const string& url, const string& title) |
12 |
> |
Page::Page(const std::string& url, const std::string& title) : title(title), tab(0) |
13 |
|
{ |
14 |
|
setUrl(url); |
22 |
– |
setTitle(title); |
23 |
– |
|
24 |
– |
tab = 0; |
15 |
|
} |
16 |
|
|
17 |
< |
void Page::setUrl(const string& url) |
17 |
> |
void Page::setUrl(const std::string& url) |
18 |
|
{ |
19 |
|
Matcher matcher("^http://(.+)(/.*)?$"); |
20 |
|
|
33 |
|
} |
34 |
|
else |
35 |
|
{ |
36 |
< |
cerr << program << ": Page.setUrl(" << url << ") failure.\n"; |
36 |
> |
std::cerr << program << ": Page.setUrl(" << url << ") failure.\n"; |
37 |
|
|
38 |
|
exit(1); |
39 |
|
} |
40 |
|
} |
41 |
|
|
42 |
< |
bool Page::operator==(const string& thing) |
42 |
> |
bool Page::operator==(const std::string& thing) |
43 |
|
{ |
44 |
|
if (address == thing) |
45 |
|
{ |
79 |
|
{ |
80 |
|
if (address == page.address) |
81 |
|
{ |
82 |
< |
if (path == page.path || title == page.title) return true; |
82 |
> |
return path == page.path || title == page.title; |
83 |
|
} |
84 |
|
|
85 |
|
return false; |
86 |
|
} |
87 |
|
|
88 |
< |
bool Page::operator<(const Page& page) const |
99 |
< |
{ |
100 |
< |
if (address == page.address) |
101 |
< |
{ |
102 |
< |
return path < page.path; |
103 |
< |
} |
104 |
< |
|
105 |
< |
return address < page.address; |
106 |
< |
} |
107 |
< |
|
108 |
< |
bool Page::operator>(const Page& page) const |
109 |
< |
{ |
110 |
< |
if (address == page.address) |
111 |
< |
{ |
112 |
< |
return path > page.path; |
113 |
< |
} |
114 |
< |
|
115 |
< |
return address > page.address; |
116 |
< |
} |
117 |
< |
|
118 |
< |
ostream& operator<<(ostream& output, Page& page) |
88 |
> |
std::ostream& operator<<(std::ostream& output, Page& page) |
89 |
|
{ |
90 |
< |
string tab(page.tab, '\t'); |
90 |
> |
std::string tab(page.tab, '\t'); |
91 |
|
|
92 |
|
output << tab << "<item><link address=\"" << page.getUrl() << "\">" |
93 |
|
<< page.title << "</link>\n"; |
96 |
|
{ |
97 |
|
output << tab << "\t<list>\n"; |
98 |
|
|
99 |
< |
for (list<Page>::iterator itor = page.children.begin(); itor != |
130 |
< |
page.children.end(); itor++) |
99 |
> |
for (unsigned index(0); index < page.children.size(); ++index) |
100 |
|
{ |
101 |
< |
output << (*itor)(page.tab + 1) << '\n'; |
101 |
> |
output << page.children[index](page.tab + 2) << '\n'; |
102 |
|
} |
103 |
|
|
104 |
|
output << tab << "\t</list>\n"; |