ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/SiteMapper/Page.cpp
(Generate patch)

Comparing SiteMapper/Page.cpp (file contents):
Revision 128 by Douglas Thrift, 2004-03-23T22:15:08-08:00 vs.
Revision 330 by douglas, 2004-12-13T20:46:08-08:00

# Line 4 | Line 4
4   //
5   // $Id$
6  
7 < #include "Page.hpp"
7 > #include "SiteMapper.hpp"
8 > #include "Matcher/Matcher.hpp"
9  
10 < Page::Page(const string& address, const string& path, const string& title)
10 > void Page::setUrl(const ext::String& url)
11   {
12 <        setAddress(address);
12 <        setPath(path);
13 <        setTitle(title);
14 < }
12 >        api::Cerr << PCRE_MULTILINE << " = " << Matcher::defaults << ios::NewLine;
13  
14 < Page::Page(const string& url)
17 < {
18 <        setUrl(url);
19 < }
14 >        Matcher matcher("^http://(.+)(/.*)?$", (PCRE_UNGREEDY | PCRE_DOTALL));
15  
16 < void Page::setUrl(const string& url)
22 < {
23 <        Matcher matcher("^http://(.+)(/.*)?$");
16 >        api::Cerr << (PCRE_UNGREEDY | PCRE_DOTALL) << " = " << matcher.options << ios::NewLine;
17  
18          if (url == matcher)
19          {
20                  address = matcher[1];
21  
22 <                if (matcher.size() > 2)
30 <                {
31 <                        path = matcher[2];
32 <                }
33 <                else
34 <                {
35 <                        path = '/';
36 <                }
22 >                if (matcher.size() > 2) path = matcher[2]; else path = "/";
23          }
24          else
25          {
26 <                cerr << program << ": Page.setUrl(" << url << ") failure.\n";
26 >                api::Cerr << program << ": Page.setUrl(" << url << ") failure.\n";
27 >
28 >                throw;
29 >        }
30 > }
31 >
32 > bool Page::operator==(const ext::String& thing)
33 > {
34 >        return address == thing || path == thing || title == thing;
35 > }
36 >
37 > bool Page::operator==(Matcher& matcher)
38 > {
39 >        return address == matcher || path == matcher || title == matcher;
40 > }
41 >
42 > bool Page::operator==(const Page& page) const
43 > {
44 >        if (address == page.address)
45 >        {
46 >                return path == page.path || title == page.title;
47          }
48 +
49 +        return false;
50 + }
51 +
52 + xml::TextWriter& operator<<(xml::TextWriter& xml, Page& page)
53 + {
54 +        xml::ScopeElement item(xml, "item");
55 +
56 +        xml.OpenElement("link");
57 +        xml.SetAttribute("address", page.getUrl());
58 +        xml.OutputText(page.title);
59 +        xml.CloseElement();
60 +
61 +        if (!page.children.IsEmpty())
62 +        {
63 +                xml::ScopeElement list(xml, "list");
64 +
65 +                _mforeach (ext::Vector<Page>, child, page.children) xml << *child;
66 +        }
67 +
68 +        return xml;
69   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines