From 80d901c93c8bd28bde7ddc471a763321d905f0ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20D=C3=BCring?= Date: Sun, 27 Nov 2016 14:26:10 +0100 Subject: [PATCH] Add writing to graphviz file --- src/main.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index dc6ad29..473212f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,12 @@ //! \file main.cpp #include +#include #include "WikiWalker.h" #include "version.h" #include "BoostPoCommandLineParser.h" +#include "ToGraphvizWriter.h" using namespace std; @@ -35,6 +37,8 @@ int main(int argc, char** argv) cmdp.printHelp(); return 1; } + bool isDotSet = cmdp.hasSet("dot-out"); + bool read_failed = false; std::string url = cmdp.getValue("url"); @@ -70,5 +74,24 @@ int main(int argc, char** argv) } } + if(isDotSet) { + const ArticleCollection& ac = w.getCollection(); + std::string outfile = cmdp.getValue("dot-out"); + ToGraphvizWriter tgw; + ofstream file(outfile, ios::trunc | ios::out); + + if(file.fail()) { + cerr << "Error opening dot out file for writing" << endl; + } else { + tgw.output(ac, file); + file.flush(); + + if(file.bad() || file.fail()) { + cerr << "Error during writing dot out file." << endl; + } + + file.close(); + } + } return 0; } -- 2.11.4.GIT