| 1 | 
< | 
 /* | 
| 1 | 
> | 
/* | 
| 2 | 
  | 
 * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. | 
| 3 | 
  | 
 * | 
| 4 | 
  | 
 * The University of Notre Dame grants you ("Licensee") a | 
| 43 | 
  | 
#include "utils/Trim.hpp" | 
| 44 | 
  | 
namespace oopse { | 
| 45 | 
  | 
 | 
| 46 | 
< | 
void SectionParser::parse(std::istream& input, ForceField& ff, int lineNo) { | 
| 46 | 
> | 
  void SectionParser::parse(std::istream& input, ForceField& ff, int lineNo) { | 
| 47 | 
  | 
    const int bufferSize = 65535; | 
| 48 | 
  | 
    char buffer[bufferSize]; | 
| 49 | 
  | 
    std::string line; | 
| 50 | 
  | 
    while(input.getline(buffer, bufferSize)) { | 
| 51 | 
< | 
        ++lineNo; | 
| 52 | 
< | 
        line = trimLeftCopy(buffer); | 
| 53 | 
< | 
        //a line begins with "//" is comment | 
| 54 | 
< | 
        if (isEndSection(line)) { | 
| 55 | 
< | 
            break; | 
| 56 | 
< | 
        } else if ( line.empty() || (line.size() >= 2 && line[0] == '/' && line[1] == '/')) { | 
| 57 | 
< | 
            continue; | 
| 58 | 
< | 
        } else { | 
| 59 | 
< | 
            parseLine(ff, line, lineNo); | 
| 60 | 
< | 
        } | 
| 51 | 
> | 
      ++lineNo; | 
| 52 | 
> | 
      line = trimLeftCopy(buffer); | 
| 53 | 
> | 
      //a line begins with "//" is comment | 
| 54 | 
> | 
      if (isEndSection(line)) { | 
| 55 | 
> | 
        break; | 
| 56 | 
> | 
      } else if ( line.empty() || (line.size() >= 2 && line[0] == '/' && line[1] == '/')) { | 
| 57 | 
> | 
        continue; | 
| 58 | 
> | 
      } else { | 
| 59 | 
> | 
        parseLine(ff, line, lineNo); | 
| 60 | 
> | 
      } | 
| 61 | 
  | 
    } | 
| 62 | 
< | 
} | 
| 62 | 
> | 
  } | 
| 63 | 
  | 
 | 
| 64 | 
< | 
bool SectionParser::isEndSection(const std::string& line) { | 
| 64 | 
> | 
  bool SectionParser::isEndSection(const std::string& line) { | 
| 65 | 
  | 
    StringTokenizer tokenizer(line); | 
| 66 | 
  | 
 | 
| 67 | 
  | 
    if (tokenizer.countTokens() >= 2) { | 
| 68 | 
< | 
        std::string keyword = tokenizer.nextToken(); | 
| 68 | 
> | 
      std::string keyword = tokenizer.nextToken(); | 
| 69 | 
  | 
 | 
| 70 | 
< | 
        if (keyword != "end"){ | 
| 71 | 
< | 
            return false; | 
| 72 | 
< | 
        }  | 
| 70 | 
> | 
      if (keyword != "end"){ | 
| 71 | 
> | 
        return false; | 
| 72 | 
> | 
      }  | 
| 73 | 
  | 
 | 
| 74 | 
< | 
        std::string section = tokenizer.nextToken(); | 
| 75 | 
< | 
        if (section == sectionName_) { | 
| 76 | 
< | 
            return true; | 
| 77 | 
< | 
        }else { | 
| 78 | 
< | 
            return false; | 
| 79 | 
< | 
        } | 
| 74 | 
> | 
      std::string section = tokenizer.nextToken(); | 
| 75 | 
> | 
      if (section == sectionName_) { | 
| 76 | 
> | 
        return true; | 
| 77 | 
> | 
      }else { | 
| 78 | 
> | 
        return false; | 
| 79 | 
> | 
      } | 
| 80 | 
  | 
         | 
| 81 | 
  | 
    }else { | 
| 82 | 
< | 
        return false; | 
| 82 | 
> | 
      return false; | 
| 83 | 
  | 
    } | 
| 84 | 
  | 
         | 
| 85 | 
< | 
} | 
| 85 | 
> | 
  } | 
| 86 | 
  | 
 | 
| 87 | 
  | 
}//namespace oopse |