ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/SiteMapper/Page.cpp
Revision: 136
Committed: 2004-03-25T01:21:21-08:00 (21 years, 2 months ago) by Douglas Thrift
File size: 1699 byte(s)
Log Message:
Slight error, no comment!

File Contents

# Content
1 // Site Mapper
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
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)
28 {
29 Matcher matcher("^http://(.+)(/.*)?$");
30
31 if (url == matcher)
32 {
33 address = matcher[1];
34
35 if (matcher.size() > 2)
36 {
37 path = matcher[2];
38 }
39 else
40 {
41 path = '/';
42 }
43 }
44 else
45 {
46 cerr << program << ": Page.setUrl(" << url << ") failure.\n";
47
48 exit(1);
49 }
50 }
51
52 bool Page::operator==(const string& thing)
53 {
54 if (address == thing)
55 {
56 return true;
57 }
58 else if (path == thing)
59 {
60 return true;
61 }
62 else if (title == thing)
63 {
64 return true;
65 }
66
67 return false;
68 }
69
70 bool Page::operator==(Page& page)
71 {
72 if (address == page.address)
73 {
74 if (path == page.path || title == page.title) return true;
75 }
76
77 return false;
78 }
79
80 bool Page::operator<(Page& page)
81 {
82 if (address < page.address) if (path < page.path) return true;
83
84 return false;
85 }
86
87 bool Page::operator>(Page& page)
88 {
89 if (address > page.address) if (path > page.path) return true;
90
91 return false;
92 }
93
94 ostream& operator<<(ostream& output, Page& page)
95 {
96 string tab(page.tab, '\t');
97
98 output << tab << "<item><link address=\"" << page.getUrl() << "\">"
99 << page.title << "</link>\n";
100
101 if (!page.children.empty())
102 {
103 output << tab << "\t<list>\n";
104
105 for (int index = 0; index < page.children.size(); index++)
106 {
107 output << page.children[index](page.tab + 1) << '\n';
108 }
109
110 output << tab << "\t</list>\n";
111 }
112
113 output << tab << "</item>";
114
115 return output;
116 }

Properties

Name Value
svn:eol-style native
svn:keywords Id