0
2
0
48
68
46
68
... | ... |
@@ -382,33 +382,55 @@ |
382 | 382 |
} |
383 | 383 |
} |
384 | 384 |
if (is) is.putback(c); |
385 | 385 |
else if (is.eof()) is.clear(); |
386 | 386 |
} |
387 | 387 |
}; |
388 | 388 |
|
389 | 389 |
} |
390 | 390 |
|
391 | 391 |
template <typename Digraph> |
392 | 392 |
class DigraphReader; |
393 | 393 |
|
394 |
/// \brief Return a \ref DigraphReader class |
|
395 |
/// |
|
396 |
/// This function just returns a \ref DigraphReader class. |
|
397 |
/// \relates DigraphReader |
|
394 | 398 |
template <typename Digraph> |
395 | 399 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, |
396 |
std::istream& is = std::cin); |
|
397 |
|
|
400 |
std::istream& is = std::cin) { |
|
401 |
DigraphReader<Digraph> tmp(digraph, is); |
|
402 |
return tmp; |
|
403 |
} |
|
404 |
|
|
405 |
/// \brief Return a \ref DigraphReader class |
|
406 |
/// |
|
407 |
/// This function just returns a \ref DigraphReader class. |
|
408 |
/// \relates DigraphReader |
|
398 | 409 |
template <typename Digraph> |
399 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn); |
|
400 |
|
|
410 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, |
|
411 |
const std::string& fn) { |
|
412 |
DigraphReader<Digraph> tmp(digraph, fn); |
|
413 |
return tmp; |
|
414 |
} |
|
415 |
|
|
416 |
/// \brief Return a \ref DigraphReader class |
|
417 |
/// |
|
418 |
/// This function just returns a \ref DigraphReader class. |
|
419 |
/// \relates DigraphReader |
|
401 | 420 |
template <typename Digraph> |
402 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, const char |
|
421 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) { |
|
422 |
DigraphReader<Digraph> tmp(digraph, fn); |
|
423 |
return tmp; |
|
424 |
} |
|
403 | 425 |
|
404 | 426 |
/// \ingroup lemon_io |
405 | 427 |
/// |
406 | 428 |
/// \brief \ref lgf-format "LGF" reader for directed graphs |
407 | 429 |
/// |
408 | 430 |
/// This utility reads an \ref lgf-format "LGF" file. |
409 | 431 |
/// |
410 | 432 |
/// The reading method does a batch processing. The user creates a |
411 | 433 |
/// reader object, then various reading rules can be added to the |
412 | 434 |
/// reader, and eventually the reading is executed with the \c run() |
413 | 435 |
/// member function. A map reading rule can be added to the reader |
414 | 436 |
/// with the \c nodeMap() or \c arcMap() members. An optional |
... | ... |
@@ -1180,69 +1202,57 @@ |
1180 | 1202 |
} |
1181 | 1203 |
|
1182 | 1204 |
if (!attributes_done && !_attributes.empty()) { |
1183 | 1205 |
throw FormatError("Section @attributes not found"); |
1184 | 1206 |
} |
1185 | 1207 |
|
1186 | 1208 |
} |
1187 | 1209 |
|
1188 | 1210 |
/// @} |
1189 | 1211 |
|
1190 | 1212 |
}; |
1191 | 1213 |
|
1192 |
|
|
1214 |
template <typename Graph> |
|
1215 |
class GraphReader; |
|
1216 |
|
|
1217 |
/// \brief Return a \ref GraphReader class |
|
1193 | 1218 |
/// |
1194 |
/// This function just returns a \ref DigraphReader class. |
|
1195 |
/// \relates DigraphReader |
|
1196 |
template <typename Digraph> |
|
1197 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, |
|
1198 |
std::istream& is = std::cin) { |
|
1199 |
DigraphReader<Digraph> tmp(digraph, is); |
|
1219 |
/// This function just returns a \ref GraphReader class. |
|
1220 |
/// \relates GraphReader |
|
1221 |
template <typename Graph> |
|
1222 |
GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) { |
|
1223 |
GraphReader<Graph> tmp(graph, is); |
|
1200 | 1224 |
return tmp; |
1201 | 1225 |
} |
1202 | 1226 |
|
1203 |
/// \brief Return a \ref |
|
1227 |
/// \brief Return a \ref GraphReader class |
|
1204 | 1228 |
/// |
1205 |
/// This function just returns a \ref DigraphReader class. |
|
1206 |
/// \relates DigraphReader |
|
1207 |
template <typename Digraph> |
|
1208 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, |
|
1209 |
const std::string& fn) { |
|
1210 |
DigraphReader<Digraph> tmp(digraph, fn); |
|
1229 |
/// This function just returns a \ref GraphReader class. |
|
1230 |
/// \relates GraphReader |
|
1231 |
template <typename Graph> |
|
1232 |
GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) { |
|
1233 |
GraphReader<Graph> tmp(graph, fn); |
|
1211 | 1234 |
return tmp; |
1212 | 1235 |
} |
1213 | 1236 |
|
1214 |
/// \brief Return a \ref |
|
1237 |
/// \brief Return a \ref GraphReader class |
|
1215 | 1238 |
/// |
1216 |
/// This function just returns a \ref DigraphReader class. |
|
1217 |
/// \relates DigraphReader |
|
1218 |
template <typename Digraph> |
|
1219 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) { |
|
1220 |
|
|
1239 |
/// This function just returns a \ref GraphReader class. |
|
1240 |
/// \relates GraphReader |
|
1241 |
template <typename Graph> |
|
1242 |
GraphReader<Graph> graphReader(Graph& graph, const char* fn) { |
|
1243 |
GraphReader<Graph> tmp(graph, fn); |
|
1221 | 1244 |
return tmp; |
1222 | 1245 |
} |
1223 | 1246 |
|
1224 |
template <typename Graph> |
|
1225 |
class GraphReader; |
|
1226 |
|
|
1227 |
template <typename Graph> |
|
1228 |
GraphReader<Graph> graphReader(Graph& graph, |
|
1229 |
std::istream& is = std::cin); |
|
1230 |
|
|
1231 |
template <typename Graph> |
|
1232 |
GraphReader<Graph> graphReader(Graph& graph, const std::string& fn); |
|
1233 |
|
|
1234 |
template <typename Graph> |
|
1235 |
GraphReader<Graph> graphReader(Graph& graph, const char *fn); |
|
1236 |
|
|
1237 | 1247 |
/// \ingroup lemon_io |
1238 | 1248 |
/// |
1239 | 1249 |
/// \brief \ref lgf-format "LGF" reader for undirected graphs |
1240 | 1250 |
/// |
1241 | 1251 |
/// This utility reads an \ref lgf-format "LGF" file. |
1242 | 1252 |
/// |
1243 | 1253 |
/// It can be used almost the same way as \c DigraphReader. |
1244 | 1254 |
/// The only difference is that this class can handle edges and |
1245 | 1255 |
/// edge maps as well as arcs and arc maps. |
1246 | 1256 |
/// |
1247 | 1257 |
/// The columns in the \c \@edges (or \c \@arcs) section are the |
1248 | 1258 |
/// edge maps. However, if there are two maps with the same name |
... | ... |
@@ -2022,54 +2032,24 @@ |
2022 | 2032 |
} |
2023 | 2033 |
|
2024 | 2034 |
if (!attributes_done && !_attributes.empty()) { |
2025 | 2035 |
throw FormatError("Section @attributes not found"); |
2026 | 2036 |
} |
2027 | 2037 |
|
2028 | 2038 |
} |
2029 | 2039 |
|
2030 | 2040 |
/// @} |
2031 | 2041 |
|
2032 | 2042 |
}; |
2033 | 2043 |
|
2034 |
/// \brief Return a \ref GraphReader class |
|
2035 |
/// |
|
2036 |
/// This function just returns a \ref GraphReader class. |
|
2037 |
/// \relates GraphReader |
|
2038 |
template <typename Graph> |
|
2039 |
GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) { |
|
2040 |
GraphReader<Graph> tmp(graph, is); |
|
2041 |
return tmp; |
|
2042 |
} |
|
2043 |
|
|
2044 |
/// \brief Return a \ref GraphReader class |
|
2045 |
/// |
|
2046 |
/// This function just returns a \ref GraphReader class. |
|
2047 |
/// \relates GraphReader |
|
2048 |
template <typename Graph> |
|
2049 |
GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) { |
|
2050 |
GraphReader<Graph> tmp(graph, fn); |
|
2051 |
return tmp; |
|
2052 |
} |
|
2053 |
|
|
2054 |
/// \brief Return a \ref GraphReader class |
|
2055 |
/// |
|
2056 |
/// This function just returns a \ref GraphReader class. |
|
2057 |
/// \relates GraphReader |
|
2058 |
template <typename Graph> |
|
2059 |
GraphReader<Graph> graphReader(Graph& graph, const char* fn) { |
|
2060 |
GraphReader<Graph> tmp(graph, fn); |
|
2061 |
return tmp; |
|
2062 |
} |
|
2063 |
|
|
2064 | 2044 |
class SectionReader; |
2065 | 2045 |
|
2066 | 2046 |
SectionReader sectionReader(std::istream& is); |
2067 | 2047 |
SectionReader sectionReader(const std::string& fn); |
2068 | 2048 |
SectionReader sectionReader(const char* fn); |
2069 | 2049 |
|
2070 | 2050 |
/// \ingroup lemon_io |
2071 | 2051 |
/// |
2072 | 2052 |
/// \brief Section reader class |
2073 | 2053 |
/// |
2074 | 2054 |
/// In the \ref lgf-format "LGF" file extra sections can be placed, |
2075 | 2055 |
/// which contain any data in arbitrary format. Such sections can be |
... | ... |
@@ -342,35 +342,56 @@ |
342 | 342 |
virtual ~StreamSection() {} |
343 | 343 |
|
344 | 344 |
virtual void process(std::ostream& os) { |
345 | 345 |
_functor(os); |
346 | 346 |
} |
347 | 347 |
}; |
348 | 348 |
|
349 | 349 |
} |
350 | 350 |
|
351 | 351 |
template <typename Digraph> |
352 | 352 |
class DigraphWriter; |
353 | 353 |
|
354 |
/// \brief Return a \ref DigraphWriter class |
|
355 |
/// |
|
356 |
/// This function just returns a \ref DigraphWriter class. |
|
357 |
/// \relates DigraphWriter |
|
354 | 358 |
template <typename Digraph> |
355 | 359 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
356 |
std::ostream& os = std::cout) |
|
360 |
std::ostream& os = std::cout) { |
|
361 |
DigraphWriter<Digraph> tmp(digraph, os); |
|
362 |
return tmp; |
|
363 |
} |
|
357 | 364 |
|
365 |
/// \brief Return a \ref DigraphWriter class |
|
366 |
/// |
|
367 |
/// This function just returns a \ref DigraphWriter class. |
|
368 |
/// \relates DigraphWriter |
|
358 | 369 |
template <typename Digraph> |
359 | 370 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
360 |
const std::string& fn) |
|
371 |
const std::string& fn) { |
|
372 |
DigraphWriter<Digraph> tmp(digraph, fn); |
|
373 |
return tmp; |
|
374 |
} |
|
361 | 375 |
|
376 |
/// \brief Return a \ref DigraphWriter class |
|
377 |
/// |
|
378 |
/// This function just returns a \ref DigraphWriter class. |
|
379 |
/// \relates DigraphWriter |
|
362 | 380 |
template <typename Digraph> |
363 | 381 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
364 |
const char |
|
382 |
const char* fn) { |
|
383 |
DigraphWriter<Digraph> tmp(digraph, fn); |
|
384 |
return tmp; |
|
385 |
} |
|
365 | 386 |
|
366 | 387 |
/// \ingroup lemon_io |
367 | 388 |
/// |
368 | 389 |
/// \brief \ref lgf-format "LGF" writer for directed graphs |
369 | 390 |
/// |
370 | 391 |
/// This utility writes an \ref lgf-format "LGF" file. |
371 | 392 |
/// |
372 | 393 |
/// The writing method does a batch processing. The user creates a |
373 | 394 |
/// writer object, then various writing rules can be added to the |
374 | 395 |
/// writer, and eventually the writing is executed with the \c run() |
375 | 396 |
/// member function. A map writing rule can be added to the writer |
376 | 397 |
/// with the \c nodeMap() or \c arcMap() members. An optional |
... | ... |
@@ -904,70 +925,58 @@ |
904 | 925 |
} |
905 | 926 |
|
906 | 927 |
/// \brief Give back the stream of the writer |
907 | 928 |
/// |
908 | 929 |
/// Give back the stream of the writer. |
909 | 930 |
std::ostream& ostream() { |
910 | 931 |
return *_os; |
911 | 932 |
} |
912 | 933 |
|
913 | 934 |
/// @} |
914 | 935 |
}; |
915 | 936 |
|
916 |
|
|
937 |
template <typename Graph> |
|
938 |
class GraphWriter; |
|
939 |
|
|
940 |
/// \brief Return a \ref GraphWriter class |
|
917 | 941 |
/// |
918 |
/// This function just returns a \ref DigraphWriter class. |
|
919 |
/// \relates DigraphWriter |
|
920 |
template <typename Digraph> |
|
921 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
922 |
std::ostream& os = std::cout) { |
|
923 |
DigraphWriter<Digraph> tmp(digraph, os); |
|
942 |
/// This function just returns a \ref GraphWriter class. |
|
943 |
/// \relates GraphWriter |
|
944 |
template <typename Graph> |
|
945 |
GraphWriter<Graph> graphWriter(const Graph& graph, |
|
946 |
std::ostream& os = std::cout) { |
|
947 |
GraphWriter<Graph> tmp(graph, os); |
|
924 | 948 |
return tmp; |
925 | 949 |
} |
926 | 950 |
|
927 |
/// \brief Return a \ref |
|
951 |
/// \brief Return a \ref GraphWriter class |
|
928 | 952 |
/// |
929 |
/// This function just returns a \ref DigraphWriter class. |
|
930 |
/// \relates DigraphWriter |
|
931 |
template <typename Digraph> |
|
932 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
933 |
const std::string& fn) { |
|
934 |
DigraphWriter<Digraph> tmp(digraph, fn); |
|
953 |
/// This function just returns a \ref GraphWriter class. |
|
954 |
/// \relates GraphWriter |
|
955 |
template <typename Graph> |
|
956 |
GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) { |
|
957 |
GraphWriter<Graph> tmp(graph, fn); |
|
935 | 958 |
return tmp; |
936 | 959 |
} |
937 | 960 |
|
938 |
/// \brief Return a \ref |
|
961 |
/// \brief Return a \ref GraphWriter class |
|
939 | 962 |
/// |
940 |
/// This function just returns a \ref DigraphWriter class. |
|
941 |
/// \relates DigraphWriter |
|
942 |
template <typename Digraph> |
|
943 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
944 |
const char* fn) { |
|
945 |
DigraphWriter<Digraph> tmp(digraph, fn); |
|
963 |
/// This function just returns a \ref GraphWriter class. |
|
964 |
/// \relates GraphWriter |
|
965 |
template <typename Graph> |
|
966 |
GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) { |
|
967 |
GraphWriter<Graph> tmp(graph, fn); |
|
946 | 968 |
return tmp; |
947 | 969 |
} |
948 | 970 |
|
949 |
template <typename Graph> |
|
950 |
class GraphWriter; |
|
951 |
|
|
952 |
template <typename Graph> |
|
953 |
GraphWriter<Graph> graphWriter(const Graph& graph, |
|
954 |
std::ostream& os = std::cout); |
|
955 |
|
|
956 |
template <typename Graph> |
|
957 |
GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn); |
|
958 |
|
|
959 |
template <typename Graph> |
|
960 |
GraphWriter<Graph> graphWriter(const Graph& graph, const char *fn); |
|
961 |
|
|
962 | 971 |
/// \ingroup lemon_io |
963 | 972 |
/// |
964 | 973 |
/// \brief \ref lgf-format "LGF" writer for directed graphs |
965 | 974 |
/// |
966 | 975 |
/// This utility writes an \ref lgf-format "LGF" file. |
967 | 976 |
/// |
968 | 977 |
/// It can be used almost the same way as \c DigraphWriter. |
969 | 978 |
/// The only difference is that this class can handle edges and |
970 | 979 |
/// edge maps as well as arcs and arc maps. |
971 | 980 |
/// |
972 | 981 |
/// The arc maps are written into the file as two columns, the |
973 | 982 |
/// caption of the columns are the name of the map prefixed with \c |
... | ... |
@@ -1517,55 +1526,24 @@ |
1517 | 1526 |
} |
1518 | 1527 |
|
1519 | 1528 |
/// \brief Give back the stream of the writer |
1520 | 1529 |
/// |
1521 | 1530 |
/// Give back the stream of the writer |
1522 | 1531 |
std::ostream& ostream() { |
1523 | 1532 |
return *_os; |
1524 | 1533 |
} |
1525 | 1534 |
|
1526 | 1535 |
/// @} |
1527 | 1536 |
}; |
1528 | 1537 |
|
1529 |
/// \brief Return a \ref GraphWriter class |
|
1530 |
/// |
|
1531 |
/// This function just returns a \ref GraphWriter class. |
|
1532 |
/// \relates GraphWriter |
|
1533 |
template <typename Graph> |
|
1534 |
GraphWriter<Graph> graphWriter(const Graph& graph, |
|
1535 |
std::ostream& os = std::cout) { |
|
1536 |
GraphWriter<Graph> tmp(graph, os); |
|
1537 |
return tmp; |
|
1538 |
} |
|
1539 |
|
|
1540 |
/// \brief Return a \ref GraphWriter class |
|
1541 |
/// |
|
1542 |
/// This function just returns a \ref GraphWriter class. |
|
1543 |
/// \relates GraphWriter |
|
1544 |
template <typename Graph> |
|
1545 |
GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) { |
|
1546 |
GraphWriter<Graph> tmp(graph, fn); |
|
1547 |
return tmp; |
|
1548 |
} |
|
1549 |
|
|
1550 |
/// \brief Return a \ref GraphWriter class |
|
1551 |
/// |
|
1552 |
/// This function just returns a \ref GraphWriter class. |
|
1553 |
/// \relates GraphWriter |
|
1554 |
template <typename Graph> |
|
1555 |
GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) { |
|
1556 |
GraphWriter<Graph> tmp(graph, fn); |
|
1557 |
return tmp; |
|
1558 |
} |
|
1559 |
|
|
1560 | 1538 |
class SectionWriter; |
1561 | 1539 |
|
1562 | 1540 |
SectionWriter sectionWriter(std::istream& is); |
1563 | 1541 |
SectionWriter sectionWriter(const std::string& fn); |
1564 | 1542 |
SectionWriter sectionWriter(const char* fn); |
1565 | 1543 |
|
1566 | 1544 |
/// \ingroup lemon_io |
1567 | 1545 |
/// |
1568 | 1546 |
/// \brief Section writer class |
1569 | 1547 |
/// |
1570 | 1548 |
/// In the \ref lgf-format "LGF" file extra sections can be placed, |
1571 | 1549 |
/// which contain any data in arbitrary format. Such sections can be |
0 comments (0 inline)