#include<iostream>
#include<fstream>
#include<string>
#include<map>

#include"YahooTree.h"
#include"URL.h"

using namespace std;

int main() {
	ifstream opendir("//Engr_asu/ECE352/computer_science.txt");
    if (opendir == 0) {
           cout << "Could not open input file" << endl;
    }
	
	YahooTree cs;
	opendir  >> cs;	//reads the whole file into the tree.
	opendir.close();

	
	ifstream od("//Engr_asu/ECE352/computer_science.txt");
    if (od == 0) {
           cout << "Could not open input file" << endl;
    }
	map<string, URL> m; //the string the the url text (e.g. "http://me.com")
						// while the URL object holds the title and description.
	URL next;
	while (od >> next) {
		m[next.getURL()] = next;
	}

	cs.printAsHTML(m); //this one does all the work. We pass it a map that
	//matches url strings to URL objects (so you can print them easily).
	od.close();
	return 0;
}