COIN-OR::LEMON - Graph Library

Changeset 2000:ebcc93ead7da in lemon-0.x


Ignore:
Timestamp:
03/06/06 18:32:35 (18 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2610
Message:

Checking missing section reader

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/lemon_reader.h

    r1997 r2000  
    652652      /// It reads the content of the section.
    653653      virtual void read(std::istream& is) = 0;
     654
     655      /// \brief The given section missing in the file.
     656      ///
     657      /// The given section missing in the file.
     658      virtual void missing() {};
    654659    };
    655660
     
    685690
    686691    void attach(SectionReader& reader) {
    687       readers.push_back(&reader);
     692      readers.push_back(std::make_pair(&reader, false));
    688693    }
    689694
     
    696701      std::string line;
    697702      try {
     703        SectionReaders::iterator it;
    698704        while ((++line_num, getline(*is, line)) && line.find("@end") != 0) {
    699           SectionReaders::iterator it;
    700705          for (it = readers.begin(); it != readers.end(); ++it) {
    701             if ((*it)->header(line)) {
     706            if (it->first->header(line)) {
     707              it->second = true;
    702708              char buf[2048];
    703709              FilterStreamBuf buffer(*is, line_num);
    704710              buffer.pubsetbuf(buf, sizeof(buf));
    705711              std::istream is(&buffer);
    706               (*it)->read(is);
     712              it->first->read(is);
    707713              break;
    708714            }
    709715          }
    710716        }
     717        for (it = readers.begin(); it != readers.end(); ++it) {
     718          if (!it->second) {
     719            it->first->missing();
     720          }
     721        }
    711722      } catch (DataFormatError& error) {
    712723        error.line(line_num);
     
    721732    bool own_is;
    722733
    723     typedef std::vector<SectionReader*> SectionReaders;
     734    typedef std::vector<std::pair<SectionReader*, bool> > SectionReaders;
    724735    SectionReaders readers;
    725736
     
    905916        }
    906917      }
     918    }
     919
     920    virtual void missing() {
     921      if (readers.empty()) return;
     922      ErrorMessage msg;
     923      msg << "NodeSet section not found in file: " << name;
     924      throw IOParameterError(msg.message());
    907925    }
    908926
     
    11351153    }
    11361154
     1155    virtual void missing() {
     1156      if (readers.empty()) return;
     1157      ErrorMessage msg;
     1158      msg << "EdgeSet section not found in file: " << name;
     1159      throw IOParameterError(msg.message());
     1160    }
     1161
    11371162  public:
    11381163
     
    14311456    }
    14321457
     1458    virtual void missing() {
     1459      if (readers.empty()) return;
     1460      ErrorMessage msg;
     1461      msg << "UEdgeSet section not found in file: " << name;
     1462      throw IOParameterError(msg.message());
     1463    }
     1464
    14331465  public:
    14341466
     
    15801612      }
    15811613    }
     1614
     1615    virtual void missing() {
     1616      if (readers.empty()) return;
     1617      ErrorMessage msg;
     1618      msg << "Nodes section not found in file: " << name;
     1619      throw IOParameterError(msg.message());
     1620    }
    15821621   
    15831622  private:
     
    16851724        }
    16861725      }
     1726    }
     1727
     1728    virtual void missing() {
     1729      if (readers.empty()) return;
     1730      ErrorMessage msg;
     1731      msg << "Edges section not found in file: " << name;
     1732      throw IOParameterError(msg.message());
    16871733    }
    16881734   
     
    18311877      }
    18321878    }
     1879
     1880    virtual void missing() {
     1881      if (edgeReaders.empty() && uEdgeReaders.empty()) return;
     1882      ErrorMessage msg;
     1883      msg << "UEdges section not found in file: " << name;
     1884      throw IOParameterError(msg.message());
     1885    }
    18331886   
    18341887  private:
     
    19512004      }
    19522005    }   
     2006
     2007    virtual void missing() {
     2008      if (readers.empty()) return;
     2009      ErrorMessage msg;
     2010      msg << "Attribute section not found in file: " << name;
     2011      throw IOParameterError(msg.message());
     2012    }
    19532013
    19542014  private:
  • test/dijkstra_test.lgf

    r1901 r2000  
    100110011       
    100210020       
    1003 @edgeset
     1003@edgeset 
    10041004                label   capacity       
    1005100575      377     6906    27     
Note: See TracChangeset for help on using the changeset viewer.