graphview: add a format version to graphview

This commit is contained in:
Stéphane Cerveau 2022-02-10 09:57:08 +01:00
parent 2f60471f8b
commit 6cc908c109

View file

@ -37,6 +37,7 @@ use std::cell::RefMut;
use std::{cmp::Ordering, collections::HashMap}; use std::{cmp::Ordering, collections::HashMap};
static GRAPHVIEW_STYLE: &str = include_str!("graphview.css"); static GRAPHVIEW_STYLE: &str = include_str!("graphview.css");
pub static GRAPHVIEW_XML_VERSION: &str = "0.1";
mod imp { mod imp {
use super::*; use super::*;
@ -830,8 +831,11 @@ impl GraphView {
.perform_indent(true) .perform_indent(true)
.create_writer(&mut buffer); .create_writer(&mut buffer);
writer writer.write(
.write(XMLWEvent::start_element("Graph").attr("id", &private.id.get().to_string()))?; XMLWEvent::start_element("Graph")
.attr("id", &private.id.get().to_string())
.attr("version", GRAPHVIEW_XML_VERSION),
)?;
//Get the nodes //Get the nodes
let nodes = self.all_nodes(NodeType::All); let nodes = self.all_nodes(NodeType::All);
@ -920,6 +924,11 @@ impl GraphView {
if let Some(id) = attrs.get::<String>(&String::from("id")) { if let Some(id) = attrs.get::<String>(&String::from("id")) {
self.set_id(id.parse::<u32>().expect("id should be an u32")); self.set_id(id.parse::<u32>().expect("id should be an u32"));
} }
if let Some(version) = attrs.get::<String>(&"version".to_string()) {
info!("Found file format version: {}", version);
} else {
warn!("No file format version found");
}
} }
"Node" => { "Node" => {
let id = attrs let id = attrs