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

Comparing branches/new_design/OOPSE-4/src/io/SectionParserManager.cpp (file contents):
Revision 1765 by tim, Mon Nov 22 20:55:52 2004 UTC vs.
Revision 1840 by tim, Fri Dec 3 00:26:07 2004 UTC

# Line 24 | Line 24
24   */
25  
26   #include "io/SectionParserManager.hpp"
27 + #include "utils/Trim.hpp"
28  
29   namespace oopse {
30  
31   SectionParserManager::~SectionParserManager() {
32      SectionParserManager::iterator i;
33      for (i = sectionParsers_.begin(); i != sectionParsers_.end(); ++i) {
34 <        delete (i->sp);
34 >        delete (i->sectionParser);
35      }
36      sectionParsers_.clear();
37   }
38  
39 < void SectionParserManager::parse(ifstrstream& input, ForceField& ff) {
39 > void SectionParserManager::parse(std::istream& input, ForceField& ff) {
40  
41      //reset active flags
42      SectionParserManager::iterator i;
# Line 49 | Line 50 | void SectionParserManager::parse(ifstrstream& input, F
50      //scan through the input stream and find section names        
51      while(input.getline(buffer, bufferSize)) {
52          ++lineNo;
53 <        line = LeftTrim(buffer);
54 <
53 >        
54 >        std::string line = trimLeftCopy(buffer);
55          //a line begins with "//" is comment
56          if ( line.empty() || (line.size() >= 2 && line[0] == '/' && line[1] == '/')) {
57              continue;
# Line 67 | Line 68 | void SectionParserManager::parse(ifstrstream& input, F
68  
69                  std::string section = tokenizer.nextToken();
70  
71 <                i = std::find_if(sectionParsers_.begin(), sectionParsers_.end(), predict);
71 >                i = std::find_if(sectionParsers_.begin(), sectionParsers_.end(), SameSectionParserFunctor(section));
72                  if (i == sectionParsers_.end()){
73                      //can not find corresponding section parser
74                      std::cerr << "Can not find corresponding section parser for section: " << section << std::endl;
75                  } else {
76                      i->isActive = true;
77                      i->lineNo = lineNo;
78 <                    i->offset = input->tellg();
78 >                    i->offset = input.tellg();
79                  }
80                  
81              }
# Line 86 | Line 87 | void SectionParserManager::parse(ifstrstream& input, F
87      //invoke parser
88      for (i = sectionParsers_.begin(); i != sectionParsers_.end(); ++i) {
89          if (i->isActive) {
90 <            input->seekg(i->offset);
90 >            input.seekg(i->offset);
91              (i->sectionParser)->parse(input, ff, i->lineNo);
92          }
93      }
# Line 114 | Line 115 | void SectionParserManager::push_front(SectionParser* s
115      context.offset = 0;
116      context.isActive = false;
117  
118 +    sectionParsers_.push_front(context);
119   }
120  
121   void SectionParserManager::push_back(SectionParser* sp) {
# Line 136 | Line 138 | void SectionParserManager::push_back(SectionParser* sp
138      context.offset = 0;
139      context.isActive = false;
140  
141 +    sectionParsers_.push_back(context);
142 +
143   }
144  
145   void SectionParserManager::insert(SectionParser* sp, int priority) {
# Line 171 | Line 175 | iterator SectionParserManager::findSectionParser(const
175   }
176  
177  
178 < iterator SectionParserManager::findSectionParser(const std::string& sectionName) {
178 > SectionParserManager::iterator SectionParserManager::findSectionParser(const std::string& sectionName) {
179      SectionParserManager::iterator i;
180      for (i = sectionParsers_.begin(); i != sectionParsers_.end(); ++i) {
181          if (i->sectionParser->getSectionName() == sectionName) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines