LCOV - code coverage report
Current view: top level - include/mutable/util - DotTool.hpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 1 0.0 %
Date: 2025-05-23 10:42:01 Functions: 0 2 0.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : #pragma once
       2                 :            : 
       3                 :            : #include <mutable/mutable-config.hpp>
       4                 :            : #include <mutable/util/Diagnostic.hpp>
       5                 :            : #include <sstream>
       6                 :            : #include <utility>
       7                 :            : 
       8                 :            : 
       9                 :            : namespace m {
      10                 :            : 
      11                 :            : /** This class enables direct rendering of dot output (e.g. that of `ASTDot`).  It uses the graphviz library to render
      12                 :            :  * the dot output directly to PDF. */
      13                 :            : struct M_EXPORT DotTool
      14                 :            : {
      15                 :            :     static constexpr const char *DEFAULT_LAYOUT_ALGORITHM = "dot";
      16                 :            : 
      17                 :            :     m::Diagnostic &diag;
      18                 :            :     private:
      19                 :            :     std::stringstream stream_;
      20                 :            : 
      21                 :            :     public:
      22                 :            :     DotTool(m::Diagnostic &diag);
      23                 :            : 
      24                 :            :     template<typename T>
      25                 :            :     friend DotTool & operator<<(DotTool &dot, T &&t) { dot.stream_ << std::forward<T>(t); return dot; }
      26                 :            : 
      27                 :          0 :     std::ostream & stream() { return stream_; }
      28                 :            : 
      29                 :            :     std::string str() const { return stream_.str(); }
      30                 :            : 
      31                 :            :     friend std::ostream & operator<<(std::ostream &out, const DotTool &dot) { return out << dot.stream_.rdbuf(); }
      32                 :            : 
      33                 :            :     /** Render the graph to the PDF file `path_to_pdf` using the given layouting `algo`rithm.
      34                 :            :      * \returns `0` (zero) if rendering to PDF succeeded, non-zero otherwise
      35                 :            :      */
      36                 :            :     int render_to_pdf(const char *path_to_pdf, const char *algo = DEFAULT_LAYOUT_ALGORITHM);
      37                 :            : 
      38                 :            :     /** Present the graph to the user.  Automatically figures out the best way to do so.
      39                 :            :      * \param name  the name of the graph, used in the filename
      40                 :            :      * \param       interactive whether the program runs interactively
      41                 :            :      * \param algo  the layouting algorithm to use
      42                 :            :      */
      43                 :            :     void show(const char *name, bool interactive, const char *algo = DEFAULT_LAYOUT_ALGORITHM);
      44                 :            : };
      45                 :            : 
      46                 :            : }

Generated by: LCOV version 1.16