// Site Mapper // // Douglas Thrift // // $Id$ #include "SiteMapper.hpp" #include "Matcher/Matcher.hpp" void Page::setUrl(const ext::String& url) { Matcher matcher("^http://(.+)(/.*)?$"); if (url == matcher) { address = matcher[1]; if (matcher.size() > 2) path = matcher[2]; else path = "/"; } else { api::Cerr << program << ": Page.setUrl(" << url << ") failure.\n"; std::exit(1); } } bool Page::operator==(const ext::String& thing) { return address == thing || path == thing || title == thing; } bool Page::operator==(Matcher& matcher) { return address == matcher || path == matcher || title == matcher; } bool Page::operator==(const Page& page) const { if (address == page.address) { return path == page.path || title == page.title; } return false; } xml::TextWriter& operator<<(xml::TextWriter& xml, Page& page) { xml::ScopeElement item(xml, "item"); xml.OpenElement("link"); xml.SetAttribute("address", page.getUrl()); xml.OutputText(page.title); xml.CloseElement(); if (!page.children.IsEmpty()) { xml::ScopeElement list(xml, "list"); _mforeach (ext::Vector, child, page.children) xml << *child; } return xml; }