From 80e5c01f09667ebdc2ad9f950c0e83b8a0b64a41 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Tue, 17 Feb 2015 23:37:53 +0100 Subject: Implement possiblility of Graphviz export when in debug mode (for demo purposes) --- src/cli/Main.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/cli/Main.cpp') diff --git a/src/cli/Main.cpp b/src/cli/Main.cpp index 7ec7cf9..88ec6b9 100644 --- a/src/cli/Main.cpp +++ b/src/cli/Main.cpp @@ -106,6 +106,10 @@ int main(int argc, char **argv) std::string inputPath; std::string outputPath; std::string format; +#ifdef MANAGER_GRAPHVIZ_EXPORT + std::string graphvizPath; +#endif + /* * This is a rather strange access mechanism: add_options() returns an * easy_init object that has overloaded the () operator to accept new @@ -121,7 +125,13 @@ int main(int argc, char **argv) "output,o", po::value(&outputPath), "The output file name. Per default the input file name will be used.")( "format,F", po::value(&format)->required(), - "The output format that shall be produced."); + "The output format that shall be produced." +#ifdef MANAGER_GRAPHVIZ_EXPORT + )( + "graphviz,G", po::value(&graphvizPath), + "If set, dumps the internal object graph to the given graphviz dot file" +#endif + ); // "input" should be a positional option, such that we can write: // ./ousia [some options] // without having to use -i or I @@ -240,6 +250,17 @@ int main(int argc, char **argv) // now all preparation is done and we can parse the input document. Rooted docNode = context.import(inputPath, "", "", {&RttiTypes::Document}); + +#ifdef MANAGER_GRAPHVIZ_EXPORT + if (!graphvizPath.empty()) { + try { + manager.exportGraphviz(graphvizPath.c_str()); + } catch (LoggableException ex){ + logger.log(ex); + } + } +#endif + if (logger.hasError() || docNode == nullptr) { logger.fatalError("Errors occured while parsing the document"); return ERROR_IN_DOCUMENT; @@ -254,4 +275,4 @@ int main(int argc, char **argv) } return SUCCESS; -} \ No newline at end of file +} -- cgit v1.2.3