Changes in lemon/lgf_writer.h [190:1e6af6f0843c:201:9757e3d9bfeb] in lemon-main
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/lgf_writer.h
r190 r201 19 19 ///\ingroup lemon_io 20 20 ///\file 21 ///\brief Lemon Graph Formatwriter.21 ///\brief \ref lgf-format "Lemon Graph Format" writer. 22 22 23 23 … … 226 226 }; 227 227 228 bool isWhiteSpace(char c) {228 inline bool isWhiteSpace(char c) { 229 229 return c == ' ' || c == '\t' || c == '\v' || 230 230 c == '\n' || c == '\r' || c == '\f'; 231 231 } 232 232 233 bool isEscaped(char c) {233 inline bool isEscaped(char c) { 234 234 return c == '\\' || c == '\"' || c == '\'' || 235 235 c == '\a' || c == '\b'; 236 236 } 237 237 238 static void writeEscape(std::ostream& os, char c) {238 inline static void writeEscape(std::ostream& os, char c) { 239 239 switch (c) { 240 240 case '\\': … … 277 277 } 278 278 279 bool requireEscape(const std::string& str) {279 inline bool requireEscape(const std::string& str) { 280 280 if (str.empty() || str[0] == '@') return true; 281 281 std::istringstream is(str); … … 289 289 } 290 290 291 std::ostream& writeToken(std::ostream& os, const std::string& str) {291 inline std::ostream& writeToken(std::ostream& os, const std::string& str) { 292 292 293 293 if (requireEscape(str)) { … … 323 323 /// \ingroup lemon_io 324 324 /// 325 /// \brief LGFwriter for directed graphs325 /// \brief \ref lgf-format "LGF" writer for directed graphs 326 326 /// 327 327 /// This utility writes an \ref lgf-format "LGF" file. … … 333 333 /// with the \c nodeMap() or \c arcMap() members. An optional 334 334 /// converter parameter can also be added as a standard functor 335 /// converting from the value type of the map to std::string. If it336 /// is set, it will determine how the map's value typeis written to335 /// converting from the value type of the map to \c std::string. If it 336 /// is set, it will determine how the value type of the map is written to 337 337 /// the output stream. If the functor is not set, then a default 338 338 /// conversion will be used. The \c attribute(), \c node() and \c … … 340 340 /// 341 341 ///\code 342 /// 343 /// 344 /// 345 /// 346 /// 347 /// 348 /// 349 /// 350 /// 342 /// DigraphWriter<Digraph>(std::cout, digraph). 343 /// nodeMap("coordinates", coord_map). 344 /// nodeMap("size", size). 345 /// nodeMap("title", title). 346 /// arcMap("capacity", cap_map). 347 /// node("source", src). 348 /// node("target", trg). 349 /// attribute("caption", caption). 350 /// run(); 351 351 ///\endcode 352 352 /// … … 487 487 /// @{ 488 488 489 /// \brief Node map reading rule490 /// 491 /// Add a node map reading rule to the writer.489 /// \brief Node map writing rule 490 /// 491 /// Add a node map writing rule to the writer. 492 492 template <typename Map> 493 493 DigraphWriter& nodeMap(const std::string& caption, const Map& map) { … … 587 587 } 588 588 589 /// \name Se lect section by name589 /// \name Section captions 590 590 /// @{ 591 591 592 /// \brief Set \c \@nodes section to be read593 /// 594 /// Set \c \@nodes section to be read592 /// \brief Add an additional caption to the \c \@nodes section 593 /// 594 /// Add an additional caption to the \c \@nodes section. 595 595 DigraphWriter& nodes(const std::string& caption) { 596 596 _nodes_caption = caption; … … 598 598 } 599 599 600 /// \brief Set \c \@arcs section to be read601 /// 602 /// Set \c \@arcs section to be read600 /// \brief Add an additional caption to the \c \@arcs section 601 /// 602 /// Add an additional caption to the \c \@arcs section. 603 603 DigraphWriter& arcs(const std::string& caption) { 604 604 _arcs_caption = caption; … … 606 606 } 607 607 608 /// \brief Set \c \@attributes section to be read609 /// 610 /// Set \c \@attributes section to be read608 /// \brief Add an additional caption to the \c \@attributes section 609 /// 610 /// Add an additional caption to the \c \@attributes section. 611 611 DigraphWriter& attributes(const std::string& caption) { 612 612 _attributes_caption = caption; … … 619 619 /// \brief Skip writing the node set 620 620 /// 621 /// The \c \@nodes section will be notwritten to the stream.621 /// The \c \@nodes section will not be written to the stream. 622 622 DigraphWriter& skipNodes() { 623 623 LEMON_ASSERT(!_skip_nodes, "Multiple usage of skipNodes() member"); … … 628 628 /// \brief Skip writing arc set 629 629 /// 630 /// The \c \@arcs section will be notwritten to the stream.630 /// The \c \@arcs section will not be written to the stream. 631 631 DigraphWriter& skipArcs() { 632 632 LEMON_ASSERT(!_skip_arcs, "Multiple usage of skipArcs() member"); … … 836 836 /// \brief Start the batch processing 837 837 /// 838 /// This function starts the batch processing 838 /// This function starts the batch processing. 839 839 void run() { 840 840 if (!_skip_nodes) { … … 851 851 } 852 852 853 /// \brief Give sback the stream of the writer854 /// 855 /// Give s back the stream of the writer853 /// \brief Give back the stream of the writer 854 /// 855 /// Give back the stream of the writer. 856 856 std::ostream& ostream() { 857 857 return *_os; … … 861 861 }; 862 862 863 /// \brief Return a \ref DigraphWriter class 864 /// 865 /// This function just returns a \ref DigraphWriter class. 863 866 /// \relates DigraphWriter 864 867 template <typename Digraph> … … 869 872 } 870 873 874 /// \brief Return a \ref DigraphWriter class 875 /// 876 /// This function just returns a \ref DigraphWriter class. 871 877 /// \relates DigraphWriter 872 878 template <typename Digraph> … … 877 883 } 878 884 885 /// \brief Return a \ref DigraphWriter class 886 /// 887 /// This function just returns a \ref DigraphWriter class. 879 888 /// \relates DigraphWriter 880 889 template <typename Digraph> … … 899 908 /// \ingroup lemon_io 900 909 /// 901 /// \brief LGFwriter for directed graphs910 /// \brief \ref lgf-format "LGF" writer for directed graphs 902 911 /// 903 912 /// This utility writes an \ref lgf-format "LGF" file. 913 /// 914 /// It can be used almost the same way as \c DigraphWriter. 915 /// The only difference is that this class can handle edges and 916 /// edge maps as well as arcs and arc maps. 917 /// 918 /// The arc maps are written into the file as two columns, the 919 /// caption of the columns are the name of the map prefixed with \c 920 /// '+' and \c '-'. The arcs are written into the \c \@attributes 921 /// section as a \c '+' or a \c '-' prefix (depends on the direction 922 /// of the arc) and the label of corresponding edge. 904 923 template <typename _Graph> 905 924 class GraphWriter { … … 1024 1043 /// @{ 1025 1044 1026 /// \brief Node map reading rule1027 /// 1028 /// Add a node map reading rule to the writer.1045 /// \brief Node map writing rule 1046 /// 1047 /// Add a node map writing rule to the writer. 1029 1048 template <typename Map> 1030 1049 GraphWriter& nodeMap(const std::string& caption, const Map& map) { … … 1170 1189 } 1171 1190 1172 /// \name Se lect section by name1191 /// \name Section captions 1173 1192 /// @{ 1174 1193 1175 /// \brief Set \c \@nodes section to be read1176 /// 1177 /// Set \c \@nodes section to be read1194 /// \brief Add an additional caption to the \c \@nodes section 1195 /// 1196 /// Add an additional caption to the \c \@nodes section. 1178 1197 GraphWriter& nodes(const std::string& caption) { 1179 1198 _nodes_caption = caption; … … 1181 1200 } 1182 1201 1183 /// \brief Set \c \@edges section to be read1184 /// 1185 /// Set \c \@edges section to be read1202 /// \brief Add an additional caption to the \c \@arcs section 1203 /// 1204 /// Add an additional caption to the \c \@arcs section. 1186 1205 GraphWriter& edges(const std::string& caption) { 1187 1206 _edges_caption = caption; … … 1189 1208 } 1190 1209 1191 /// \brief Set \c \@attributes section to be read1192 /// 1193 /// Set \c \@attributes section to be read1210 /// \brief Add an additional caption to the \c \@attributes section 1211 /// 1212 /// Add an additional caption to the \c \@attributes section. 1194 1213 GraphWriter& attributes(const std::string& caption) { 1195 1214 _attributes_caption = caption; … … 1202 1221 /// \brief Skip writing the node set 1203 1222 /// 1204 /// The \c \@nodes section will be notwritten to the stream.1223 /// The \c \@nodes section will not be written to the stream. 1205 1224 GraphWriter& skipNodes() { 1206 1225 LEMON_ASSERT(!_skip_nodes, "Multiple usage of skipNodes() member"); … … 1211 1230 /// \brief Skip writing edge set 1212 1231 /// 1213 /// The \c \@edges section will be notwritten to the stream.1232 /// The \c \@edges section will not be written to the stream. 1214 1233 GraphWriter& skipEdges() { 1215 1234 LEMON_ASSERT(!_skip_edges, "Multiple usage of skipEdges() member"); … … 1419 1438 /// \brief Start the batch processing 1420 1439 /// 1421 /// This function starts the batch processing 1440 /// This function starts the batch processing. 1422 1441 void run() { 1423 1442 if (!_skip_nodes) { … … 1434 1453 } 1435 1454 1436 /// \brief Give sback the stream of the writer1437 /// 1438 /// Give sback the stream of the writer1455 /// \brief Give back the stream of the writer 1456 /// 1457 /// Give back the stream of the writer 1439 1458 std::ostream& ostream() { 1440 1459 return *_os; … … 1444 1463 }; 1445 1464 1465 /// \brief Return a \ref GraphWriter class 1466 /// 1467 /// This function just returns a \ref GraphWriter class. 1446 1468 /// \relates GraphWriter 1447 1469 template <typename Graph> … … 1451 1473 } 1452 1474 1475 /// \brief Return a \ref GraphWriter class 1476 /// 1477 /// This function just returns a \ref GraphWriter class. 1453 1478 /// \relates GraphWriter 1454 1479 template <typename Graph> … … 1458 1483 } 1459 1484 1485 /// \brief Return a \ref GraphWriter class 1486 /// 1487 /// This function just returns a \ref GraphWriter class. 1460 1488 /// \relates GraphWriter 1461 1489 template <typename Graph>
Note: See TracChangeset
for help on using the changeset viewer.