127 edge_writer(*writer, edgeset_writer, std::string()), |
130 edge_writer(*writer, edgeset_writer, std::string()), |
128 attribute_writer(*writer, std::string()) {} |
131 attribute_writer(*writer, std::string()) {} |
129 |
132 |
130 /// \brief Construct a new GraphWriter. |
133 /// \brief Construct a new GraphWriter. |
131 /// |
134 /// |
132 /// Construct a new GraphWriter. It writes into the given graph |
135 /// This function constructs a new GraphWriter to write the given graph |
133 /// to given LemonReader. |
136 /// to the given LemonReader. |
134 GraphWriter(LemonWriter& _writer, const Graph& _graph) |
137 GraphWriter(LemonWriter& _writer, const Graph& _graph) |
135 : writer(_writer), own_writer(false), |
138 : writer(_writer), own_writer(false), |
136 nodeset_writer(*writer, _graph, std::string()), |
139 nodeset_writer(*writer, _graph, std::string()), |
137 edgeset_writer(*writer, _graph, nodeset_writer, std::string()), |
140 edgeset_writer(*writer, _graph, nodeset_writer, std::string()), |
138 node_writer(*writer, nodeset_writer, std::string()), |
141 node_writer(*writer, nodeset_writer, std::string()), |
139 edge_writer(*writer, edgeset_writer, std::string()), |
142 edge_writer(*writer, edgeset_writer, std::string()), |
140 attribute_writer(*writer, std::string()) {} |
143 attribute_writer(*writer, std::string()) {} |
141 |
144 |
142 /// \brief Destruct the graph writer. |
145 /// \brief Destruct the graph writer. |
143 /// |
146 /// |
144 /// Destruct the graph writer. |
147 /// This function destructs the graph writer. |
145 ~GraphWriter() { |
148 ~GraphWriter() { |
146 if (own_writer) |
149 if (own_writer) |
147 delete writer; |
150 delete writer; |
148 } |
151 } |
149 |
152 |
150 /// \brief Add a new node map writer command for the writer. |
153 /// \brief Issue a new node map writing command for the writer. |
151 /// |
154 /// |
152 /// Add a new node map writer command for the writer. |
155 /// This function issues a new <i> node map writing command</i> to the writer. |
153 template <typename Map> |
156 template <typename Map> |
154 GraphWriter& writeNodeMap(std::string name, const Map& map) { |
157 GraphWriter& writeNodeMap(std::string name, const Map& map) { |
155 nodeset_writer.writeNodeMap(name, map); |
158 nodeset_writer.writeNodeMap(name, map); |
156 return *this; |
159 return *this; |
157 } |
160 } |
158 |
161 |
159 /// \brief Add a new node map writer command for the writer. |
162 /// \brief Issue a new node map writing command for the writer. |
160 /// |
163 /// |
161 /// Add a new node map writer command for the writer. |
164 /// This function issues a new <i> node map writing command</i> to the writer. |
162 template <typename Writer, typename Map> |
165 template <typename Writer, typename Map> |
163 GraphWriter& writeNodeMap(std::string name, const Map& map, |
166 GraphWriter& writeNodeMap(std::string name, const Map& map, |
164 const Writer& writer = Writer()) { |
167 const Writer& writer = Writer()) { |
165 nodeset_writer.writeNodeMap(name, map, writer); |
168 nodeset_writer.writeNodeMap(name, map, writer); |
166 return *this; |
169 return *this; |
167 } |
170 } |
168 |
171 |
169 |
172 |
170 /// \brief Add a new edge map writer command for the writer. |
173 /// \brief Issue a new edge map writing command for the writer. |
171 /// |
174 /// |
172 /// Add a new edge map writer command for the writer. |
175 /// This function issues a new <i> edge map writing command</i> to the writer. |
173 template <typename Map> |
176 template <typename Map> |
174 GraphWriter& writeEdgeMap(std::string name, const Map& map) { |
177 GraphWriter& writeEdgeMap(std::string name, const Map& map) { |
175 edgeset_writer.writeEdgeMap(name, map); |
178 edgeset_writer.writeEdgeMap(name, map); |
176 return *this; |
179 return *this; |
177 } |
180 } |
178 |
181 |
179 |
182 |
180 /// \brief Add a new edge map writer command for the writer. |
183 /// \brief Issue a new edge map writing command for the writer. |
181 /// |
184 /// |
182 /// Add a new edge map writer command for the writer. |
185 /// This function issues a new <i> edge map writing command</i> to the writer. |
183 template <typename Writer, typename Map> |
186 template <typename Writer, typename Map> |
184 GraphWriter& writeEdgeMap(std::string name, const Map& map, |
187 GraphWriter& writeEdgeMap(std::string name, const Map& map, |
185 const Writer& writer = Writer()) { |
188 const Writer& writer = Writer()) { |
186 edgeset_writer.writeEdgeMap(name, map, writer); |
189 edgeset_writer.writeEdgeMap(name, map, writer); |
187 return *this; |
190 return *this; |
188 } |
191 } |
189 |
192 |
190 /// \brief Add a new labeled node writer for the writer. |
193 /// \brief Issue a new labeled node writing command to the writer. |
191 /// |
194 /// |
192 /// Add a new labeled node writer for the writer. |
195 /// This function issues a new <i> labeled node writing command</i> |
|
196 /// to the writer. |
193 GraphWriter& writeNode(std::string name, const Node& node) { |
197 GraphWriter& writeNode(std::string name, const Node& node) { |
194 node_writer.writeNode(name, node); |
198 node_writer.writeNode(name, node); |
195 return *this; |
199 return *this; |
196 } |
200 } |
197 |
201 |
198 /// \brief Add a new labeled edge writer for the writer. |
202 /// \brief Issue a new labeled edge writing command to the writer. |
199 /// |
203 /// |
200 /// Add a new labeled edge writer for the writer. |
204 /// This function issues a new <i> labeled edge writing command</i> |
|
205 /// to the writer. |
201 GraphWriter& writeEdge(std::string name, const Edge& edge) { |
206 GraphWriter& writeEdge(std::string name, const Edge& edge) { |
202 edge_writer.writeEdge(name, edge); |
207 edge_writer.writeEdge(name, edge); |
203 } |
208 } |
204 |
209 |
205 /// \brief Add a new attribute writer command. |
210 /// \brief Issue a new attribute writing command. |
206 /// |
211 /// |
207 /// Add a new attribute writer command. |
212 /// This function issues a new <i> attribute writing command</i> |
|
213 /// to the writer. |
208 template <typename Value> |
214 template <typename Value> |
209 GraphWriter& writeAttribute(std::string name, const Value& value) { |
215 GraphWriter& writeAttribute(std::string name, const Value& value) { |
210 attribute_writer.writeAttribute(name, value); |
216 attribute_writer.writeAttribute(name, value); |
211 return *this; |
217 return *this; |
212 } |
218 } |
213 |
219 |
214 /// \brief Add a new attribute writer command. |
220 /// \brief Issue a new attribute writing command. |
215 /// |
221 /// |
216 /// Add a new attribute writer command. |
222 /// This function issues a new <i> attribute writing command</i> |
|
223 /// to the writer. |
217 template <typename Writer, typename Value> |
224 template <typename Writer, typename Value> |
218 GraphWriter& writeAttribute(std::string name, const Value& value, |
225 GraphWriter& writeAttribute(std::string name, const Value& value, |
219 const Writer& writer) { |
226 const Writer& writer) { |
220 attribute_writer.writeAttribute<Writer>(name, value, writer); |
227 attribute_writer.writeAttribute<Writer>(name, value, writer); |
221 return *this; |
228 return *this; |
222 } |
229 } |
223 |
230 |
224 /// \brief Conversion operator to LemonWriter. |
231 /// \brief Conversion operator to LemonWriter. |
225 /// |
232 /// |
226 /// Conversion operator to LemonWriter. It make possible |
233 /// Conversion operator to LemonWriter. It makes possible |
227 /// to access the encapsulated \e LemonWriter, this way |
234 /// to access the encapsulated \e LemonWriter, this way |
228 /// you can attach to this writer new instances of |
235 /// you can attach to this writer new instances of |
229 /// \e LemonWriter::SectionWriter. |
236 /// \e LemonWriter::SectionWriter. |
230 operator LemonWriter&() { |
237 operator LemonWriter&() { |
231 return *writer; |
238 return *writer; |
232 } |
239 } |
233 |
240 |
234 /// \brief Executes the writer commands. |
241 /// \brief Executes the writing commands. |
235 /// |
242 /// |
236 /// Executes the writer commands. |
243 /// Executes the writing commands. |
237 void run() { |
244 void run() { |
238 writer->run(); |
245 writer->run(); |
239 } |
246 } |
240 |
247 |
241 /// \brief Write the id of the given node. |
248 /// \brief Write the id of the given node. |
242 /// |
249 /// |
243 /// It writes the id of the given node. If there was written an "id" |
250 /// It writes the id of the given node. If there was written an "id" |
244 /// named node map then it will write the map value belongs to the node. |
251 /// named node map then it will write the map value belonging to the node. |
245 void writeId(std::ostream& os, const Node& item) const { |
252 void writeId(std::ostream& os, const Node& item) const { |
246 nodeset_writer.writeId(os, item); |
253 nodeset_writer.writeId(os, item); |
247 } |
254 } |
248 |
255 |
249 /// \brief Write the id of the given edge. |
256 /// \brief Write the id of the given edge. |
250 /// |
257 /// |
251 /// It writes the id of the given edge. If there was written an "id" |
258 /// It writes the id of the given edge. If there was written an "id" |
252 /// named edge map then it will write the map value belongs to the edge. |
259 /// named edge map then it will write the map value belonging to the edge. |
253 void writeId(std::ostream& os, const Edge& item) const { |
260 void writeId(std::ostream& os, const Edge& item) const { |
254 edgeset_writer.writeId(os, item); |
261 edgeset_writer.writeId(os, item); |
255 } |
262 } |
256 |
263 |
257 private: |
264 private: |
493 ~UndirGraphWriter() { |
500 ~UndirGraphWriter() { |
494 if (own_writer) |
501 if (own_writer) |
495 delete writer; |
502 delete writer; |
496 } |
503 } |
497 |
504 |
498 /// \brief Add a new node map writer command for the writer. |
505 /// \brief Issue a new node map writing command to the writer. |
499 /// |
506 /// |
500 /// Add a new node map writer command for the writer. |
507 /// This function issues a new <i> node map writing command</i> to the writer. |
501 template <typename Map> |
508 template <typename Map> |
502 UndirGraphWriter& writeNodeMap(std::string name, const Map& map) { |
509 UndirGraphWriter& writeNodeMap(std::string name, const Map& map) { |
503 nodeset_writer.writeNodeMap(name, map); |
510 nodeset_writer.writeNodeMap(name, map); |
504 return *this; |
511 return *this; |
505 } |
512 } |
506 |
513 |
507 /// \brief Add a new node map writer command for the writer. |
514 /// \brief Issue a new node map writing command to the writer. |
508 /// |
515 /// |
509 /// Add a new node map writer command for the writer. |
516 /// This function issues a new <i> node map writing command</i> to the writer. |
510 template <typename Writer, typename Map> |
517 template <typename Writer, typename Map> |
511 UndirGraphWriter& writeNodeMap(std::string name, const Map& map, |
518 UndirGraphWriter& writeNodeMap(std::string name, const Map& map, |
512 const Writer& writer = Writer()) { |
519 const Writer& writer = Writer()) { |
513 nodeset_writer.writeNodeMap(name, map, writer); |
520 nodeset_writer.writeNodeMap(name, map, writer); |
514 return *this; |
521 return *this; |
515 } |
522 } |
516 |
523 |
517 /// \brief Add a new edge map writer command for the writer. |
524 /// \brief Issue a new edge map writing command to the writer. |
518 /// |
525 /// |
519 /// Add a new edge map writer command for the writer. |
526 /// This function issues a new <i> edge map writing command</i> to the writer. |
520 template <typename Map> |
527 template <typename Map> |
521 UndirGraphWriter& writeEdgeMap(std::string name, const Map& map) { |
528 UndirGraphWriter& writeEdgeMap(std::string name, const Map& map) { |
522 undir_edgeset_writer.writeEdgeMap(name, map); |
529 undir_edgeset_writer.writeEdgeMap(name, map); |
523 return *this; |
530 return *this; |
524 } |
531 } |
525 |
532 |
526 /// \brief Add a new edge map writer command for the writer. |
533 /// \brief Issue a new edge map writing command to the writer. |
527 /// |
534 /// |
528 /// Add a new edge map writer command for the writer. |
535 /// This function issues a new <i> edge map writing command</i> to the writer. |
529 template <typename Writer, typename Map> |
536 template <typename Writer, typename Map> |
530 UndirGraphWriter& writeEdgeMap(std::string name, const Map& map, |
537 UndirGraphWriter& writeEdgeMap(std::string name, const Map& map, |
531 const Writer& writer = Writer()) { |
538 const Writer& writer = Writer()) { |
532 undir_edgeset_writer.writeEdgeMap(name, map, writer); |
539 undir_edgeset_writer.writeEdgeMap(name, map, writer); |
533 return *this; |
540 return *this; |
534 } |
541 } |
535 |
542 |
536 /// \brief Add a new undirected edge map writer command for the writer. |
543 /// \brief Issue a new undirected edge map writing command to the writer. |
537 /// |
544 /// |
538 /// Add a new undirected edge map writer command for the writer. |
545 /// This function issues a new <i> undirected edge map writing |
|
546 /// command</i> to the writer. |
539 template <typename Map> |
547 template <typename Map> |
540 UndirGraphWriter& writeUndirEdgeMap(std::string name, const Map& map) { |
548 UndirGraphWriter& writeUndirEdgeMap(std::string name, const Map& map) { |
541 undir_edgeset_writer.writeUndirEdgeMap(name, map); |
549 undir_edgeset_writer.writeUndirEdgeMap(name, map); |
542 return *this; |
550 return *this; |
543 } |
551 } |
544 |
552 |
545 /// \brief Add a new undirected edge map writer command for the writer. |
553 /// \brief Issue a new undirected edge map writing command to the writer. |
546 /// |
554 /// |
547 /// Add a new edge undirected map writer command for the writer. |
555 /// This function issues a new <i> undirected edge map writing |
|
556 /// command</i> to the writer. |
548 template <typename Writer, typename Map> |
557 template <typename Writer, typename Map> |
549 UndirGraphWriter& writeUndirEdgeMap(std::string name, const Map& map, |
558 UndirGraphWriter& writeUndirEdgeMap(std::string name, const Map& map, |
550 const Writer& writer = Writer()) { |
559 const Writer& writer = Writer()) { |
551 undir_edgeset_writer.writeUndirEdgeMap(name, map, writer); |
560 undir_edgeset_writer.writeUndirEdgeMap(name, map, writer); |
552 return *this; |
561 return *this; |
553 } |
562 } |
554 |
563 |
555 /// \brief Add a new labeled node writer for the writer. |
564 /// \brief Issue a new labeled node writer to the writer. |
556 /// |
565 /// |
557 /// Add a new labeled node writer for the writer. |
566 /// This function issues a new <i> labeled node writing |
|
567 /// command</i> to the writer. |
558 UndirGraphWriter& writeNode(std::string name, const Node& node) { |
568 UndirGraphWriter& writeNode(std::string name, const Node& node) { |
559 node_writer.writeNode(name, node); |
569 node_writer.writeNode(name, node); |
560 return *this; |
570 return *this; |
561 } |
571 } |
562 |
572 |
563 /// \brief Add a new labeled edge writer for the writer. |
573 /// \brief Issue a new labeled edge writer to the writer. |
564 /// |
574 /// |
565 /// Add a new labeled edge writer for the writer. |
575 /// This function issues a new <i> labeled edge writing |
|
576 /// command</i> to the writer. |
566 UndirGraphWriter& writeEdge(std::string name, const Edge& edge) { |
577 UndirGraphWriter& writeEdge(std::string name, const Edge& edge) { |
567 undir_edge_writer.writeEdge(name, edge); |
578 undir_edge_writer.writeEdge(name, edge); |
568 } |
579 } |
569 |
580 |
570 /// \brief Add a new labeled undirected edge writer for the writer. |
581 /// \brief Issue a new labeled undirected edge writing command to |
571 /// |
582 /// the writer. |
572 /// Add a new labeled undirected edge writer for the writer. |
583 /// |
|
584 /// Issue a new <i>labeled undirected edge writing command</i> to |
|
585 /// the writer. |
573 UndirGraphWriter& writeUndirEdge(std::string name, const UndirEdge& edge) { |
586 UndirGraphWriter& writeUndirEdge(std::string name, const UndirEdge& edge) { |
574 undir_edge_writer.writeUndirEdge(name, edge); |
587 undir_edge_writer.writeUndirEdge(name, edge); |
575 } |
588 } |
576 |
589 |
577 /// \brief Add a new attribute writer command. |
590 /// \brief Issue a new attribute writing command. |
578 /// |
591 /// |
579 /// Add a new attribute writer command. |
592 /// This function issues a new <i> attribute writing |
|
593 /// command</i> to the writer. |
580 template <typename Value> |
594 template <typename Value> |
581 UndirGraphWriter& writeAttribute(std::string name, const Value& value) { |
595 UndirGraphWriter& writeAttribute(std::string name, const Value& value) { |
582 attribute_writer.writeAttribute(name, value); |
596 attribute_writer.writeAttribute(name, value); |
583 return *this; |
597 return *this; |
584 } |
598 } |
585 |
599 |
586 /// \brief Add a new attribute writer command. |
600 /// \brief Issue a new attribute writing command. |
587 /// |
601 /// |
588 /// Add a new attribute writer command. |
602 /// This function issues a new <i> attribute writing |
|
603 /// command</i> to the writer. |
589 template <typename Writer, typename Value> |
604 template <typename Writer, typename Value> |
590 UndirGraphWriter& writeAttribute(std::string name, const Value& value, |
605 UndirGraphWriter& writeAttribute(std::string name, const Value& value, |
591 const Writer& writer) { |
606 const Writer& writer) { |
592 attribute_writer.writeAttribute<Writer>(name, value, writer); |
607 attribute_writer.writeAttribute<Writer>(name, value, writer); |
593 return *this; |
608 return *this; |
594 } |
609 } |
595 |
610 |
596 /// \brief Conversion operator to LemonWriter. |
611 /// \brief Conversion operator to LemonWriter. |
597 /// |
612 /// |
598 /// Conversion operator to LemonWriter. It make possible |
613 /// Conversion operator to LemonWriter. It makes possible |
599 /// to access the encapsulated \e LemonWriter, this way |
614 /// to access the encapsulated \e LemonWriter, this way |
600 /// you can attach to this writer new instances of |
615 /// you can attach to this writer new instances of |
601 /// \e LemonWriter::SectionWriter. |
616 /// \e LemonWriter::SectionWriter. |
602 operator LemonWriter&() { |
617 operator LemonWriter&() { |
603 return *writer; |
618 return *writer; |
604 } |
619 } |
605 |
620 |
606 /// \brief Executes the writer commands. |
621 /// \brief Executes the writing commands. |
607 /// |
622 /// |
608 /// Executes the writer commands. |
623 /// Executes the writing commands. |
609 void run() { |
624 void run() { |
610 writer->run(); |
625 writer->run(); |
611 } |
626 } |
612 |
627 |
613 /// \brief Write the id of the given node. |
628 /// \brief Write the id of the given node. |
614 /// |
629 /// |
615 /// It writes the id of the given node. If there was written an "id" |
630 /// It writes the id of the given node. If there was written an "id" |
616 /// named node map then it will write the map value belongs to the node. |
631 /// named node map then it will write the map value belonging to the node. |
617 void writeId(std::ostream& os, const Node& item) const { |
632 void writeId(std::ostream& os, const Node& item) const { |
618 nodeset_writer.writeId(os, item); |
633 nodeset_writer.writeId(os, item); |
619 } |
634 } |
620 |
635 |
621 /// \brief Write the id of the given edge. |
636 /// \brief Write the id of the given edge. |
622 /// |
637 /// |
623 /// It writes the id of the given edge. If there was written an "id" |
638 /// It writes the id of the given edge. If there was written an "id" |
624 /// named edge map then it will write the map value belongs to the edge. |
639 /// named edge map then it will write the map value belonging to the edge. |
625 void writeId(std::ostream& os, const Edge& item) const { |
640 void writeId(std::ostream& os, const Edge& item) const { |
626 undir_edgeset_writer.writeId(os, item); |
641 undir_edgeset_writer.writeId(os, item); |
627 } |
642 } |
628 |
643 |
629 /// \brief Write the id of the given undirected edge. |
644 /// \brief Write the id of the given undirected edge. |
630 /// |
645 /// |
631 /// It writes the id of the given undirected edge. If there was written |
646 /// It writes the id of the given undirected edge. If there was written |
632 /// an "id" named edge map then it will write the map value belongs to |
647 /// an "id" named edge map then it will write the map value belonging to |
633 /// the edge. |
648 /// the edge. |
634 void writeId(std::ostream& os, const UndirEdge& item) const { |
649 void writeId(std::ostream& os, const UndirEdge& item) const { |
635 undir_edgeset_writer.writeId(os, item); |
650 undir_edgeset_writer.writeId(os, item); |
636 } |
651 } |
637 |
652 |