Introduce version 0.1
[dueringa_WikiWalker.git] / src / ToGraphvizWriter.cpp
blob7f031fcde4089aa69eeb4562d5642addab10a6c2
1 //! \file ToGraphvizWriter.cpp
3 #include "ToGraphvizWriter.h"
5 #include <string>
7 #include "Article.h"
9 void ToGraphvizWriter::writeHeader(std::ostream& os)
11 os << "digraph G {";
12 os << std::endl;
15 void ToGraphvizWriter::writeFooter(std::ostream& os)
17 os << "}";
18 os << std::endl;
21 /*! \bug When writing an #Article only, attributes are only set on the article
22 * itself. Attributes won't be written on linked articles.
23 * However, when writing an #ArticleCollection, all articles are included, so
24 * all attibutes will be written.
26 void ToGraphvizWriter::writeArticle(const Article* a, std::ostream& os)
28 // marked articles are printed as box
29 if(a->isMarked()) {
30 os << "\"" << a->getTitle() << "\" [shape=box];" << std::endl;
33 if(!a->isAnalyzed()) {
34 os << "\"" << a->getTitle() << "\" [fillcolor=gray,style=filled];" << std::endl;
37 // unanalyzed articles are printed greyed out
38 for(auto al = a->linkBegin(); al != a->linkEnd(); al++) {
39 os << "\"" << a->getTitle() << "\" -> \"" << (*al)->getTitle() << "\";" << std::endl;
43 void ToGraphvizWriter::output(const Article* a, std::ostream& os)
45 writeHeader(os);
47 writeArticle(a, os);
49 writeFooter(os);
52 void ToGraphvizWriter::output(const ArticleCollection& ac, std::ostream& os)
54 writeHeader(os);
56 for(auto a : ac) {
57 writeArticle(a.second, os);
60 writeFooter(os);