COIN-OR::LEMON - Graph Library

Changeset 2460:3c347c306703 in lemon-0.x for lemon/lemon_reader.h


Ignore:
Timestamp:
07/26/07 14:18:02 (17 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3298
Message:

Correction in the line numbering method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lemon_reader.h

    r2416 r2460  
    617617        return EOF;
    618618      }
     619
     620    public:
     621
     622      int line_num() const {
     623        int r = _num;
     624        for (char_type* p = gptr(); p != egptr(); ++p) {
     625          if (*p == '\n') --r;
     626        }
     627        return r;
     628      }
     629
    619630    };
    620631
     
    701712      int line_num = 0;
    702713      std::string line;
    703       try {
    704         SectionReaders::iterator it;
    705         while ((++line_num, getline(*is, line)) && line.find("@end") != 0) {
    706           for (it = readers.begin(); it != readers.end(); ++it) {
    707             if (it->first->header(line)) {
    708               it->second = true;
    709               char buf[2048];
    710               FilterStreamBuf buffer(*is, line_num);
     714     
     715      SectionReaders::iterator it;
     716      while ((++line_num, getline(*is, line)) && line.find("@end") != 0) {
     717        for (it = readers.begin(); it != readers.end(); ++it) {
     718          if (it->first->header(line)) {
     719            it->second = true;
     720            char buf[2048];
     721            FilterStreamBuf buffer(*is, line_num);
     722
     723            try {
    711724              buffer.pubsetbuf(buf, sizeof(buf));
    712725              std::istream ss(&buffer);
    713726              it->first->read(ss);
    714727              break;
    715             }
     728            } catch (DataFormatError& error) {
     729              error.line(buffer.line_num());
     730              throw;
     731            }   
    716732          }
    717733        }
    718         for (it = readers.begin(); it != readers.end(); ++it) {
    719           if (!it->second) {
    720             it->first->missing();
    721           }
    722         }
    723       } catch (DataFormatError& error) {
    724         error.line(line_num);
    725         throw;
    726       }
     734      }
     735      for (it = readers.begin(); it != readers.end(); ++it) {
     736        if (!it->second) {
     737          try {
     738            it->first->missing();
     739          } catch (DataFormatError& error) {
     740            error.line(line_num);
     741            throw;
     742          }     
     743        }
     744      }
    727745    }
    728746
Note: See TracChangeset for help on using the changeset viewer.