514 DigraphReader(const std::string& fn, Digraph& digraph) |
514 DigraphReader(const std::string& fn, Digraph& digraph) |
515 : _is(new std::ifstream(fn.c_str())), local_is(true), |
515 : _is(new std::ifstream(fn.c_str())), local_is(true), |
516 _filename(fn), _digraph(digraph), |
516 _filename(fn), _digraph(digraph), |
517 _use_nodes(false), _use_arcs(false), |
517 _use_nodes(false), _use_arcs(false), |
518 _skip_nodes(false), _skip_arcs(false) { |
518 _skip_nodes(false), _skip_arcs(false) { |
519 if (!(*_is)) throw IoError(fn, "Cannot open file"); |
519 if (!(*_is)) throw IoError("Cannot open file", fn); |
520 } |
520 } |
521 |
521 |
522 /// \brief Constructor |
522 /// \brief Constructor |
523 /// |
523 /// |
524 /// Construct a directed graph reader, which reads from the given |
524 /// Construct a directed graph reader, which reads from the given |
526 DigraphReader(const char* fn, Digraph& digraph) |
526 DigraphReader(const char* fn, Digraph& digraph) |
527 : _is(new std::ifstream(fn)), local_is(true), |
527 : _is(new std::ifstream(fn)), local_is(true), |
528 _filename(fn), _digraph(digraph), |
528 _filename(fn), _digraph(digraph), |
529 _use_nodes(false), _use_arcs(false), |
529 _use_nodes(false), _use_arcs(false), |
530 _skip_nodes(false), _skip_arcs(false) { |
530 _skip_nodes(false), _skip_arcs(false) { |
531 if (!(*_is)) throw IoError(fn, "Cannot open file"); |
531 if (!(*_is)) throw IoError("Cannot open file", fn); |
532 } |
532 } |
533 |
533 |
534 /// \brief Destructor |
534 /// \brief Destructor |
535 ~DigraphReader() { |
535 ~DigraphReader() { |
536 for (typename NodeMaps::iterator it = _node_maps.begin(); |
536 for (typename NodeMaps::iterator it = _node_maps.begin(); |
877 for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) { |
877 for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) { |
878 std::map<std::string, int>::iterator jt = |
878 std::map<std::string, int>::iterator jt = |
879 maps.find(_node_maps[i].first); |
879 maps.find(_node_maps[i].first); |
880 if (jt == maps.end()) { |
880 if (jt == maps.end()) { |
881 std::ostringstream msg; |
881 std::ostringstream msg; |
882 msg << "Map not found in file: " << _node_maps[i].first; |
882 msg << "Map not found: " << _node_maps[i].first; |
883 throw FormatError(msg.str()); |
883 throw FormatError(msg.str()); |
884 } |
884 } |
885 map_index[i] = jt->second; |
885 map_index[i] = jt->second; |
886 } |
886 } |
887 |
887 |
906 msg << "Column not found (" << i + 1 << ")"; |
906 msg << "Column not found (" << i + 1 << ")"; |
907 throw FormatError(msg.str()); |
907 throw FormatError(msg.str()); |
908 } |
908 } |
909 } |
909 } |
910 if (line >> std::ws >> c) |
910 if (line >> std::ws >> c) |
911 throw FormatError("Extra character on the end of line"); |
911 throw FormatError("Extra character at the end of line"); |
912 |
912 |
913 Node n; |
913 Node n; |
914 if (!_use_nodes) { |
914 if (!_use_nodes) { |
915 n = _digraph.addNode(); |
915 n = _digraph.addNode(); |
916 if (label_index != -1) |
916 if (label_index != -1) |
917 _node_index.insert(std::make_pair(tokens[label_index], n)); |
917 _node_index.insert(std::make_pair(tokens[label_index], n)); |
918 } else { |
918 } else { |
919 if (label_index == -1) |
919 if (label_index == -1) |
920 throw FormatError("Label map not found in file"); |
920 throw FormatError("Label map not found"); |
921 typename std::map<std::string, Node>::iterator it = |
921 typename std::map<std::string, Node>::iterator it = |
922 _node_index.find(tokens[label_index]); |
922 _node_index.find(tokens[label_index]); |
923 if (it == _node_index.end()) { |
923 if (it == _node_index.end()) { |
924 std::ostringstream msg; |
924 std::ostringstream msg; |
925 msg << "Node with label not found: " << tokens[label_index]; |
925 msg << "Node with label not found: " << tokens[label_index]; |
970 for (int i = 0; i < static_cast<int>(_arc_maps.size()); ++i) { |
970 for (int i = 0; i < static_cast<int>(_arc_maps.size()); ++i) { |
971 std::map<std::string, int>::iterator jt = |
971 std::map<std::string, int>::iterator jt = |
972 maps.find(_arc_maps[i].first); |
972 maps.find(_arc_maps[i].first); |
973 if (jt == maps.end()) { |
973 if (jt == maps.end()) { |
974 std::ostringstream msg; |
974 std::ostringstream msg; |
975 msg << "Map not found in file: " << _arc_maps[i].first; |
975 msg << "Map not found: " << _arc_maps[i].first; |
976 throw FormatError(msg.str()); |
976 throw FormatError(msg.str()); |
977 } |
977 } |
978 map_index[i] = jt->second; |
978 map_index[i] = jt->second; |
979 } |
979 } |
980 |
980 |
1008 msg << "Column not found (" << i + 1 << ")"; |
1008 msg << "Column not found (" << i + 1 << ")"; |
1009 throw FormatError(msg.str()); |
1009 throw FormatError(msg.str()); |
1010 } |
1010 } |
1011 } |
1011 } |
1012 if (line >> std::ws >> c) |
1012 if (line >> std::ws >> c) |
1013 throw FormatError("Extra character on the end of line"); |
1013 throw FormatError("Extra character at the end of line"); |
1014 |
1014 |
1015 Arc a; |
1015 Arc a; |
1016 if (!_use_arcs) { |
1016 if (!_use_arcs) { |
1017 |
1017 |
1018 typename NodeIndex::iterator it; |
1018 typename NodeIndex::iterator it; |
1036 a = _digraph.addArc(source, target); |
1036 a = _digraph.addArc(source, target); |
1037 if (label_index != -1) |
1037 if (label_index != -1) |
1038 _arc_index.insert(std::make_pair(tokens[label_index], a)); |
1038 _arc_index.insert(std::make_pair(tokens[label_index], a)); |
1039 } else { |
1039 } else { |
1040 if (label_index == -1) |
1040 if (label_index == -1) |
1041 throw FormatError("Label map not found in file"); |
1041 throw FormatError("Label map not found"); |
1042 typename std::map<std::string, Arc>::iterator it = |
1042 typename std::map<std::string, Arc>::iterator it = |
1043 _arc_index.find(tokens[label_index]); |
1043 _arc_index.find(tokens[label_index]); |
1044 if (it == _arc_index.end()) { |
1044 if (it == _arc_index.end()) { |
1045 std::ostringstream msg; |
1045 std::ostringstream msg; |
1046 msg << "Arc with label not found: " << tokens[label_index]; |
1046 msg << "Arc with label not found: " << tokens[label_index]; |
1071 if (!_reader_bits::readToken(line, attr)) |
1071 if (!_reader_bits::readToken(line, attr)) |
1072 throw FormatError("Attribute name not found"); |
1072 throw FormatError("Attribute name not found"); |
1073 if (!_reader_bits::readToken(line, token)) |
1073 if (!_reader_bits::readToken(line, token)) |
1074 throw FormatError("Attribute value not found"); |
1074 throw FormatError("Attribute value not found"); |
1075 if (line >> c) |
1075 if (line >> c) |
1076 throw FormatError("Extra character on the end of line"); |
1076 throw FormatError("Extra character at the end of line"); |
1077 |
1077 |
1078 { |
1078 { |
1079 std::set<std::string>::iterator it = read_attr.find(attr); |
1079 std::set<std::string>::iterator it = read_attr.find(attr); |
1080 if (it != read_attr.end()) { |
1080 if (it != read_attr.end()) { |
1081 std::ostringstream msg; |
1081 std::ostringstream msg; |
1082 msg << "Multiple occurence of attribute " << attr; |
1082 msg << "Multiple occurence of attribute: " << attr; |
1083 throw FormatError(msg.str()); |
1083 throw FormatError(msg.str()); |
1084 } |
1084 } |
1085 read_attr.insert(attr); |
1085 read_attr.insert(attr); |
1086 } |
1086 } |
1087 |
1087 |
1099 } |
1099 } |
1100 for (typename Attributes::iterator it = _attributes.begin(); |
1100 for (typename Attributes::iterator it = _attributes.begin(); |
1101 it != _attributes.end(); ++it) { |
1101 it != _attributes.end(); ++it) { |
1102 if (read_attr.find(it->first) == read_attr.end()) { |
1102 if (read_attr.find(it->first) == read_attr.end()) { |
1103 std::ostringstream msg; |
1103 std::ostringstream msg; |
1104 msg << "Attribute not found in file: " << it->first; |
1104 msg << "Attribute not found: " << it->first; |
1105 throw FormatError(msg.str()); |
1105 throw FormatError(msg.str()); |
1106 } |
1106 } |
1107 } |
1107 } |
1108 } |
1108 } |
1109 |
1109 |
1115 /// \brief Start the batch processing |
1115 /// \brief Start the batch processing |
1116 /// |
1116 /// |
1117 /// This function starts the batch processing |
1117 /// This function starts the batch processing |
1118 void run() { |
1118 void run() { |
1119 LEMON_ASSERT(_is != 0, "This reader assigned to an other reader"); |
1119 LEMON_ASSERT(_is != 0, "This reader assigned to an other reader"); |
1120 if (!*_is) { |
|
1121 throw FormatError("Cannot find file"); |
|
1122 } |
|
1123 |
1120 |
1124 bool nodes_done = _skip_nodes; |
1121 bool nodes_done = _skip_nodes; |
1125 bool arcs_done = _skip_arcs; |
1122 bool arcs_done = _skip_arcs; |
1126 bool attributes_done = false; |
1123 bool attributes_done = false; |
1127 |
1124 |
1136 line >> c; |
1133 line >> c; |
1137 _reader_bits::readToken(line, section); |
1134 _reader_bits::readToken(line, section); |
1138 _reader_bits::readToken(line, caption); |
1135 _reader_bits::readToken(line, caption); |
1139 |
1136 |
1140 if (line >> c) |
1137 if (line >> c) |
1141 throw FormatError("Extra character on the end of line"); |
1138 throw FormatError("Extra character at the end of line"); |
1142 |
1139 |
1143 if (section == "nodes" && !nodes_done) { |
1140 if (section == "nodes" && !nodes_done) { |
1144 if (_nodes_caption.empty() || _nodes_caption == caption) { |
1141 if (_nodes_caption.empty() || _nodes_caption == caption) { |
1145 readNodes(); |
1142 readNodes(); |
1146 nodes_done = true; |
1143 nodes_done = true; |
1306 GraphReader(const std::string& fn, Graph& graph) |
1303 GraphReader(const std::string& fn, Graph& graph) |
1307 : _is(new std::ifstream(fn.c_str())), local_is(true), |
1304 : _is(new std::ifstream(fn.c_str())), local_is(true), |
1308 _filename(fn), _graph(graph), |
1305 _filename(fn), _graph(graph), |
1309 _use_nodes(false), _use_edges(false), |
1306 _use_nodes(false), _use_edges(false), |
1310 _skip_nodes(false), _skip_edges(false) { |
1307 _skip_nodes(false), _skip_edges(false) { |
1311 if (!(*_is)) throw IoError(fn, "Cannot open file"); |
1308 if (!(*_is)) throw IoError("Cannot open file", fn); |
1312 } |
1309 } |
1313 |
1310 |
1314 /// \brief Constructor |
1311 /// \brief Constructor |
1315 /// |
1312 /// |
1316 /// Construct an undirected graph reader, which reads from the given |
1313 /// Construct an undirected graph reader, which reads from the given |
1318 GraphReader(const char* fn, Graph& graph) |
1315 GraphReader(const char* fn, Graph& graph) |
1319 : _is(new std::ifstream(fn)), local_is(true), |
1316 : _is(new std::ifstream(fn)), local_is(true), |
1320 _filename(fn), _graph(graph), |
1317 _filename(fn), _graph(graph), |
1321 _use_nodes(false), _use_edges(false), |
1318 _use_nodes(false), _use_edges(false), |
1322 _skip_nodes(false), _skip_edges(false) { |
1319 _skip_nodes(false), _skip_edges(false) { |
1323 if (!(*_is)) throw IoError(fn, "Cannot open file"); |
1320 if (!(*_is)) throw IoError("Cannot open file", fn); |
1324 } |
1321 } |
1325 |
1322 |
1326 /// \brief Destructor |
1323 /// \brief Destructor |
1327 ~GraphReader() { |
1324 ~GraphReader() { |
1328 for (typename NodeMaps::iterator it = _node_maps.begin(); |
1325 for (typename NodeMaps::iterator it = _node_maps.begin(); |
1713 for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) { |
1710 for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) { |
1714 std::map<std::string, int>::iterator jt = |
1711 std::map<std::string, int>::iterator jt = |
1715 maps.find(_node_maps[i].first); |
1712 maps.find(_node_maps[i].first); |
1716 if (jt == maps.end()) { |
1713 if (jt == maps.end()) { |
1717 std::ostringstream msg; |
1714 std::ostringstream msg; |
1718 msg << "Map not found in file: " << _node_maps[i].first; |
1715 msg << "Map not found: " << _node_maps[i].first; |
1719 throw FormatError(msg.str()); |
1716 throw FormatError(msg.str()); |
1720 } |
1717 } |
1721 map_index[i] = jt->second; |
1718 map_index[i] = jt->second; |
1722 } |
1719 } |
1723 |
1720 |
1742 msg << "Column not found (" << i + 1 << ")"; |
1739 msg << "Column not found (" << i + 1 << ")"; |
1743 throw FormatError(msg.str()); |
1740 throw FormatError(msg.str()); |
1744 } |
1741 } |
1745 } |
1742 } |
1746 if (line >> std::ws >> c) |
1743 if (line >> std::ws >> c) |
1747 throw FormatError("Extra character on the end of line"); |
1744 throw FormatError("Extra character at the end of line"); |
1748 |
1745 |
1749 Node n; |
1746 Node n; |
1750 if (!_use_nodes) { |
1747 if (!_use_nodes) { |
1751 n = _graph.addNode(); |
1748 n = _graph.addNode(); |
1752 if (label_index != -1) |
1749 if (label_index != -1) |
1753 _node_index.insert(std::make_pair(tokens[label_index], n)); |
1750 _node_index.insert(std::make_pair(tokens[label_index], n)); |
1754 } else { |
1751 } else { |
1755 if (label_index == -1) |
1752 if (label_index == -1) |
1756 throw FormatError("Label map not found in file"); |
1753 throw FormatError("Label map not found"); |
1757 typename std::map<std::string, Node>::iterator it = |
1754 typename std::map<std::string, Node>::iterator it = |
1758 _node_index.find(tokens[label_index]); |
1755 _node_index.find(tokens[label_index]); |
1759 if (it == _node_index.end()) { |
1756 if (it == _node_index.end()) { |
1760 std::ostringstream msg; |
1757 std::ostringstream msg; |
1761 msg << "Node with label not found: " << tokens[label_index]; |
1758 msg << "Node with label not found: " << tokens[label_index]; |
1806 for (int i = 0; i < static_cast<int>(_edge_maps.size()); ++i) { |
1803 for (int i = 0; i < static_cast<int>(_edge_maps.size()); ++i) { |
1807 std::map<std::string, int>::iterator jt = |
1804 std::map<std::string, int>::iterator jt = |
1808 maps.find(_edge_maps[i].first); |
1805 maps.find(_edge_maps[i].first); |
1809 if (jt == maps.end()) { |
1806 if (jt == maps.end()) { |
1810 std::ostringstream msg; |
1807 std::ostringstream msg; |
1811 msg << "Map not found in file: " << _edge_maps[i].first; |
1808 msg << "Map not found: " << _edge_maps[i].first; |
1812 throw FormatError(msg.str()); |
1809 throw FormatError(msg.str()); |
1813 } |
1810 } |
1814 map_index[i] = jt->second; |
1811 map_index[i] = jt->second; |
1815 } |
1812 } |
1816 |
1813 |
1844 msg << "Column not found (" << i + 1 << ")"; |
1841 msg << "Column not found (" << i + 1 << ")"; |
1845 throw FormatError(msg.str()); |
1842 throw FormatError(msg.str()); |
1846 } |
1843 } |
1847 } |
1844 } |
1848 if (line >> std::ws >> c) |
1845 if (line >> std::ws >> c) |
1849 throw FormatError("Extra character on the end of line"); |
1846 throw FormatError("Extra character at the end of line"); |
1850 |
1847 |
1851 Edge e; |
1848 Edge e; |
1852 if (!_use_edges) { |
1849 if (!_use_edges) { |
1853 |
1850 |
1854 typename NodeIndex::iterator it; |
1851 typename NodeIndex::iterator it; |
1872 e = _graph.addEdge(source, target); |
1869 e = _graph.addEdge(source, target); |
1873 if (label_index != -1) |
1870 if (label_index != -1) |
1874 _edge_index.insert(std::make_pair(tokens[label_index], e)); |
1871 _edge_index.insert(std::make_pair(tokens[label_index], e)); |
1875 } else { |
1872 } else { |
1876 if (label_index == -1) |
1873 if (label_index == -1) |
1877 throw FormatError("Label map not found in file"); |
1874 throw FormatError("Label map not found"); |
1878 typename std::map<std::string, Edge>::iterator it = |
1875 typename std::map<std::string, Edge>::iterator it = |
1879 _edge_index.find(tokens[label_index]); |
1876 _edge_index.find(tokens[label_index]); |
1880 if (it == _edge_index.end()) { |
1877 if (it == _edge_index.end()) { |
1881 std::ostringstream msg; |
1878 std::ostringstream msg; |
1882 msg << "Edge with label not found: " << tokens[label_index]; |
1879 msg << "Edge with label not found: " << tokens[label_index]; |
1907 if (!_reader_bits::readToken(line, attr)) |
1904 if (!_reader_bits::readToken(line, attr)) |
1908 throw FormatError("Attribute name not found"); |
1905 throw FormatError("Attribute name not found"); |
1909 if (!_reader_bits::readToken(line, token)) |
1906 if (!_reader_bits::readToken(line, token)) |
1910 throw FormatError("Attribute value not found"); |
1907 throw FormatError("Attribute value not found"); |
1911 if (line >> c) |
1908 if (line >> c) |
1912 throw FormatError("Extra character on the end of line"); |
1909 throw FormatError("Extra character at the end of line"); |
1913 |
1910 |
1914 { |
1911 { |
1915 std::set<std::string>::iterator it = read_attr.find(attr); |
1912 std::set<std::string>::iterator it = read_attr.find(attr); |
1916 if (it != read_attr.end()) { |
1913 if (it != read_attr.end()) { |
1917 std::ostringstream msg; |
1914 std::ostringstream msg; |
1918 msg << "Multiple occurence of attribute " << attr; |
1915 msg << "Multiple occurence of attribute: " << attr; |
1919 throw FormatError(msg.str()); |
1916 throw FormatError(msg.str()); |
1920 } |
1917 } |
1921 read_attr.insert(attr); |
1918 read_attr.insert(attr); |
1922 } |
1919 } |
1923 |
1920 |
1935 } |
1932 } |
1936 for (typename Attributes::iterator it = _attributes.begin(); |
1933 for (typename Attributes::iterator it = _attributes.begin(); |
1937 it != _attributes.end(); ++it) { |
1934 it != _attributes.end(); ++it) { |
1938 if (read_attr.find(it->first) == read_attr.end()) { |
1935 if (read_attr.find(it->first) == read_attr.end()) { |
1939 std::ostringstream msg; |
1936 std::ostringstream msg; |
1940 msg << "Attribute not found in file: " << it->first; |
1937 msg << "Attribute not found: " << it->first; |
1941 throw FormatError(msg.str()); |
1938 throw FormatError(msg.str()); |
1942 } |
1939 } |
1943 } |
1940 } |
1944 } |
1941 } |
1945 |
1942 |
1970 line >> c; |
1967 line >> c; |
1971 _reader_bits::readToken(line, section); |
1968 _reader_bits::readToken(line, section); |
1972 _reader_bits::readToken(line, caption); |
1969 _reader_bits::readToken(line, caption); |
1973 |
1970 |
1974 if (line >> c) |
1971 if (line >> c) |
1975 throw FormatError("Extra character on the end of line"); |
1972 throw FormatError("Extra character at the end of line"); |
1976 |
1973 |
1977 if (section == "nodes" && !nodes_done) { |
1974 if (section == "nodes" && !nodes_done) { |
1978 if (_nodes_caption.empty() || _nodes_caption == caption) { |
1975 if (_nodes_caption.empty() || _nodes_caption == caption) { |
1979 readNodes(); |
1976 readNodes(); |
1980 nodes_done = true; |
1977 nodes_done = true; |
2093 /// |
2090 /// |
2094 /// Construct a section reader, which reads from the given file. |
2091 /// Construct a section reader, which reads from the given file. |
2095 SectionReader(const std::string& fn) |
2092 SectionReader(const std::string& fn) |
2096 : _is(new std::ifstream(fn.c_str())), local_is(true), |
2093 : _is(new std::ifstream(fn.c_str())), local_is(true), |
2097 _filename(fn) { |
2094 _filename(fn) { |
2098 if (!(*_is)) throw IoError(fn, "Cannot open file"); |
2095 if (!(*_is)) throw IoError("Cannot open file", fn); |
2099 } |
2096 } |
2100 |
2097 |
2101 /// \brief Constructor |
2098 /// \brief Constructor |
2102 /// |
2099 /// |
2103 /// Construct a section reader, which reads from the given file. |
2100 /// Construct a section reader, which reads from the given file. |
2104 SectionReader(const char* fn) |
2101 SectionReader(const char* fn) |
2105 : _is(new std::ifstream(fn)), local_is(true), |
2102 : _is(new std::ifstream(fn)), local_is(true), |
2106 _filename(fn) { |
2103 _filename(fn) { |
2107 if (!(*_is)) throw IoError(fn, "Cannot open file"); |
2104 if (!(*_is)) throw IoError("Cannot open file", fn); |
2108 } |
2105 } |
2109 |
2106 |
2110 /// \brief Destructor |
2107 /// \brief Destructor |
2111 ~SectionReader() { |
2108 ~SectionReader() { |
2112 for (Sections::iterator it = _sections.begin(); |
2109 for (Sections::iterator it = _sections.begin(); |
2259 line >> c; |
2256 line >> c; |
2260 _reader_bits::readToken(line, section); |
2257 _reader_bits::readToken(line, section); |
2261 _reader_bits::readToken(line, caption); |
2258 _reader_bits::readToken(line, caption); |
2262 |
2259 |
2263 if (line >> c) |
2260 if (line >> c) |
2264 throw FormatError("Extra character on the end of line"); |
2261 throw FormatError("Extra character at the end of line"); |
2265 |
2262 |
2266 if (extra_sections.find(section) != extra_sections.end()) { |
2263 if (extra_sections.find(section) != extra_sections.end()) { |
2267 std::ostringstream msg; |
2264 std::ostringstream msg; |
2268 msg << "Multiple occurence of section " << section; |
2265 msg << "Multiple occurence of section: " << section; |
2269 throw FormatError(msg.str()); |
2266 throw FormatError(msg.str()); |
2270 } |
2267 } |
2271 Sections::iterator it = _sections.find(section); |
2268 Sections::iterator it = _sections.find(section); |
2272 if (it != _sections.end()) { |
2269 if (it != _sections.end()) { |
2273 extra_sections.insert(section); |
2270 extra_sections.insert(section); |
2385 /// |
2382 /// |
2386 /// Construct an \e LGF contents reader, which reads from the given |
2383 /// Construct an \e LGF contents reader, which reads from the given |
2387 /// file. |
2384 /// file. |
2388 LgfContents(const std::string& fn) |
2385 LgfContents(const std::string& fn) |
2389 : _is(new std::ifstream(fn.c_str())), local_is(true) { |
2386 : _is(new std::ifstream(fn.c_str())), local_is(true) { |
2390 if (!(*_is)) throw IoError(fn, "Cannot open file"); |
2387 if (!(*_is)) throw IoError("Cannot open file", fn); |
2391 } |
2388 } |
2392 |
2389 |
2393 /// \brief Constructor |
2390 /// \brief Constructor |
2394 /// |
2391 /// |
2395 /// Construct an \e LGF contents reader, which reads from the given |
2392 /// Construct an \e LGF contents reader, which reads from the given |
2396 /// file. |
2393 /// file. |
2397 LgfContents(const char* fn) |
2394 LgfContents(const char* fn) |
2398 : _is(new std::ifstream(fn)), local_is(true) { |
2395 : _is(new std::ifstream(fn)), local_is(true) { |
2399 if (!(*_is)) throw IoError(fn, "Cannot open file"); |
2396 if (!(*_is)) throw IoError("Cannot open file", fn); |
2400 } |
2397 } |
2401 |
2398 |
2402 /// \brief Destructor |
2399 /// \brief Destructor |
2403 ~LgfContents() { |
2400 ~LgfContents() { |
2404 if (local_is) delete _is; |
2401 if (local_is) delete _is; |