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

Comparing:
SiteMapper/Page.cpp (file contents), Revision 128 by Douglas Thrift, 2004-03-23T22:15:08-08:00 vs.
SiteMapperOld/Page.cpp (file contents), Revision 425 by douglas, 2005-03-10T20:06:50-08:00

# Line 4 | Line 4
4   //
5   // $Id$
6  
7 < #include "Page.hpp"
7 > #include "Matcher/Matcher.hpp"
8 > #include "SiteMapper.hpp"
9  
10 < Page::Page(const string& address, const string& path, const string& title)
10 < {
11 <        setAddress(address);
12 <        setPath(path);
13 <        setTitle(title);
14 < }
10 > Page::Page(const std::string& address, const std::string& path, const std::string& title) : address(address), path(path), title(title), tab(0) {}
11  
12 < Page::Page(const string& url)
12 > Page::Page(const std::string& url, const std::string& title) : title(title), tab(0)
13   {
14          setUrl(url);
15   }
16  
17 < void Page::setUrl(const string& url)
17 > void Page::setUrl(const std::string& url)
18   {
19          Matcher matcher("^http://(.+)(/.*)?$");
20  
# Line 37 | Line 33 | void Page::setUrl(const string& url)
33          }
34          else
35          {
36 <                cerr << program << ": Page.setUrl(" << url << ") failure.\n";
36 >                std::cerr << program << ": Page.setUrl(" << url << ") failure.\n";
37 >
38 >                exit(1);
39 >        }
40 > }
41 >
42 > bool Page::operator==(const std::string& thing)
43 > {
44 >        if (address == thing)
45 >        {
46 >                return true;
47 >        }
48 >        else if (path == thing)
49 >        {
50 >                return true;
51 >        }
52 >        else if (title == thing)
53 >        {
54 >                return true;
55 >        }
56 >
57 >        return false;
58 > }
59 >
60 > bool Page::operator==(Matcher& matcher)
61 > {
62 >        if (address == matcher)
63 >        {
64 >                return true;
65 >        }
66 >        else if (path == matcher)
67 >        {
68 >                return true;
69 >        }
70 >        else if (title == matcher)
71 >        {
72 >                return true;
73          }
74 +
75 +        return false;
76 + }
77 +
78 + bool Page::operator==(const Page& page) const
79 + {
80 +        if (address == page.address)
81 +        {
82 +                return path == page.path || title == page.title;
83 +        }
84 +
85 +        return false;
86 + }
87 +
88 + std::ostream& operator<<(std::ostream& output, Page& page)
89 + {
90 +        std::string tab(page.tab, '\t');
91 +
92 +        output << tab << "<item><link address=\"" << page.getUrl() << "\">"
93 +                << page.title << "</link>\n";
94 +
95 +        if (!page.children.empty())
96 +        {
97 +                output << tab << "\t<list>\n";
98 +
99 +                for (unsigned index(0); index < page.children.size(); ++index)
100 +                {
101 +                        output << page.children[index](page.tab + 2) << '\n';
102 +                }
103 +
104 +                output << tab << "\t</list>\n";
105 +        }
106 +
107 +        output << tab << "</item>";
108 +
109 +        return output;
110   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines