ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/SiteMapper/Page.cpp
Revision: 285
Committed: 2004-11-28T03:01:11-08:00 (20 years, 6 months ago) by douglas
File size: 1368 byte(s)
Log Message:
Wow, that's pretty big!

File Contents

# Content
1 // Site Mapper
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #include "Matcher.hpp"
8 #include "Page.hpp"
9
10 void Page::setUrl(const ext::String& url)
11 {
12 Matcher matcher("^http://(.+)(/.*)?$");
13
14 if (url == matcher)
15 {
16 address = matcher[1];
17
18 if (matcher.size() > 2)
19 {
20 path = matcher[2];
21 }
22 else
23 {
24 path = "/";
25 }
26 }
27 else
28 {
29 api::Cerr << program << ": Page.setUrl(" << url << ") failure.\n";
30
31 std::exit(1);
32 }
33 }
34
35 bool Page::operator==(const ext::String& thing)
36 {
37 if (address == thing)
38 {
39 return true;
40 }
41 else if (path == thing)
42 {
43 return true;
44 }
45 else if (title == thing)
46 {
47 return true;
48 }
49
50 return false;
51 }
52
53 bool Page::operator==(Matcher& matcher)
54 {
55 if (address == matcher)
56 {
57 return true;
58 }
59 else if (path == matcher)
60 {
61 return true;
62 }
63 else if (title == matcher)
64 {
65 return true;
66 }
67
68 return false;
69 }
70
71 bool Page::operator==(const Page& page) const
72 {
73 if (address == page.address)
74 {
75 return path == page.path || title == page.title;
76 }
77
78 return false;
79 }
80
81 xml::TextWriter& operator<<(xml::TextWriter& xml, Page& page)
82 {
83 xml::ScopeElement item(xml, "item");
84
85 xml.OpenElement("link");
86 xml.SetAttribute("address", page.getUrl());
87 xml.OutputText(page.title);
88 xml.CloseElement();
89
90 if (!page.children.IsEmpty())
91 {
92 xml::ScopeElement list(xml, "list");
93
94 _mforeach (ext::Vector<Page>, child, page.children) xml << *child;
95 }
96
97 return xml;
98 }

Properties

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