#include "YahooTree.h"
istream & operator>>(istream & is, YahooTree &t)
{
YahooNode * current = t.root;
stack<YahooNode *> ancestors;
for (YahooNode * n = new YahooNode; is >> *n; n = new YahooNode){
if (t.root == 0) { t.root = n;
ancestors.push(n);
continue;
}
for (YahooNode * c = ancestors.top(); !(ancestors.empty()); ancestors.pop(),
c = ancestors.top()){
if (n->childOf(*c)) {
c->addChild(n);
ancestors.push(n);
break;
}
};
}
delete n; return is;
}
void YahooTree::printAsHTML(map<string, URL> & m)
{
if (root != 0)
root->printAsHTML(m);
}