// Site Mapper // // Douglas Thrift // // $Id$ #include "Matcher.hpp" #include "Page.hpp" Page::Page(const string& address, const string& path, const string& title) { setAddress(address); setPath(path); setTitle(title); } Page::Page(const string& url) { setUrl(url); } void Page::setUrl(const string& url) { Matcher matcher("^http://(.+)(/.*)?$"); if (url == matcher) { address = matcher[1]; if (matcher.size() > 2) { path = matcher[2]; } else { path = '/'; } } else { cerr << program << ": Page.setUrl(" << url << ") failure.\n"; exit(1); } } bool Page::operator==(const string& thing) { if (address == thing) { return true; } else if (path == thing) { return true; } else if (title == thing) { return true; } return false; } bool Page::operator==(Page& page) { if (address == page.address) { if (path == page.path || title == page.title) return true; } return false; } bool Page::operator<(Page& page) { if (address < page.address) if (path < page.path) return true; return false; } bool Page::operator>(Page& page) { if (address > page.address) if (path > page.path) return true; return false; }