////////////////////////////////////////////////////////// // ExportTree.cpp // // // // Contains functions for exporting some information // // from the WAM tree structure into a human-readable // // form. Uses a recursive folder dump algorithm // // // // AUTHOR: Lucas Scharf // // // // REVISIONS: DATE, REASON // // AUTHOR FOR EACH (if different) // // VERSION: x.xx // ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// // Includes // ////////////////////////////////////////////////////////// #include "ExportTree.h" //self-include ////////////////////////////////////////////////////////// // Private Function Prototypes // ////////////////////////////////////////////////////////// void DumpFolder(FolderDataPtr FolderListHead, BookmarkDataPtr BookmarkListHead, int FolderEntryIndex, int Depth, ofstream &OutFile); ////////////////////////////////////////////////////////// // ExportTree // // // // Creates a text-tree out of the folder and bookmark // // names contained in the WAM folder heirarchy. // // // // ALGORITHM: Recursive folder dump // // // // CALLED BY: WebAddressManager // // CALLS: (LIST OF FUNCTIONS) // // // // PARAMETERS: // // FolderDataPtr FolderListHead: In - pointer to the // // head of the folder list. // // BookmarkDataPtr BookmarkListHead: In - pointer to // // the head of the bookmark list. // // const char OutputFile[]: In - the filename to which // // the tree will be written // // // // REVISIONS: DATE, REASON // // AUTHOR FOR EACH (if different) // // VERSION: x.xx // ////////////////////////////////////////////////////////// void ExportTree(FolderDataPtr FolderListHead, BookmarkDataPtr BookmarkListHead, const char OutputFileName[]){ //-- Variable Declarations -- ofstream OutFile; //The file to which the tree will be written //-- Open Files -- OutFile.open(OutputFileName); //-- Blank line -- OutFile << endl; //-- Dump Root Folder -- DumpFolder(FolderListHead, BookmarkListHead, ROOTENTRYINDEX, 0, OutFile); //-- Blank line -- OutFile << endl; //-- Closr Files -- OutFile.close(); }//end ExportTree ////////////////////////////////////////////////////////// // DumpFolder // // // // Dumps the contents of the specified folder to // // OutFile. // // // // ALGORITHM: Recursive folder dump // // // // CALLED BY: WebAddressManager // // CALLS: (LIST OF FUNCTIONS) // // // // PARAMETERS: // // FolderDataPtr FolderListHead: In - pointer to the // // head of the folder list. // // BookmarkDataPtr BookmarkListHead: In - pointer to // // the head of the bookmark list. // // int FolderEntryIndex: In - the entry index of the // // folder to dump. // // int Depth: In - the number of levels to indent the // // current output // // ofile OutFile: In & Out - the file to which the // // bookamark and folder titles will be written. // // // // REVISIONS: DATE, REASON // // AUTHOR FOR EACH (if different) // // VERSION: x.xx // ////////////////////////////////////////////////////////// void DumpFolder(FolderDataPtr FolderListHead, BookmarkDataPtr BookmarkListHead, int FolderEntryIndex, int Depth, ofstream &OutFile){ //-- Constant Declarations -- const char FOLDERLABEL[5] = {"FLD:"}; //lefthand column label for folders const char BOOKMARKLABEL[5] = {"BKM:"}; //lefthand column label for bookmarks const char INDENT[5] = {" "}; //string used to indent folders and bookmarks const char ASTERISK = '*'; //A star -- used to denote folders const char PLUS = '+'; //A plus sign -- used to denote bookmarks //-- Variable Declarations -- BookmarkDataPtr BookmarkBeingExamined; //The bookmark currently being examined FolderDataPtr FolderBeingExamined; //The folder currently being examined int ForCnt; //For-loop counter //-- Output Foldername -- FolderBeingExamined = FindFolderWithEntryIndex(FolderListHead, FolderEntryIndex); OutFile << FOLDERLABEL; for(ForCnt=0; ForCntName << ASTERISK << endl; //-- Find all bookmarks child to this folder -- BookmarkBeingExamined = FindBookmarkWithParentEntryIndex(BookmarkListHead, FolderEntryIndex); while (BookmarkBeingExamined){ //-- Output Bookmark -- OutFile << BOOKMARKLABEL; for(ForCnt=0; ForCnt<=Depth; ForCnt++) OutFile << INDENT; OutFile << PLUS << BookmarkBeingExamined->Name << endl; //-- Advance to the next bookmark in the folder -- BookmarkBeingExamined = FindBookmarkWithParentEntryIndex(BookmarkBeingExamined->LinkNext, FolderEntryIndex); }//end while-bookmark //-- Find all Folders child to this folder -- FolderBeingExamined = FindFolderWithParentEntryIndex(FolderListHead, FolderEntryIndex); while (FolderBeingExamined){ //-- Output Folders -- DumpFolder(FolderListHead, BookmarkListHead, FolderBeingExamined->EntryIndex, Depth+1, OutFile); //-- Advance to the next Folder in the folder -- FolderBeingExamined = FindFolderWithParentEntryIndex(FolderBeingExamined->LinkNext, FolderEntryIndex); }//end while-Folder }//end DumpFolder