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 144 by Douglas Thrift, 2004-03-31T23:21:15-08:00

# Line 4 | Line 4
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)
# Line 11 | Line 12 | Page::Page(const string& address, const
12          setAddress(address);
13          setPath(path);
14          setTitle(title);
15 +
16 +        tab = 0;
17   }
18  
19 < Page::Page(const string& url)
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)
# Line 38 | Line 44 | void Page::setUrl(const string& url)
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==(Matcher& matcher)
71 + {
72 +        if (address == matcher)
73 +        {
74 +                return true;
75 +        }
76 +        else if (path == matcher)
77 +        {
78 +                return true;
79 +        }
80 +        else if (title == matcher)
81 +        {
82 +                return true;
83 +        }
84 +
85 +        return false;
86 + }
87 +
88 + bool Page::operator==(const Page& page) const
89 + {
90 +        if (address == page.address)
91 +        {
92 +                return path == page.path || title == page.title;
93 +        }
94 +
95 +        return false;
96 + }
97 +
98 + ostream& operator<<(ostream& output, Page& page)
99 + {
100 +        string tab(page.tab, '\t');
101 +
102 +        output << tab << "<item><link address=\"" << page.getUrl() << "\">"
103 +                << page.title << "</link>\n";
104 +
105 +        if (!page.children.empty())
106 +        {
107 +                output << tab << "\t<list>\n";
108 +
109 +                for (unsigned index = 0; index < page.children.size(); index++)
110 +                {
111 +                        output << page.children[index](page.tab + 2) << '\n';
112 +                }
113 +
114 +                output << tab << "\t</list>\n";
115 +        }
116 +
117 +        output << tab << "</item>";
118 +
119 +        return output;
120   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines