ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/io/SectionParser.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/io/SectionParser.cpp (file contents):
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC vs.
Revision 2211 by chrisfen, Thu Apr 21 14:12:19 2005 UTC

# Line 1 | Line 1
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
# Line 43 | Line 43 | void SectionParser::parse(std::istream& input, ForceFi
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 <        /**@todo */
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 >      // let's also call lines starting with # and ! as comments
55 >      if (isEndSection(line)) {
56 >        break;
57 >      } else if ( line.empty() ||
58 >                  (line.size() >= 2 && line[0] == '/' && line[1] == '/') ||
59 >                  (line.size() >= 1 && line[0] == '#') ||
60 >                  (line.size() >= 1 && line[0] == '!') ) {
61 >        continue;
62 >      } else {
63 >        parseLine(ff, line, lineNo);
64 >      }
65      }
66 < }
67 <
68 < bool SectionParser::isEndSection(const std::string& line) {
66 >  }
67 >  
68 >  bool SectionParser::isEndSection(const std::string& line) {
69      StringTokenizer tokenizer(line);
70 <
70 >    
71      if (tokenizer.countTokens() >= 2) {
72 <        std::string keyword = tokenizer.nextToken();
73 <
74 <        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 <        }
80 <        
81 <    }else {
72 >      std::string keyword = tokenizer.nextToken();
73 >      
74 >      if (keyword != "end"){
75          return false;
76 +      }
77 +      
78 +      std::string section = tokenizer.nextToken();
79 +      if (section == sectionName_) {
80 +        return true;
81 +      }else {
82 +        return false;
83 +      }
84 +      
85 +    }else {
86 +      return false;
87      }
88 <        
89 < }
88 >    
89 >  }
90  
91   }//namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines