/*
File Name: ErrorReport.h
Created By: Andy Odle
Date: July 29, 2009

Description: 
    
    
*/
#ifndef ErrorReport_h
#define ErrorReport_h

// Windows Specfic.
#define _WIN32_WINNT 0x0501
#include <windows.h>

// c++ Standard headers.
#include <fstream>
#include <string>

using namespace std;

class ErrorReport
{
    public:
        
        ErrorReport(string reportName_p);
        ErrorReport();
        ~ErrorReport();
    
        // Input:
        //           Takes an error message to write to the log file.
        // 
        // Output:
        //           Adds the error message to the end of the error report.    
        void ReportPlainError(string errorDescription_p);
        
        // Input:
        //           Takes a template type.
        //           Takes an error message to write to the log file.
        //           Input must be initilized to 0 or null to properly check if a variable is empty or not.
        // 
        // Output:
        //           Writes the error message, variable's address, and the variable's contents
        //           to the end of the error report.
        void ReportVariableError(string errorDescription_p, string variableAddresss_p, string variableContents_p);
        
    private:
    
        // Input:
        //           Takes a string representing the name of the report
        //           that you would like to create.
        //           Takes a flag to set weither or not the file should
        //           should be opended for appending.
        // Output:
        //           Returns true if the file was sucessfully opened.
        //           Returns false if the file was unsucessfully opened.        
        bool OpenFile(string reportName_p, bool append_p = false);
        
        void CloseFile();
        
        // Input:
        //           Doesn't take anything.
        // 
        // Output:
        //           Writes the top extra bits of the html error report.        
        void BuildAndWriteReportHeader(); 
        
        // Input:
        //           Doesn't take anything.
        // 
        // Output:
        //           Writes the bottom extra bits of the html error report.
        void BuildAndWriteReportFooter();
        
        // Input:
        //        Takes a name for a report.
        //
        // Output:
        //         Returns a file name that matches the report name.
        //         
        string GenerateFileName(string reportName_p);

        // Display the error report in the users default web browser.
        void DisplayErrorReport(); 
        
    private:
        
        bool errorOccured_m;
        int errorCount_m;
        string reportName_m;
        ofstream reportFile_m;
};

#endif
