Ticket #35: lgf_doc.patch
File lgf_doc.patch, 28.7 KB (added by , 17 years ago) |
---|
-
doc/groups.dox
# HG changeset patch # User Balazs Dezso <deba@inf.elte.hu> # Date 1210797907 -7200 # Node ID a765b4ecbcdbd5e8ac0fc55beecf585ebb481b15 # Parent 5c3604513ed0256e35e5fd50c54cd0e37362397e Fixing token usage and documention is LGF IO diff -r 5c3604513ed0 -r a765b4ecbcdb doc/groups.dox
a b 483 483 */ 484 484 485 485 /** 486 @defgroup section_io Section readers and writers487 @ingroup lemon_io488 \brief Section readers and writers for LEMON Input-Output.489 490 This group describes section reader and writer classes that can be491 attached to \ref LemonReader and \ref LemonWriter.492 */493 494 /**495 @defgroup item_io Item readers and writers496 @ingroup lemon_io497 \brief Item readers and writers for LEMON Input-Output.498 499 This group describes reader and writer classes for various data types500 (e.g. map or attribute values). These classes can be attached to501 \ref LemonReader and \ref LemonWriter.502 */503 504 /**505 486 @defgroup eps_io Postscript exporting 506 487 @ingroup io_group 507 488 \brief General \c EPS drawer and graph exporter -
lemon/lgf_reader.h
diff -r 5c3604513ed0 -r a765b4ecbcdb lemon/lgf_reader.h
a b 268 268 str = os.str(); 269 269 return is; 270 270 } 271 272 std::istream& readIdentifier(std::istream& is, std::string& str) {273 std::ostringstream os;274 275 char c;276 is >> std::ws;277 278 if (!is.get(c))279 return is;280 281 if (!isIdentifierFirstChar(c))282 throw DataFormatError("Wrong char in identifier");283 284 os << c;285 286 while (is.get(c) && !isWhiteSpace(c)) {287 if (!isIdentifierChar(c))288 throw DataFormatError("Wrong char in identifier");289 os << c;290 }291 if (!is) is.clear();292 293 str = os.str();294 return is;295 }296 271 297 272 } 298 299 /// \e 273 274 /// \ingroup lemon_io 275 /// 276 /// \brief LGF reader for directed graphs 277 /// 278 /// The \e LGF (LEMON graph file) format is the default file format 279 /// of the LEMON library. It is a text based, section oriented 280 /// format, which defines some standard sections for storing graphs 281 /// in text files. Each line with \c '#' first non-whitespace 282 /// character is considered as a comment line. Each section starts with 283 /// a header line, these lines starts with \c '@' character and the 284 /// name of section type. The standard sections are \c \@nodes, \c 285 /// \@arcs and \c \@edges (these two names are completely equivalent) 286 /// and \@attributes. Each header line may also have an optional 287 /// name, which can be use to distinguish the sections of the same 288 /// type. 289 /// 290 /// The \@nodes section describes a set of nodes and associated 291 /// maps. The first is a header line consisting of the names of the 292 /// maps, each of them is a plain or quoted token. A plain token is 293 /// a sequence of non-whitespace characters, and a quoted token is a 294 /// character sequence surrounded by double quotes, and the sequence 295 /// may contain escape sequences. One of the maps must be called \c 296 /// "label", which plays special role in the file. Each following 297 /// non-empty line until the next section describes a node in the 298 /// graph. These lines contain the values of the node maps 299 /// associated to the current node, each value is also plain or 300 /// quoted token. 301 /// 302 /// The \c \@arcs section is very similar to the \c \@nodes section, 303 /// it starts with a header line consists from the names of the arc 304 /// maps, the \c "label" map is also necessary. The following lines 305 /// contain the description of the arcs. The first two tokens are 306 /// the source and the target node of the edge, then comes the map 307 /// values. The source and target tokens must be node labels. 308 /// 309 /// The \c \@attributes section contains key-value pairs, each line 310 /// starts with an attribute nome, and then an attribute value. Both 311 /// of them are plain or quoted tokens, but the value could be also 312 /// a node or an arc label. 313 /// 314 ///\code 315 /// @nodes 316 /// label coordinates size title 317 /// 1 (10,20) 10 "First node" 318 /// 2 (80,80) 8 "Second node" 319 /// 3 (40,10) 10 "Third node" 320 /// @arcs 321 /// capacity 322 /// 1 2 16 323 /// 1 3 12 324 /// 2 3 18 325 /// @attributes 326 /// source 1 327 /// target 3 328 /// caption "LEMON test digraph" 329 ///\endcode 330 /// 331 /// The writing method does a batch processing. The user creates a 332 /// writer object, then several writing rules can be added to the 333 /// writer, and eventually the writing is executed with the \c run() 334 /// member function. A map writing rule can be added to the writer 335 /// with the \c nodeMap() or \c arcMap() members. The optional 336 /// converter parameter can be a standard functor, which converts an 337 /// the value type of the map to std::string, if it is set, it 338 /// determines how the the map's value type is written to the output 339 /// stream. If the functor is not set, then a default conversion 340 /// will be used. The \c attribute(), \c node() and \c arc() functions 341 /// are used to add attribute writing rules. 342 /// 343 ///\code 344 /// DigraphWriter<Digraph>(std::cout, digraph). 345 /// nodeMap("coordinates", coord_map). 346 /// nodeMap("size", size). 347 /// nodeMap("title", title). 348 /// arcMap("capacity", cap_map). 349 /// node("source", src). 350 /// node("target", trg). 351 /// attribute("caption", caption). 352 /// run(); 353 ///\endcode 354 /// 355 /// By default the writer uses the first section in the file of the 356 /// proper type. If a section has an optional name, then it can be 357 /// selected to write with the \c nodes(), \c arcs() or \c attributes() 358 /// functions. 359 /// 360 /// The \c useNodes() and \c useArcs() functions are used to specify 361 /// that the nodes or arcs should not be constructed(added to the 362 /// graph) during the reading, the argument of these functions is a 363 /// node map or arc map determining the label map for the items. An 364 /// application of these function is the multipass reading, which is 365 /// important if two \e \@arcs sections should be read from the 366 /// file. In this example the first phase reads the node set and one 367 /// of the arc set, while the second phase will read the second arc 368 /// set into an \e ArcSet class (\c SmartArcSet or \c ListArcSet), 369 /// the previously read label node map should be given to the \c 370 /// useNodes() functions. An other multipass application is reading 371 /// paths into a node map or an arc map. It is impossible in 372 /// single pass, because the arcs are not constructed when the node 373 /// maps are read. 300 374 template <typename _Digraph> 301 375 class DigraphReader { 302 376 public: … … 341 415 342 416 public: 343 417 344 /// \e 418 /// \brief Constructor 419 /// 420 /// Construct a directed graph reader, which reads from the given 421 /// input stream. 345 422 DigraphReader(std::istream& is, Digraph& digraph) 346 423 : _is(&is), local_is(false), _digraph(digraph), 347 424 _use_nodes(false), _use_arcs(false) {} 348 425 349 /// \e 426 /// \brief Constructor 427 /// 428 /// Construct a directed graph reader, which reads from the given 429 /// file. 350 430 DigraphReader(const std::string& fn, Digraph& digraph) 351 431 : _is(new std::ifstream(fn.c_str())), local_is(true), _digraph(digraph), 352 432 _use_nodes(false), _use_arcs(false) {} 353 354 355 /// \e 433 434 /// \brief Constructor 435 /// 436 /// Construct a directed graph reader, which reads from the given 437 /// file. 356 438 DigraphReader(const char* fn, Digraph& digraph) 357 439 : _is(new std::ifstream(fn)), local_is(true), _digraph(digraph), 358 440 _use_nodes(false), _use_arcs(false) {} 359 441 360 /// \e 442 /// \brief Copy constructor 443 /// 444 /// The copy constructor transfers all data from the other reader, 445 /// therefore the copied reader will not be useable more. 361 446 DigraphReader(DigraphReader& other) 362 447 : _is(other._is), local_is(other.local_is), _digraph(other._digraph), 363 448 _use_nodes(other._use_nodes), _use_arcs(other._use_arcs) { … … 377 462 _attributes_caption = other._attributes_caption; 378 463 } 379 464 380 /// \ e465 /// \brief Destructor 381 466 ~DigraphReader() { 382 467 for (typename NodeMaps::iterator it = _node_maps.begin(); 383 468 it != _node_maps.end(); ++it) { … … 406 491 407 492 public: 408 493 409 /// \e 494 /// \name Reading rules 495 /// @{ 496 497 /// \brief Node map reading rule 498 /// 499 /// Add a node map reading rule to the reader. 410 500 template <typename Map> 411 501 DigraphReader& nodeMap(const std::string& caption, Map& map) { 412 502 checkConcept<concepts::WriteMap<Node, typename Map::Value>, Map>(); … … 416 506 return *this; 417 507 } 418 508 419 /// \e 509 /// \brief Node map reading rule 510 /// 511 /// Add a node map reading rule with specialized converter to the 512 /// reader. 420 513 template <typename Map, typename Converter> 421 514 DigraphReader& nodeMap(const std::string& caption, Map& map, 422 515 const Converter& converter = Converter()) { … … 427 520 return *this; 428 521 } 429 522 430 /// \e 523 /// \brief Arc map reading rule 524 /// 525 /// Add an arc map reading rule to the reader. 431 526 template <typename Map> 432 527 DigraphReader& arcMap(const std::string& caption, Map& map) { 433 528 checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>(); … … 437 532 return *this; 438 533 } 439 534 440 /// \e 535 /// \brief Arc map reading rule 536 /// 537 /// Add an arc map reading rule with specialized converter to the 538 /// reader. 441 539 template <typename Map, typename Converter> 442 540 DigraphReader& arcMap(const std::string& caption, Map& map, 443 541 const Converter& converter = Converter()) { … … 448 546 return *this; 449 547 } 450 548 451 /// \e 549 /// \brief Attribute reading rule 550 /// 551 /// Add an attribute reading rule to the reader. 452 552 template <typename Value> 453 553 DigraphReader& attribute(const std::string& caption, Value& value) { 454 554 _reader_bits::ValueStorageBase* storage = … … 457 557 return *this; 458 558 } 459 559 460 /// \e 560 /// \brief Attribute reading rule 561 /// 562 /// Add an attribute reading rule with specialized converter to the 563 /// reader. 461 564 template <typename Value, typename Converter> 462 565 DigraphReader& attribute(const std::string& caption, Value& value, 463 566 const Converter& converter = Converter()) { … … 467 570 return *this; 468 571 } 469 572 470 /// \e 573 /// \brief Node reading rule 574 /// 575 /// Add a node reading rule to reader. 471 576 DigraphReader& node(const std::string& caption, Node& node) { 472 577 typedef _reader_bits::MapLookUpConverter<Node> Converter; 473 578 Converter converter(_node_index); … … 477 582 return *this; 478 583 } 479 584 480 /// \e 585 /// \brief Arc reading rule 586 /// 587 /// Add an arc reading rule to reader. 481 588 DigraphReader& arc(const std::string& caption, Arc& arc) { 482 589 typedef _reader_bits::MapLookUpConverter<Arc> Converter; 483 590 Converter converter(_arc_index); … … 487 594 return *this; 488 595 } 489 596 490 /// \e 597 /// @} 598 599 /// \name Select section by name 600 /// @{ 601 602 /// \brief Set \c \@nodes section to be read 603 /// 604 /// Set \c \@nodes section to be read 491 605 DigraphReader& nodes(const std::string& caption) { 492 606 _nodes_caption = caption; 493 607 return *this; 494 608 } 495 609 496 /// \e 610 /// \brief Set \c \@arcs section to be read 611 /// 612 /// Set \c \@arcs section to be read 497 613 DigraphReader& arcs(const std::string& caption) { 498 614 _arcs_caption = caption; 499 615 return *this; 500 616 } 501 617 502 /// \e 618 /// \brief Set \c \@attributes section to be read 619 /// 620 /// Set \c \@attributes section to be read 503 621 DigraphReader& attributes(const std::string& caption) { 504 622 _attributes_caption = caption; 505 623 return *this; 506 624 } 507 625 508 /// \e 626 /// @} 627 628 /// \name Using previously constructed node or arc set 629 /// @{ 630 631 /// \brief Use previously constructed node set 632 /// 633 /// Use previously constructed node set, and specify the node 634 /// label map. 509 635 template <typename Map> 510 636 DigraphReader& useNodes(const Map& map) { 511 637 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>(); … … 518 644 return *this; 519 645 } 520 646 521 /// \e 647 /// \brief Use previously constructed node set 648 /// 649 /// Use previously constructed node set, and specify the node 650 /// label map and a functor which converts the label map values to 651 /// std::string. 522 652 template <typename Map, typename Converter> 523 653 DigraphReader& useNodes(const Map& map, 524 654 const Converter& converter = Converter()) { … … 531 661 return *this; 532 662 } 533 663 534 /// \e 664 /// \brief Use previously constructed arc set 665 /// 666 /// Use previously constructed arc set, and specify the arc 667 /// label map. 535 668 template <typename Map> 536 669 DigraphReader& useArcs(const Map& map) { 537 670 checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>(); … … 544 677 return *this; 545 678 } 546 679 547 /// \e 680 /// \brief Use previously constructed arc set 681 /// 682 /// Use previously constructed arc set, and specify the arc 683 /// label map and a functor which converts the label map values to 684 /// std::string. 548 685 template <typename Map, typename Converter> 549 686 DigraphReader& useArcs(const Map& map, 550 687 const Converter& converter = Converter()) { … … 556 693 } 557 694 return *this; 558 695 } 696 697 /// @} 559 698 560 699 private: 561 700 … … 597 736 598 737 std::string map; 599 738 int index = 0; 600 while (_reader_bits::read Identifier(line, map)) {739 while (_reader_bits::readToken(line, map)) { 601 740 if (maps.find(map) != maps.end()) { 602 741 std::ostringstream msg; 603 742 msg << "Multiple occurence of node map: " << map; … … 680 819 681 820 std::string map; 682 821 int index = 0; 683 while (_reader_bits::read Identifier(line, map)) {822 while (_reader_bits::readToken(line, map)) { 684 823 if (maps.find(map) != maps.end()) { 685 824 std::ostringstream msg; 686 825 msg << "Multiple occurence of arc map: " << map; … … 787 926 line.putback(c); 788 927 789 928 std::string attr, token; 790 if (!_reader_bits::read Identifier(line, attr))929 if (!_reader_bits::readToken(line, attr)) 791 930 throw DataFormatError("Attribute name not found"); 792 931 if (!_reader_bits::readToken(line, token)) 793 932 throw DataFormatError("Attribute value not found"); … … 827 966 } 828 967 829 968 public: 830 831 /// \e 969 970 /// \name Execution of the reader 971 /// @{ 972 973 /// \brief Start the batch processing 974 /// 975 /// This function starts the batch processing 832 976 void run() { 833 977 834 978 LEMON_ASSERT(_is != 0, "This reader assigned to an other reader"); … … 846 990 char c; 847 991 std::string section, caption; 848 992 line >> c; 849 _reader_bits::read Identifier(line, section);850 _reader_bits::read Identifier(line, caption);993 _reader_bits::readToken(line, section); 994 _reader_bits::readToken(line, caption); 851 995 852 996 if (line >> c) 853 997 throw DataFormatError("Extra character on the end of line"); … … 891 1035 } 892 1036 893 1037 } 1038 1039 /// @} 894 1040 895 1041 }; 896 1042 1043 /// \relates DigraphReader 897 1044 template <typename Digraph> 898 1045 DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph) { 899 1046 return DigraphReader<Digraph>(is, digraph); 900 1047 } 901 1048 1049 /// \relates DigraphReader 902 1050 template <typename Digraph> 903 1051 DigraphReader<Digraph> digraphReader(const std::string& fn, 904 1052 Digraph& digraph) { 905 1053 return DigraphReader<Digraph>(fn, digraph); 906 1054 } 907 1055 1056 /// \relates DigraphReader 908 1057 template <typename Digraph> 909 1058 DigraphReader<Digraph> digraphReader(const char* fn, Digraph& digraph) { 910 1059 return DigraphReader<Digraph>(fn, digraph); -
lemon/lgf_writer.h
diff -r 5c3604513ed0 -r a765b4ecbcdb lemon/lgf_writer.h
a b 204 204 } 205 205 206 206 bool requireEscape(const std::string& str) { 207 if (str.empty() || str[0] == '@') return true; 207 208 std::istringstream is(str); 208 209 char c; 209 210 while (is.get(c)) { … … 231 232 232 233 } 233 234 234 /// \e 235 /// \ingroup lemon_io 236 /// 237 /// \brief LGF writer for directed graphs 238 /// 239 /// The \e LGF (LEMON graph file) format is the default file format 240 /// of the LEMON library. It is a text based, section oriented 241 /// format, which defines some standard sections for storing graphs 242 /// in text files. Each line with \c '#' first non-whitespace 243 /// character is considered as a comment line. Each section starts with 244 /// a header line, these lines starts with \c '@' character and the 245 /// name of section type. The standard sections are \c \@nodes, \c 246 /// \@arcs and \c \@edges (these two names are completely equivalent) 247 /// and \@attributes. Each header line may also have an optional 248 /// name, which can be use to distinguish the sections of the same 249 /// type. 250 /// 251 /// The \@nodes section describes a set of nodes and associated 252 /// maps. The first is a header line consisting of the names of the 253 /// maps, each of them is a plain or quoted token. A plain token is 254 /// a sequence of non-whitespace characters, and a quoted token is a 255 /// character sequence surrounded by double quotes, and the sequence 256 /// may contain escape sequences. One of the maps must be called \c 257 /// "label", which plays special role in the file. Each following 258 /// non-empty line until the next section describes a node in the 259 /// graph. These lines contain the values of the node maps 260 /// associated to the current node, each value is also plain or 261 /// quoted token. 262 /// 263 /// The \c \@arcs section is very similar to the \c \@nodes section, 264 /// it starts with a header line consists from the names of the arc 265 /// maps, the \c "label" map is also necessary. The following lines 266 /// contain the description of the arcs. The first two tokens are 267 /// the source and the target node of the edge, then comes the map 268 /// values. The source and target tokens must be node labels. 269 /// 270 /// The \c \@attributes section contains key-value pairs, each line 271 /// starts with an attribute nome, and then an attribute value. Both 272 /// of them are plain or quoted tokens, but the value could be also 273 /// a node or an arc label. 274 /// 275 ///\code 276 /// @nodes 277 /// label coordinates size title 278 /// 1 (10,20) 10 "First node" 279 /// 2 (80,80) 8 "Second node" 280 /// 3 (40,10) 10 "Third node" 281 /// @arcs 282 /// capacity 283 /// 1 2 16 284 /// 1 3 12 285 /// 2 3 18 286 /// @attributes 287 /// source 1 288 /// target 3 289 /// caption "LEMON test digraph" 290 ///\endcode 291 /// 292 /// The reading method does a batch processing. The user creates a 293 /// writer object, then several reading rules can be added to the 294 /// writer, and eventually the reading is executed with the \c run() 295 /// member function. A map reading rule can be added to the writer 296 /// with the \c nodeMap() or \c arcMap() members. The optional 297 /// converter parameter can be a standard functor, which converts an 298 /// std::string to the value type of the map, if it is set, it 299 /// determines how the read string literal is converted to the map's 300 /// value type. If the functor is not set, then a default conversion 301 /// will be used. One map can be read in multiple map objects at the 302 /// same time. The \c attribute(), \c node() and \c arc() functions 303 /// are used to add attribute reading rules. 304 /// 305 ///\code 306 /// DigraphWriter<Digraph>(std::cin, digraph). 307 /// nodeMap("coordinates", coord_map). 308 /// arcMap("capacity", cap_map). 309 /// node("source", src). 310 /// node("target", trg). 311 /// attribute("caption", caption). 312 /// run(); 313 ///\endcode 314 /// 315 /// By default the writer does not write additional captions to the 316 /// section, but they can added with the \c nodes(), \c arcs() or \c 317 /// attributes() functions. 318 /// 319 /// The \c skipNodes() and \c skipArcs() functions forbid the 320 /// writing of the sections. If two arc sections should write to the 321 /// output, it can be made in two passes, the first pass writes the 322 /// node section and the first arc section, then the second pass 323 /// skips the node section and writes just the arc section to the 324 /// stream. The output stream can be retrieved with the \c ostream() 325 /// function, hence the second pass can append the output of the 326 /// first pass. 235 327 template <typename _Digraph> 236 328 class DigraphWriter { 237 329 public: … … 273 365 274 366 public: 275 367 276 /// \e 368 /// \brief Constructor 369 /// 370 /// Construct a directed graph writer, which writes to the given 371 /// output stream. 277 372 DigraphWriter(std::ostream& is, Digraph& digraph) 278 373 : _os(&is), local_os(false), _digraph(digraph), 279 374 _skip_nodes(false), _skip_arcs(false) {} 280 375 281 /// \e 376 /// \brief Constructor 377 /// 378 /// Construct a directed graph writer, which writes to the given 379 /// output file. 282 380 DigraphWriter(const std::string& fn, Digraph& digraph) 283 381 : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph), 284 382 _skip_nodes(false), _skip_arcs(false) {} 285 383 286 /// \e 384 /// \brief Constructor 385 /// 386 /// Construct a directed graph writer, which writes to the given 387 /// output file. 287 388 DigraphWriter(const char* fn, Digraph& digraph) 288 389 : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph), 289 390 _skip_nodes(false), _skip_arcs(false) {} 290 391 392 /// \brief Copy constructor 393 /// 394 /// The copy constructor transfers all data from the other writer, 395 /// therefore the copied writer will not be useable more. 291 396 DigraphWriter(DigraphWriter& other) 292 397 : _os(other._os), local_os(other.local_os), _digraph(other._digraph), 293 398 _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) { … … 307 412 _attributes_caption = other._attributes_caption; 308 413 } 309 414 310 /// \ e415 /// \brief Destructor 311 416 ~DigraphWriter() { 312 417 for (typename NodeMaps::iterator it = _node_maps.begin(); 313 418 it != _node_maps.end(); ++it) { … … 335 440 336 441 public: 337 442 338 /// \e 443 /// \name Writing rules 444 /// @{ 445 446 /// \brief Node map reading rule 447 /// 448 /// Add a node map reading rule to the writer. 339 449 template <typename Map> 340 450 DigraphWriter& nodeMap(const std::string& caption, const Map& map) { 341 451 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>(); … … 345 455 return *this; 346 456 } 347 457 348 /// \e 458 /// \brief Node map writing rule 459 /// 460 /// Add a node map writing rule with specialized converter to the 461 /// writer. 349 462 template <typename Map, typename Converter> 350 463 DigraphWriter& nodeMap(const std::string& caption, const Map& map, 351 464 const Converter& converter = Converter()) { … … 356 469 return *this; 357 470 } 358 471 359 /// \e 472 /// \brief Arc map writing rule 473 /// 474 /// Add an arc map writing rule to the writer. 360 475 template <typename Map> 361 476 DigraphWriter& arcMap(const std::string& caption, const Map& map) { 362 477 checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>(); … … 366 481 return *this; 367 482 } 368 483 369 /// \e 484 /// \brief Arc map writing rule 485 /// 486 /// Add an arc map writing rule with specialized converter to the 487 /// writer. 370 488 template <typename Map, typename Converter> 371 489 DigraphWriter& arcMap(const std::string& caption, const Map& map, 372 490 const Converter& converter = Converter()) { … … 377 495 return *this; 378 496 } 379 497 380 /// \e 498 /// \brief Attribute writing rule 499 /// 500 /// Add an attribute writing rule to the writer. 381 501 template <typename Value> 382 502 DigraphWriter& attribute(const std::string& caption, const Value& value) { 383 503 _writer_bits::ValueStorageBase* storage = … … 386 506 return *this; 387 507 } 388 508 389 /// \e 509 /// \brief Attribute writing rule 510 /// 511 /// Add an attribute writing rule with specialized converter to the 512 /// writer. 390 513 template <typename Value, typename Converter> 391 514 DigraphWriter& attribute(const std::string& caption, const Value& value, 392 515 const Converter& converter = Converter()) { … … 396 519 return *this; 397 520 } 398 521 399 /// \e 522 /// \brief Node writing rule 523 /// 524 /// Add a node writing rule to the writer. 400 525 DigraphWriter& node(const std::string& caption, const Node& node) { 401 526 typedef _writer_bits::MapLookUpConverter<Node> Converter; 402 527 Converter converter(_node_index); … … 406 531 return *this; 407 532 } 408 533 409 /// \e 534 /// \brief Arc writing rule 535 /// 536 /// Add an arc writing rule to writer. 410 537 DigraphWriter& arc(const std::string& caption, const Arc& arc) { 411 538 typedef _writer_bits::MapLookUpConverter<Arc> Converter; 412 539 Converter converter(_arc_index); … … 416 543 return *this; 417 544 } 418 545 419 /// \e 546 /// \name Select section by name 547 /// @{ 548 549 /// \brief Set \c \@nodes section to be read 550 /// 551 /// Set \c \@nodes section to be read 420 552 DigraphWriter& nodes(const std::string& caption) { 421 553 _nodes_caption = caption; 422 554 return *this; 423 555 } 424 556 425 /// \e 557 /// \brief Set \c \@arcs section to be read 558 /// 559 /// Set \c \@arcs section to be read 426 560 DigraphWriter& arcs(const std::string& caption) { 427 561 _arcs_caption = caption; 428 562 return *this; 429 563 } 430 564 431 /// \e 565 /// \brief Set \c \@attributes section to be read 566 /// 567 /// Set \c \@attributes section to be read 432 568 DigraphWriter& attributes(const std::string& caption) { 433 569 _attributes_caption = caption; 434 570 return *this; 435 571 } 436 572 573 /// \name Skipping section 574 /// @{ 575 576 /// \brief Skip writing the node set 577 /// 578 /// The \c \@nodes section will be not written to the stream. 437 579 DigraphWriter& skipNodes() { 438 580 LEMON_ASSERT(!_skip_nodes, "Multiple usage of skipNodes() member"); 439 581 return *this; 440 582 } 441 583 584 /// \brief Skip writing arc set 585 /// 586 /// The \c \@arcs section will be not written to the stream. 442 587 DigraphWriter& skipArcs() { 443 588 LEMON_ASSERT(!_skip_arcs, "Multiple usage of skipArcs() member"); 444 589 return *this; 445 590 } 591 592 /// @} 446 593 447 594 private: 448 595 … … 458 605 459 606 *_os << "@nodes"; 460 607 if (!_nodes_caption.empty()) { 461 *_os << ' ' << _nodes_caption;608 _writer_bits::writeToken(*_os << ' ', _nodes_caption); 462 609 } 463 610 *_os << std::endl; 464 611 … … 467 614 } 468 615 for (typename NodeMaps::iterator it = _node_maps.begin(); 469 616 it != _node_maps.end(); ++it) { 470 *_os << it->first<< '\t';617 _writer_bits::writeToken(*_os, it->first) << '\t'; 471 618 } 472 619 *_os << std::endl; 473 620 … … 518 665 519 666 *_os << "@arcs"; 520 667 if (!_arcs_caption.empty()) { 521 *_os << ' ' << _arcs_caption;668 _writer_bits::writeToken(*_os << ' ', _arcs_caption); 522 669 } 523 670 *_os << std::endl; 524 671 … … 528 675 } 529 676 for (typename ArcMaps::iterator it = _arc_maps.begin(); 530 677 it != _arc_maps.end(); ++it) { 531 *_os << it->first<< '\t';678 _writer_bits::writeToken(*_os, it->first) << '\t'; 532 679 } 533 680 *_os << std::endl; 534 681 … … 577 724 if (_attributes.empty()) return; 578 725 *_os << "@attributes"; 579 726 if (!_attributes_caption.empty()) { 580 *_os << ' ' << _attributes_caption;727 _writer_bits::writeToken(*_os << ' ', _attributes_caption); 581 728 } 582 729 *_os << std::endl; 583 730 for (typename Attributes::iterator it = _attributes.begin(); 584 731 it != _attributes.end(); ++it) { 585 *_os << it->first<< ' ';732 _writer_bits::writeToken(*_os, it->first) << ' '; 586 733 _writer_bits::writeToken(*_os, it->second->get()); 587 734 *_os << std::endl; 588 735 } … … 590 737 591 738 public: 592 739 593 /// \e 740 /// \name Execution of the writer 741 /// @{ 742 743 /// \brief Start the batch processing 744 /// 745 /// This function starts the batch processing 594 746 void run() { 595 747 if (!_skip_nodes) { 596 748 writeNodes(); … … 601 753 writeAttributes(); 602 754 } 603 755 604 /// \e 605 std::ostream& stream() { 756 /// \brief Gives back the stream of the writer 757 /// 758 /// Gives back the stream of the writer 759 std::ostream& ostream() { 606 760 return *_os; 607 761 } 762 763 /// @} 608 764 }; 609 765 766 /// \relates DigraphWriter 610 767 template <typename Digraph> 611 768 DigraphWriter<Digraph> digraphWriter(std::istream& is, Digraph& digraph) { 612 769 return DigraphWriter<Digraph>(is, digraph); 613 770 } 614 771 772 /// \relates DigraphWriter 615 773 template <typename Digraph> 616 774 DigraphWriter<Digraph> digraphWriter(const std::string& fn, 617 775 Digraph& digraph) { 618 776 return DigraphWriter<Digraph>(fn, digraph); 619 777 } 620 778 779 /// \relates DigraphWriter 621 780 template <typename Digraph> 622 781 DigraphWriter<Digraph> digraphWriter(const char* fn, Digraph& digraph) { 623 782 return DigraphWriter<Digraph>(fn, digraph);