834 checkConcept<concept::WriteMap<Node, typename Map::Value>, Map>(); |
834 checkConcept<concept::WriteMap<Node, typename Map::Value>, Map>(); |
835 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>(); |
835 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>(); |
836 if (readers.find(name) != readers.end()) { |
836 if (readers.find(name) != readers.end()) { |
837 ErrorMessage msg; |
837 ErrorMessage msg; |
838 msg << "Multiple read rule for node map: " << name; |
838 msg << "Multiple read rule for node map: " << name; |
839 throw IOParameterError(msg.message()); |
839 throw IoParameterError(msg.message()); |
840 } |
840 } |
841 readers.insert( |
841 readers.insert( |
842 make_pair(name, new _reader_bits:: |
842 make_pair(name, new _reader_bits:: |
843 MapReader<Node, Map, Reader>(map, reader))); |
843 MapReader<Node, Map, Reader>(map, reader))); |
844 return *this; |
844 return *this; |
853 NodeSetReader& skipNodeMap(std::string name, |
853 NodeSetReader& skipNodeMap(std::string name, |
854 const Reader& reader = Reader()) { |
854 const Reader& reader = Reader()) { |
855 if (readers.find(name) != readers.end()) { |
855 if (readers.find(name) != readers.end()) { |
856 ErrorMessage msg; |
856 ErrorMessage msg; |
857 msg << "Multiple read rule for node map: " << name; |
857 msg << "Multiple read rule for node map: " << name; |
858 throw IOParameterError(msg.message()); |
858 throw IoParameterError(msg.message()); |
859 } |
859 } |
860 readers.insert(make_pair(name, new _reader_bits:: |
860 readers.insert(make_pair(name, new _reader_bits:: |
861 SkipReader<Node, Reader>(reader))); |
861 SkipReader<Node, Reader>(reader))); |
862 return *this; |
862 return *this; |
863 } |
863 } |
903 for (typename MapReaders::iterator it = readers.begin(); |
903 for (typename MapReaders::iterator it = readers.begin(); |
904 it != readers.end(); ++it) { |
904 it != readers.end(); ++it) { |
905 if (!it->second->touched()) { |
905 if (!it->second->touched()) { |
906 ErrorMessage msg; |
906 ErrorMessage msg; |
907 msg << "Map not found in file: " << it->first; |
907 msg << "Map not found in file: " << it->first; |
908 throw IOParameterError(msg.message()); |
908 throw IoParameterError(msg.message()); |
909 } |
909 } |
910 } |
910 } |
911 while (getline(is, line)) { |
911 while (getline(is, line)) { |
912 Node node = graph.addNode(); |
912 Node node = graph.addNode(); |
913 std::istringstream ls(line); |
913 std::istringstream ls(line); |
919 |
919 |
920 virtual void missing() { |
920 virtual void missing() { |
921 if (readers.empty()) return; |
921 if (readers.empty()) return; |
922 ErrorMessage msg; |
922 ErrorMessage msg; |
923 msg << "NodeSet section not found in file: @nodeset " << name; |
923 msg << "NodeSet section not found in file: @nodeset " << name; |
924 throw IOParameterError(msg.message()); |
924 throw IoParameterError(msg.message()); |
925 } |
925 } |
926 |
926 |
927 public: |
927 public: |
928 |
928 |
929 /// \brief Returns true if the nodeset can give back the node by its label. |
929 /// \brief Returns true if the nodeset can give back the node by its label. |
1064 checkConcept<concept::WriteMap<Edge, typename Map::Value>, Map>(); |
1064 checkConcept<concept::WriteMap<Edge, typename Map::Value>, Map>(); |
1065 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>(); |
1065 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>(); |
1066 if (readers.find(name) != readers.end()) { |
1066 if (readers.find(name) != readers.end()) { |
1067 ErrorMessage msg; |
1067 ErrorMessage msg; |
1068 msg << "Multiple read rule for edge map: " << name; |
1068 msg << "Multiple read rule for edge map: " << name; |
1069 throw IOParameterError(msg.message()); |
1069 throw IoParameterError(msg.message()); |
1070 } |
1070 } |
1071 readers.insert( |
1071 readers.insert( |
1072 make_pair(name, new _reader_bits:: |
1072 make_pair(name, new _reader_bits:: |
1073 MapReader<Edge, Map, Reader>(map, reader))); |
1073 MapReader<Edge, Map, Reader>(map, reader))); |
1074 return *this; |
1074 return *this; |
1083 EdgeSetReader& skipEdgeMap(std::string name, |
1083 EdgeSetReader& skipEdgeMap(std::string name, |
1084 const Reader& reader = Reader()) { |
1084 const Reader& reader = Reader()) { |
1085 if (readers.find(name) != readers.end()) { |
1085 if (readers.find(name) != readers.end()) { |
1086 ErrorMessage msg; |
1086 ErrorMessage msg; |
1087 msg << "Multiple read rule for edge map: " << name; |
1087 msg << "Multiple read rule for edge map: " << name; |
1088 throw IOParameterError(msg.message()); |
1088 throw IoParameterError(msg.message()); |
1089 } |
1089 } |
1090 readers.insert(make_pair(name, new _reader_bits:: |
1090 readers.insert(make_pair(name, new _reader_bits:: |
1091 SkipReader<Edge, Reader>(reader))); |
1091 SkipReader<Edge, Reader>(reader))); |
1092 return *this; |
1092 return *this; |
1093 } |
1093 } |
1136 for (typename MapReaders::iterator it = readers.begin(); |
1136 for (typename MapReaders::iterator it = readers.begin(); |
1137 it != readers.end(); ++it) { |
1137 it != readers.end(); ++it) { |
1138 if (!it->second->touched()) { |
1138 if (!it->second->touched()) { |
1139 ErrorMessage msg; |
1139 ErrorMessage msg; |
1140 msg << "Map not found in file: " << it->first; |
1140 msg << "Map not found in file: " << it->first; |
1141 throw IOParameterError(msg.message()); |
1141 throw IoParameterError(msg.message()); |
1142 } |
1142 } |
1143 } |
1143 } |
1144 while (getline(is, line)) { |
1144 while (getline(is, line)) { |
1145 std::istringstream ls(line); |
1145 std::istringstream ls(line); |
1146 Node from = nodeLabelReader->read(ls); |
1146 Node from = nodeLabelReader->read(ls); |
1154 |
1154 |
1155 virtual void missing() { |
1155 virtual void missing() { |
1156 if (readers.empty()) return; |
1156 if (readers.empty()) return; |
1157 ErrorMessage msg; |
1157 ErrorMessage msg; |
1158 msg << "EdgeSet section not found in file: @edgeset " << name; |
1158 msg << "EdgeSet section not found in file: @edgeset " << name; |
1159 throw IOParameterError(msg.message()); |
1159 throw IoParameterError(msg.message()); |
1160 } |
1160 } |
1161 |
1161 |
1162 public: |
1162 public: |
1163 |
1163 |
1164 /// \brief Returns true if the edgeset can give back the edge by its label. |
1164 /// \brief Returns true if the edgeset can give back the edge by its label. |
1308 checkConcept<concept::WriteMap<UEdge, typename Map::Value>, Map>(); |
1308 checkConcept<concept::WriteMap<UEdge, typename Map::Value>, Map>(); |
1309 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>(); |
1309 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>(); |
1310 if (readers.find(name) != readers.end()) { |
1310 if (readers.find(name) != readers.end()) { |
1311 ErrorMessage msg; |
1311 ErrorMessage msg; |
1312 msg << "Multiple read rule for edge map: " << name; |
1312 msg << "Multiple read rule for edge map: " << name; |
1313 throw IOParameterError(msg.message()); |
1313 throw IoParameterError(msg.message()); |
1314 } |
1314 } |
1315 readers.insert( |
1315 readers.insert( |
1316 make_pair(name, new _reader_bits:: |
1316 make_pair(name, new _reader_bits:: |
1317 MapReader<UEdge, Map, Reader>(map, reader))); |
1317 MapReader<UEdge, Map, Reader>(map, reader))); |
1318 return *this; |
1318 return *this; |
1327 UEdgeSetReader& skipUEdgeMap(std::string name, |
1327 UEdgeSetReader& skipUEdgeMap(std::string name, |
1328 const Reader& reader = Reader()) { |
1328 const Reader& reader = Reader()) { |
1329 if (readers.find(name) != readers.end()) { |
1329 if (readers.find(name) != readers.end()) { |
1330 ErrorMessage msg; |
1330 ErrorMessage msg; |
1331 msg << "Multiple read rule for node map: " << name; |
1331 msg << "Multiple read rule for node map: " << name; |
1332 throw IOParameterError(msg.message()); |
1332 throw IoParameterError(msg.message()); |
1333 } |
1333 } |
1334 readers.insert(make_pair(name, new _reader_bits:: |
1334 readers.insert(make_pair(name, new _reader_bits:: |
1335 SkipReader<UEdge, Reader>(reader))); |
1335 SkipReader<UEdge, Reader>(reader))); |
1336 return *this; |
1336 return *this; |
1337 } |
1337 } |
1441 for (typename MapReaders::iterator it = readers.begin(); |
1441 for (typename MapReaders::iterator it = readers.begin(); |
1442 it != readers.end(); ++it) { |
1442 it != readers.end(); ++it) { |
1443 if (!it->second->touched()) { |
1443 if (!it->second->touched()) { |
1444 ErrorMessage msg; |
1444 ErrorMessage msg; |
1445 msg << "Map not found in file: " << it->first; |
1445 msg << "Map not found in file: " << it->first; |
1446 throw IOParameterError(msg.message()); |
1446 throw IoParameterError(msg.message()); |
1447 } |
1447 } |
1448 } |
1448 } |
1449 while (getline(is, line)) { |
1449 while (getline(is, line)) { |
1450 std::istringstream ls(line); |
1450 std::istringstream ls(line); |
1451 Node from = nodeLabelReader->read(ls); |
1451 Node from = nodeLabelReader->read(ls); |
1459 |
1459 |
1460 virtual void missing() { |
1460 virtual void missing() { |
1461 if (readers.empty()) return; |
1461 if (readers.empty()) return; |
1462 ErrorMessage msg; |
1462 ErrorMessage msg; |
1463 msg << "UEdgeSet section not found in file: @uedgeset " << name; |
1463 msg << "UEdgeSet section not found in file: @uedgeset " << name; |
1464 throw IOParameterError(msg.message()); |
1464 throw IoParameterError(msg.message()); |
1465 } |
1465 } |
1466 |
1466 |
1467 public: |
1467 public: |
1468 |
1468 |
1469 /// \brief Returns true if the edgeset can give back the edge by its label. |
1469 /// \brief Returns true if the edgeset can give back the edge by its label. |
1564 /// Add a node reader command for the NodeReader. |
1564 /// Add a node reader command for the NodeReader. |
1565 void readNode(const std::string& name, Node& item) { |
1565 void readNode(const std::string& name, Node& item) { |
1566 if (readers.find(name) != readers.end()) { |
1566 if (readers.find(name) != readers.end()) { |
1567 ErrorMessage msg; |
1567 ErrorMessage msg; |
1568 msg << "Multiple read rule for node: " << name; |
1568 msg << "Multiple read rule for node: " << name; |
1569 throw IOParameterError(msg.message()); |
1569 throw IoParameterError(msg.message()); |
1570 } |
1570 } |
1571 readers.insert(make_pair(name, _reader_bits::ItemStore<Node>(item))); |
1571 readers.insert(make_pair(name, _reader_bits::ItemStore<Node>(item))); |
1572 } |
1572 } |
1573 |
1573 |
1574 protected: |
1574 protected: |
1607 for (typename NodeReaders::iterator it = readers.begin(); |
1607 for (typename NodeReaders::iterator it = readers.begin(); |
1608 it != readers.end(); ++it) { |
1608 it != readers.end(); ++it) { |
1609 if (!it->second.touched()) { |
1609 if (!it->second.touched()) { |
1610 ErrorMessage msg; |
1610 ErrorMessage msg; |
1611 msg << "Node not found in file: " << it->first; |
1611 msg << "Node not found in file: " << it->first; |
1612 throw IOParameterError(msg.message()); |
1612 throw IoParameterError(msg.message()); |
1613 } |
1613 } |
1614 } |
1614 } |
1615 } |
1615 } |
1616 |
1616 |
1617 virtual void missing() { |
1617 virtual void missing() { |
1618 if (readers.empty()) return; |
1618 if (readers.empty()) return; |
1619 ErrorMessage msg; |
1619 ErrorMessage msg; |
1620 msg << "Nodes section not found in file: @nodes " << name; |
1620 msg << "Nodes section not found in file: @nodes " << name; |
1621 throw IOParameterError(msg.message()); |
1621 throw IoParameterError(msg.message()); |
1622 } |
1622 } |
1623 |
1623 |
1624 private: |
1624 private: |
1625 |
1625 |
1626 std::string name; |
1626 std::string name; |
1677 /// Add an edge reader command for the EdgeReader. |
1677 /// Add an edge reader command for the EdgeReader. |
1678 void readEdge(const std::string& name, Edge& item) { |
1678 void readEdge(const std::string& name, Edge& item) { |
1679 if (readers.find(name) != readers.end()) { |
1679 if (readers.find(name) != readers.end()) { |
1680 ErrorMessage msg; |
1680 ErrorMessage msg; |
1681 msg << "Multiple read rule for edge: " << name; |
1681 msg << "Multiple read rule for edge: " << name; |
1682 throw IOParameterError(msg.message()); |
1682 throw IoParameterError(msg.message()); |
1683 } |
1683 } |
1684 readers.insert(make_pair(name, _reader_bits::ItemStore<Edge>(item))); |
1684 readers.insert(make_pair(name, _reader_bits::ItemStore<Edge>(item))); |
1685 } |
1685 } |
1686 |
1686 |
1687 protected: |
1687 protected: |
1720 for (typename EdgeReaders::iterator it = readers.begin(); |
1720 for (typename EdgeReaders::iterator it = readers.begin(); |
1721 it != readers.end(); ++it) { |
1721 it != readers.end(); ++it) { |
1722 if (!it->second.touched()) { |
1722 if (!it->second.touched()) { |
1723 ErrorMessage msg; |
1723 ErrorMessage msg; |
1724 msg << "Edge not found in file: " << it->first; |
1724 msg << "Edge not found in file: " << it->first; |
1725 throw IOParameterError(msg.message()); |
1725 throw IoParameterError(msg.message()); |
1726 } |
1726 } |
1727 } |
1727 } |
1728 } |
1728 } |
1729 |
1729 |
1730 virtual void missing() { |
1730 virtual void missing() { |
1731 if (readers.empty()) return; |
1731 if (readers.empty()) return; |
1732 ErrorMessage msg; |
1732 ErrorMessage msg; |
1733 msg << "Edges section not found in file: @edges " << name; |
1733 msg << "Edges section not found in file: @edges " << name; |
1734 throw IOParameterError(msg.message()); |
1734 throw IoParameterError(msg.message()); |
1735 } |
1735 } |
1736 |
1736 |
1737 private: |
1737 private: |
1738 |
1738 |
1739 std::string name; |
1739 std::string name; |
1795 /// Add an undirected edge reader command for the UEdgeReader. |
1795 /// Add an undirected edge reader command for the UEdgeReader. |
1796 void readUEdge(const std::string& name, UEdge& item) { |
1796 void readUEdge(const std::string& name, UEdge& item) { |
1797 if (uEdgeReaders.find(name) != uEdgeReaders.end()) { |
1797 if (uEdgeReaders.find(name) != uEdgeReaders.end()) { |
1798 ErrorMessage msg; |
1798 ErrorMessage msg; |
1799 msg << "Multiple read rule for undirected edge: " << name; |
1799 msg << "Multiple read rule for undirected edge: " << name; |
1800 throw IOParameterError(msg.message()); |
1800 throw IoParameterError(msg.message()); |
1801 } |
1801 } |
1802 uEdgeReaders.insert(make_pair(name, _reader_bits:: |
1802 uEdgeReaders.insert(make_pair(name, _reader_bits:: |
1803 ItemStore<UEdge>(item))); |
1803 ItemStore<UEdge>(item))); |
1804 } |
1804 } |
1805 |
1805 |
1808 /// Add an edge reader command for the UEdgeReader. |
1808 /// Add an edge reader command for the UEdgeReader. |
1809 void readEdge(const std::string& name, Edge& item) { |
1809 void readEdge(const std::string& name, Edge& item) { |
1810 if (edgeReaders.find(name) != edgeReaders.end()) { |
1810 if (edgeReaders.find(name) != edgeReaders.end()) { |
1811 ErrorMessage msg; |
1811 ErrorMessage msg; |
1812 msg << "Multiple read rule for edge: " << name; |
1812 msg << "Multiple read rule for edge: " << name; |
1813 throw IOParameterError(msg.message()); |
1813 throw IoParameterError(msg.message()); |
1814 } |
1814 } |
1815 edgeReaders.insert(make_pair(name, _reader_bits::ItemStore<Edge>(item))); |
1815 edgeReaders.insert(make_pair(name, _reader_bits::ItemStore<Edge>(item))); |
1816 } |
1816 } |
1817 |
1817 |
1818 protected: |
1818 protected: |
1864 for (typename EdgeReaders::iterator it = edgeReaders.begin(); |
1864 for (typename EdgeReaders::iterator it = edgeReaders.begin(); |
1865 it != edgeReaders.end(); ++it) { |
1865 it != edgeReaders.end(); ++it) { |
1866 if (!it->second.touched()) { |
1866 if (!it->second.touched()) { |
1867 ErrorMessage msg; |
1867 ErrorMessage msg; |
1868 msg << "Edge not found in file: " << it->first; |
1868 msg << "Edge not found in file: " << it->first; |
1869 throw IOParameterError(msg.message()); |
1869 throw IoParameterError(msg.message()); |
1870 } |
1870 } |
1871 } |
1871 } |
1872 for (typename UEdgeReaders::iterator it = uEdgeReaders.begin(); |
1872 for (typename UEdgeReaders::iterator it = uEdgeReaders.begin(); |
1873 it != uEdgeReaders.end(); ++it) { |
1873 it != uEdgeReaders.end(); ++it) { |
1874 if (!it->second.touched()) { |
1874 if (!it->second.touched()) { |
1875 ErrorMessage msg; |
1875 ErrorMessage msg; |
1876 msg << "UEdge not found in file: " << it->first; |
1876 msg << "UEdge not found in file: " << it->first; |
1877 throw IOParameterError(msg.message()); |
1877 throw IoParameterError(msg.message()); |
1878 } |
1878 } |
1879 } |
1879 } |
1880 } |
1880 } |
1881 |
1881 |
1882 virtual void missing() { |
1882 virtual void missing() { |
1883 if (edgeReaders.empty() && uEdgeReaders.empty()) return; |
1883 if (edgeReaders.empty() && uEdgeReaders.empty()) return; |
1884 ErrorMessage msg; |
1884 ErrorMessage msg; |
1885 msg << "UEdges section not found in file: @uedges " << name; |
1885 msg << "UEdges section not found in file: @uedges " << name; |
1886 throw IOParameterError(msg.message()); |
1886 throw IoParameterError(msg.message()); |
1887 } |
1887 } |
1888 |
1888 |
1889 private: |
1889 private: |
1890 |
1890 |
1891 std::string name; |
1891 std::string name; |
1957 const Reader& reader = Reader()) { |
1957 const Reader& reader = Reader()) { |
1958 checkConcept<_reader_bits::ItemReader<Value>, Reader>(); |
1958 checkConcept<_reader_bits::ItemReader<Value>, Reader>(); |
1959 if (readers.find(name) != readers.end()) { |
1959 if (readers.find(name) != readers.end()) { |
1960 ErrorMessage msg; |
1960 ErrorMessage msg; |
1961 msg << "Multiple read rule for attribute: " << name; |
1961 msg << "Multiple read rule for attribute: " << name; |
1962 throw IOParameterError(msg.message()); |
1962 throw IoParameterError(msg.message()); |
1963 } |
1963 } |
1964 readers.insert(make_pair(name, new _reader_bits:: |
1964 readers.insert(make_pair(name, new _reader_bits:: |
1965 ValueReader<Value, Reader>(value, reader))); |
1965 ValueReader<Value, Reader>(value, reader))); |
1966 return *this; |
1966 return *this; |
1967 } |
1967 } |
1999 for (typename Readers::iterator it = readers.begin(); |
1999 for (typename Readers::iterator it = readers.begin(); |
2000 it != readers.end(); ++it) { |
2000 it != readers.end(); ++it) { |
2001 if (!it->second->touched()) { |
2001 if (!it->second->touched()) { |
2002 ErrorMessage msg; |
2002 ErrorMessage msg; |
2003 msg << "Attribute not found in file: " << it->first; |
2003 msg << "Attribute not found in file: " << it->first; |
2004 throw IOParameterError(msg.message()); |
2004 throw IoParameterError(msg.message()); |
2005 } |
2005 } |
2006 } |
2006 } |
2007 } |
2007 } |
2008 |
2008 |
2009 virtual void missing() { |
2009 virtual void missing() { |
2010 if (readers.empty()) return; |
2010 if (readers.empty()) return; |
2011 ErrorMessage msg; |
2011 ErrorMessage msg; |
2012 msg << "Attribute section not found in file: @attributes " << name; |
2012 msg << "Attribute section not found in file: @attributes " << name; |
2013 throw IOParameterError(msg.message()); |
2013 throw IoParameterError(msg.message()); |
2014 } |
2014 } |
2015 |
2015 |
2016 private: |
2016 private: |
2017 std::string name; |
2017 std::string name; |
2018 |
2018 |