7 |
|
#include "Matcher.hpp" |
8 |
|
#include "Page.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 |
< |
} |
18 |
< |
|
19 |
< |
Page::Page(const string& url, const string& title) |
20 |
< |
{ |
21 |
< |
setUrl(url); |
22 |
< |
setTitle(title); |
23 |
< |
|
24 |
< |
tab = 0; |
25 |
< |
} |
26 |
< |
|
27 |
< |
void Page::setUrl(const string& url) |
10 |
> |
void Page::setUrl(const ext::String& url) |
11 |
|
{ |
12 |
|
Matcher matcher("^http://(.+)(/.*)?$"); |
13 |
|
|
21 |
|
} |
22 |
|
else |
23 |
|
{ |
24 |
< |
path = '/'; |
24 |
> |
path = "/"; |
25 |
|
} |
26 |
|
} |
27 |
|
else |
28 |
|
{ |
29 |
< |
cerr << program << ": Page.setUrl(" << url << ") failure.\n"; |
29 |
> |
api::Cerr << program << ": Page.setUrl(" << url << ") failure.\n"; |
30 |
|
|
31 |
< |
exit(1); |
31 |
> |
std::exit(1); |
32 |
|
} |
33 |
|
} |
34 |
|
|
35 |
< |
bool Page::operator==(const string& thing) |
35 |
> |
bool Page::operator==(const ext::String& thing) |
36 |
|
{ |
37 |
|
if (address == thing) |
38 |
|
{ |
78 |
|
return false; |
79 |
|
} |
80 |
|
|
81 |
< |
ostream& operator<<(ostream& output, Page& page) |
81 |
> |
xml::TextWriter& operator<<(xml::TextWriter& xml, Page& page) |
82 |
|
{ |
83 |
< |
string tab(page.tab, '\t'); |
83 |
> |
xml::ScopeElement item(xml, "item"); |
84 |
|
|
85 |
< |
output << tab << "<item><link address=\"" << page.getUrl() << "\">" |
86 |
< |
<< page.title << "</link>\n"; |
85 |
> |
xml.OpenElement("link"); |
86 |
> |
xml.SetAttribute("address", page.getUrl()); |
87 |
> |
xml.OutputText(page.title); |
88 |
> |
xml.CloseElement(); |
89 |
|
|
90 |
< |
if (!page.children.empty()) |
90 |
> |
if (!page.children.IsEmpty()) |
91 |
|
{ |
92 |
< |
output << tab << "\t<list>\n"; |
108 |
< |
|
109 |
< |
for (unsigned index = 0; index < page.children.size(); index++) |
110 |
< |
{ |
111 |
< |
output << page.children[index](page.tab + 2) << '\n'; |
112 |
< |
} |
92 |
> |
xml::ScopeElement list(xml, "list"); |
93 |
|
|
94 |
< |
output << tab << "\t</list>\n"; |
94 |
> |
_mforeach (ext::Vector<Page>, child, page.children) xml << *child; |
95 |
|
} |
96 |
|
|
97 |
< |
output << tab << "</item>"; |
118 |
< |
|
119 |
< |
return output; |
97 |
> |
return xml; |
98 |
|
} |