Changeset 2000:ebcc93ead7da in lemon-0.x
- Timestamp:
- 03/06/06 18:32:35 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2610
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/lemon_reader.h
r1997 r2000 652 652 /// It reads the content of the section. 653 653 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() {}; 654 659 }; 655 660 … … 685 690 686 691 void attach(SectionReader& reader) { 687 readers.push_back( &reader);692 readers.push_back(std::make_pair(&reader, false)); 688 693 } 689 694 … … 696 701 std::string line; 697 702 try { 703 SectionReaders::iterator it; 698 704 while ((++line_num, getline(*is, line)) && line.find("@end") != 0) { 699 SectionReaders::iterator it;700 705 for (it = readers.begin(); it != readers.end(); ++it) { 701 if ((*it)->header(line)) { 706 if (it->first->header(line)) { 707 it->second = true; 702 708 char buf[2048]; 703 709 FilterStreamBuf buffer(*is, line_num); 704 710 buffer.pubsetbuf(buf, sizeof(buf)); 705 711 std::istream is(&buffer); 706 (*it)->read(is);712 it->first->read(is); 707 713 break; 708 714 } 709 715 } 710 716 } 717 for (it = readers.begin(); it != readers.end(); ++it) { 718 if (!it->second) { 719 it->first->missing(); 720 } 721 } 711 722 } catch (DataFormatError& error) { 712 723 error.line(line_num); … … 721 732 bool own_is; 722 733 723 typedef std::vector< SectionReader*> SectionReaders;734 typedef std::vector<std::pair<SectionReader*, bool> > SectionReaders; 724 735 SectionReaders readers; 725 736 … … 905 916 } 906 917 } 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()); 907 925 } 908 926 … … 1135 1153 } 1136 1154 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 1137 1162 public: 1138 1163 … … 1431 1456 } 1432 1457 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 1433 1465 public: 1434 1466 … … 1580 1612 } 1581 1613 } 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 } 1582 1621 1583 1622 private: … … 1685 1724 } 1686 1725 } 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()); 1687 1733 } 1688 1734 … … 1831 1877 } 1832 1878 } 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 } 1833 1886 1834 1887 private: … … 1951 2004 } 1952 2005 } 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 } 1953 2013 1954 2014 private: -
test/dijkstra_test.lgf
r1901 r2000 1001 1001 1 1002 1002 0 1003 @edgeset 1003 @edgeset 1004 1004 label capacity 1005 1005 75 377 6906 27
Note: See TracChangeset
for help on using the changeset viewer.