Changeset 1291

Show
Ignore:
Timestamp:
10/24/07 16:36:57 (12 months ago)
Author:
calvin
Message:

zoners patch: index.txt supports includes

Location:
trunk/src/buzelib/Utils
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/buzelib/Utils/MachineIndex.cpp

    r1273 r1291  
    1919// found the trims in one of the comments at http://www.codeproject.com/vcpp/stl/stdstringtrim.asp 
    2020 
    21 IndexItem* MachineIndex::parseLine(const std::string& line) { 
     21IndexItem* MachineIndex::parseLine(const std::string& line, FileReader &reader) { 
    2222        if (line.length()==0) return 0; 
    2323        // try to split on comma, if second part is blank, it is hidden 
     
    5151} 
    5252 
    53 MachineMenu* MachineIndex::parseMenu(const std::string& firstLine) { 
     53MachineMenu* MachineIndex::parseMenu(const std::string& firstLine, FileReader &reader) { 
    5454        MachineMenu* menu=new MachineMenu(); 
    5555        assert(firstLine.length()>0); 
     
    6464                } else 
    6565                if (line.at(0)=='/') { 
    66                         MachineMenu* childMenu=parseMenu(line); 
     66                        MachineMenu* childMenu=parseMenu(line, reader); 
    6767                        if (childMenu) 
    6868                                menu->append(childMenu); 
    6969                } else { 
    70                         IndexItem* item=parseLine(line); 
     70                        IndexItem* item=parseLine(line, reader); 
    7171                        if (item) { 
    7272                                menu->append(item); 
     
    7878 
    7979void MachineIndex::open(const char* fn) { 
     80        FileReader reader; 
     81        string line; 
     82 
    8083        if (!reader.open(fn)) return ; 
    81         string line; 
    8284        while (!reader.eof()) { 
    8385                //cout << reader.readLine() << endl; 
     
    8991                } else 
    9092                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); 
    94106 
    95107                if (item) 
  • trunk/src/buzelib/Utils/MachineIndex.h

    r1273 r1291  
    5050 
    5151class MachineIndex { 
    52         FileReader reader; 
     52//      FileReader reader; 
    5353        FileWriter writer; 
    5454//      std::stack<IndexItem*> currentMenu; 
     
    5757        MachineMenu root; 
    5858 
    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); 
    6161        void open(const char* fn); 
    6262