From 6cc908c1098e3a96216622327919e26bc6ba652b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Thu, 10 Feb 2022 09:57:08 +0100 Subject: [PATCH] graphview: add a format version to graphview --- src/graphmanager/graphview.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/graphmanager/graphview.rs b/src/graphmanager/graphview.rs index 4c5e31b..077402a 100644 --- a/src/graphmanager/graphview.rs +++ b/src/graphmanager/graphview.rs @@ -37,6 +37,7 @@ use std::cell::RefMut; use std::{cmp::Ordering, collections::HashMap}; static GRAPHVIEW_STYLE: &str = include_str!("graphview.css"); +pub static GRAPHVIEW_XML_VERSION: &str = "0.1"; mod imp { use super::*; @@ -830,8 +831,11 @@ impl GraphView { .perform_indent(true) .create_writer(&mut buffer); - writer - .write(XMLWEvent::start_element("Graph").attr("id", &private.id.get().to_string()))?; + writer.write( + XMLWEvent::start_element("Graph") + .attr("id", &private.id.get().to_string()) + .attr("version", GRAPHVIEW_XML_VERSION), + )?; //Get the nodes let nodes = self.all_nodes(NodeType::All); @@ -920,6 +924,11 @@ impl GraphView { if let Some(id) = attrs.get::(&String::from("id")) { self.set_id(id.parse::().expect("id should be an u32")); } + if let Some(version) = attrs.get::(&"version".to_string()) { + info!("Found file format version: {}", version); + } else { + warn!("No file format version found"); + } } "Node" => { let id = attrs