Changeset 1291
- Timestamp:
- 10/24/07 16:36:57 (12 months ago)
- Location:
- trunk/src/buzelib/Utils
- Files:
-
- 2 modified
-
MachineIndex.cpp (modified) (5 diffs)
-
MachineIndex.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/buzelib/Utils/MachineIndex.cpp
r1273 r1291 19 19 // found the trims in one of the comments at http://www.codeproject.com/vcpp/stl/stdstringtrim.asp 20 20 21 IndexItem* MachineIndex::parseLine(const std::string& line ) {21 IndexItem* MachineIndex::parseLine(const std::string& line, FileReader &reader) { 22 22 if (line.length()==0) return 0; 23 23 // try to split on comma, if second part is blank, it is hidden … … 51 51 } 52 52 53 MachineMenu* MachineIndex::parseMenu(const std::string& firstLine ) {53 MachineMenu* MachineIndex::parseMenu(const std::string& firstLine, FileReader &reader) { 54 54 MachineMenu* menu=new MachineMenu(); 55 55 assert(firstLine.length()>0); … … 64 64 } else 65 65 if (line.at(0)=='/') { 66 MachineMenu* childMenu=parseMenu(line );66 MachineMenu* childMenu=parseMenu(line, reader); 67 67 if (childMenu) 68 68 menu->append(childMenu); 69 69 } else { 70 IndexItem* item=parseLine(line );70 IndexItem* item=parseLine(line, reader); 71 71 if (item) { 72 72 menu->append(item); … … 78 78 79 79 void MachineIndex::open(const char* fn) { 80 FileReader reader; 81 string line; 82 80 83 if (!reader.open(fn)) return ; 81 string line;82 84 while (!reader.eof()) { 83 85 //cout << reader.readLine() << endl; … … 89 91 } else 90 92 if (line.at(0)=='/') { 91 item=parseMenu(line); 92 } else 93 item=parseLine(line); 93 item=parseMenu(line, reader); 94 } else 95 if (line.at(0) == '#') { 96 const char *str; 97 98 str = line.c_str(); 99 if(str && strlen(str) > 15 && !strncmp(str, "# buze-include ", 15)) 100 { 101 open(str + 15); 102 } 103 item=0; 104 } else 105 item=parseLine(line, reader); 94 106 95 107 if (item) -
trunk/src/buzelib/Utils/MachineIndex.h
r1273 r1291 50 50 51 51 class MachineIndex { 52 FileReader reader;52 // FileReader reader; 53 53 FileWriter writer; 54 54 // std::stack<IndexItem*> currentMenu; … … 57 57 MachineMenu root; 58 58 59 IndexItem* parseLine(const std::string& line );60 MachineMenu* parseMenu(const std::string& firstLine );59 IndexItem* parseLine(const std::string& line, FileReader &reader); 60 MachineMenu* parseMenu(const std::string& firstLine, FileReader &reader); 61 61 void open(const char* fn); 62 62
