element.text = text;
}
+void SVGAnalyzer::set_graphviz_version(std::string_view version) {
+ m_svg.graphviz_version = version;
+}
+
+void SVGAnalyzer::set_graphviz_build_date(std::string_view build_date) {
+ m_svg.graphviz_build_date = build_date;
+}
+
std::string SVGAnalyzer::svg_string(std::size_t indent_size) const {
std::string output{};
output += m_svg.to_string(indent_size);
std::size_t num_rects() const { return m_num_rects; };
std::size_t num_texts() const { return m_num_texts; };
std::size_t num_titles() const { return m_num_titles; };
+ void set_graphviz_version(std::string_view version);
+ void set_graphviz_build_date(std::string_view build_date);
std::string svg_string(std::size_t indent_size = 2) const;
private:
"\n";
output += R"( "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">)"
"\n";
+ output += fmt::format("<!-- Generated by graphviz version {} "
+ "({})\n -->\n",
+ graphviz_version, graphviz_build_date);
to_string_impl(output, indent_size, 0);
return output;
}
std::string to_string(std::size_t indent_size) const;
+ /// The Graphviz build date
+ std::string graphviz_build_date;
std::vector<SVGElement> children;
+ /// The Graphviz release version
+ std::string graphviz_version;
/// The SVG element text node contents. Not to be confused with an SVG `text`
/// element
std::string text;
auto g = CGraph::AGraph{dot};
const auto demand_loading = false;
- auto gvc = GVC::GVContext(lt_preloaded_symbols, demand_loading);
+ auto gvc = GVC::GVContext{lt_preloaded_symbols, demand_loading};
+ const auto graphviz_version = gvc.version();
+ const auto graphviz_build_date = gvc.buildDate();
const auto layout = GVC::GVLayout(std::move(gvc), std::move(g), "dot");
const auto result = layout.render("svg");
const std::string original_svg{result.string_view()};
SVGAnalyzer svgAnalyzer{result.c_str()};
+ svgAnalyzer.set_graphviz_version(graphviz_version);
+ svgAnalyzer.set_graphviz_build_date(graphviz_build_date);
const std::size_t expected_num_graphs = 1;
const std::size_t expected_num_nodes = 2;
for (std::size_t i = 0; i < original_svg_lines.size(); i++) {
REQUIRE(i < recreated_svg_lines.size());
if (recreated_svg_lines[i] == "<svg>") {
- // stop comparison here since we do not yet handle the Graphviz version
- // and build date comment and the graph title comment that comes before
- // the 'svg' element
+ // stop comparison here since we do not yet handle the graph title
+ // comment that comes before the 'svg' element
break;
}
REQUIRE(recreated_svg_lines[i] == original_svg_lines[i]);