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 136 by Douglas Thrift, 2004-03-25T01:21:21-08:00 vs.
Revision 287 by douglas, 2004-11-28T03:35:24-08:00

# Line 7 | Line 7
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  
# Line 32 | Line 15 | void Page::setUrl(const string& url)
15          {
16                  address = matcher[1];
17  
18 <                if (matcher.size() > 2)
36 <                {
37 <                        path = matcher[2];
38 <                }
39 <                else
40 <                {
41 <                        path = '/';
42 <                }
18 >                if (matcher.size() > 2) path = matcher[2]; else path = "/";
19          }
20          else
21          {
22 <                cerr << program << ": Page.setUrl(" << url << ") failure.\n";
22 >                api::Cerr << program << ": Page.setUrl(" << url << ") failure.\n";
23  
24 <                exit(1);
24 >                std::exit(1);
25          }
26   }
27  
28 < bool Page::operator==(const string& thing)
28 > bool Page::operator==(const ext::String& thing)
29   {
30 <        if (address == thing)
31 <        {
56 <                return true;
57 <        }
58 <        else if (path == thing)
59 <        {
60 <                return true;
61 <        }
62 <        else if (title == thing)
63 <        {
64 <                return true;
65 <        }
30 >        return address == thing || path == thing || title == thing;
31 > }
32  
33 <        return false;
33 > bool Page::operator==(Matcher& matcher)
34 > {
35 >        return address == matcher || path == matcher || title == matcher;
36   }
37  
38 < bool Page::operator==(Page& page)
38 > bool Page::operator==(const Page& page) const
39   {
40          if (address == page.address)
41          {
42 <                if (path == page.path || title == page.title) return true;
42 >                return path == page.path || title == page.title;
43          }
44  
45          return false;
46   }
47  
48 < 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)
48 > xml::TextWriter& operator<<(xml::TextWriter& xml, Page& page)
49   {
50 <        if (address > page.address) if (path > page.path) return true;
50 >        xml::ScopeElement item(xml, "item");
51  
52 <        return false;
53 < }
54 <
55 < ostream& operator<<(ostream& output, Page& page)
95 < {
96 <        string tab(page.tab, '\t');
52 >        xml.OpenElement("link");
53 >        xml.SetAttribute("address", page.getUrl());
54 >        xml.OutputText(page.title);
55 >        xml.CloseElement();
56  
57 <        output << tab << "<item><link address=\"" << page.getUrl() << "\">"
99 <                << page.title << "</link>\n";
100 <
101 <        if (!page.children.empty())
57 >        if (!page.children.IsEmpty())
58          {
59 <                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 <                }
59 >                xml::ScopeElement list(xml, "list");
60  
61 <                output << tab << "\t</list>\n";
61 >                _mforeach (ext::Vector<Page>, child, page.children) xml << *child;
62          }
63  
64 <        output << tab << "</item>";
114 <
115 <        return output;
64 >        return xml;
65   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines