ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/SiteMapper/Page.cpp
Revision: 423
Committed: 2005-03-09T19:23:17-08:00 (20 years, 3 months ago) by douglas
File size: 1209 byte(s)
Log Message:
More Menes stuff needs doing, mostly _forish stuff this time.

File Contents

# User Rev Content
1 Douglas Thrift 128 // Site Mapper
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7 douglas 328 #include "SiteMapper.hpp"
8     #include "Matcher/Matcher.hpp"
9 Douglas Thrift 128
10 douglas 285 void Page::setUrl(const ext::String& url)
11 Douglas Thrift 128 {
12 douglas 330 Matcher matcher("^http://(.+)(/.*)?$", (PCRE_UNGREEDY | PCRE_DOTALL));
13    
14 Douglas Thrift 128 if (url == matcher)
15     {
16     address = matcher[1];
17    
18 douglas 287 if (matcher.size() > 2) path = matcher[2]; else path = "/";
19 Douglas Thrift 128 }
20     else
21     {
22 douglas 348 api::Cerr << SiteMapper::program << ": Page.setUrl(" << url << ") failure.\n";
23 Douglas Thrift 129
24 douglas 330 throw;
25 Douglas Thrift 128 }
26     }
27 Douglas Thrift 129
28 douglas 285 bool Page::operator==(const ext::String& thing)
29 Douglas Thrift 129 {
30 douglas 287 return address == thing || path == thing || title == thing;
31 Douglas Thrift 129 }
32    
33 Douglas Thrift 140 bool Page::operator==(Matcher& matcher)
34 Douglas Thrift 129 {
35 douglas 287 return address == matcher || path == matcher || title == matcher;
36 Douglas Thrift 140 }
37    
38     bool Page::operator==(const Page& page) const
39     {
40 Douglas Thrift 132 if (address == page.address)
41     {
42 Douglas Thrift 142 return path == page.path || title == page.title;
43 Douglas Thrift 132 }
44 Douglas Thrift 129
45     return false;
46     }
47    
48 douglas 285 xml::TextWriter& operator<<(xml::TextWriter& xml, Page& page)
49 Douglas Thrift 135 {
50 douglas 285 xml::ScopeElement item(xml, "item");
51 Douglas Thrift 135
52 douglas 285 xml.OpenElement("link");
53     xml.SetAttribute("address", page.getUrl());
54     xml.OutputText(page.title);
55     xml.CloseElement();
56 Douglas Thrift 135
57 douglas 285 if (!page.children.IsEmpty())
58 Douglas Thrift 135 {
59 douglas 285 xml::ScopeElement list(xml, "list");
60 Douglas Thrift 135
61 douglas 423 _foreach (ext::Vector<Page>, child, page.children) xml << *child;
62 Douglas Thrift 135 }
63    
64 douglas 285 return xml;
65 Douglas Thrift 135 }

Properties

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