1 //! \file ToGraphvizWriter.cpp
3 #include "ToGraphvizWriter.h"
13 static void writeHeader(std::ostream
& os
)
19 static void writeFooter(std::ostream
& os
)
25 /*! \bug When writing an #Article only, attributes are only set on the article
26 * itself. Attributes won't be written on linked articles.
27 * However, when writing an #ArticleCollection, all articles are included, so
28 * all attibutes will be written.
30 static void writeArticle(const Article
* a
, std::ostream
& os
)
32 std::string atitle
= a
->title();
35 std::regex
re(R
"(")");
36 // replace by escaped quote
37 atitle = std::regex_replace(atitle, re, R"(\")");
39 // marked articles are printed as box
41 os << R"(")" << atitle
<< R
"(" [shape
=box
];)" << std::endl;
45 os << R"(")" << atitle
<< R
"(" [fillcolor
=gray
,style
=filled
];)"
49 // unanalyzed articles are printed greyed out
50 for(auto al = a->linkBegin(); al != a->linkEnd(); al++) {
51 auto lck_article = al->lock();
52 if(lck_article != nullptr) {
53 std::string alinkedtitle = lck_article->title();
54 os << R"(")" << atitle
<< R
"(" -> ")"
55 << std::regex_replace(alinkedtitle
, re
, R
"(\")") << R"(";)"
61 void ToGraphvizWriter::output(const Article
* a
, std::ostream
& os
)
70 void ToGraphvizWriter::output(const CollectionUtils::ArticleCollection
& ac
,
76 writeArticle(a
.second
.get(), os
);
81 } // namespace WikiWalker