Commit 0fd94577 authored by Benoît Barbot's avatar Benoît Barbot
Browse files

add def

parent 741d0243
Pipeline #1764 failed with stage
in 29 seconds
......@@ -200,6 +200,10 @@ module GraphEditor (G: GRAPH ) = struct
let attr = snd @@ G.get_arc_attribute graph arc in
buff_list buff write_attribute attr
);
let def_attr = snd @@ G.get_arc_attribute graph `Empty in
Buffer.add_char buff 'D';
buff_list buff write_attribute def_attr;
Bytes.to_string @@ Buffer.to_bytes buff
......@@ -209,23 +213,9 @@ module GraphEditor (G: GRAPH ) = struct
| t::q -> let v,q2 = find_and_remove x q in
v,t::q2
let parse_exchange_string str =
let parse_exchange_node graph str pos node =
let open GenericSerializer in
let graph = G.new_graph () in
let length = String.length str in
assert (String.sub str 0 3 = "GEX");
let pos = ref 3 in
let map = Hashtbl.create 10 in
let i =ref 0 in
while !pos+4 <= length && str.[!pos] = 'N' do
let node_type = ui_of_b64 str.[!pos+1] in
let p1,f1 = float_buff str (!pos+2) in
let p2,f2 = float_buff str p1 in
let node = G.new_node graph node_type (f1,f2) in
Hashtbl.add map !i node;
incr i;
pos := p2;
let npos,attrl = list_buff str read_attribute !pos in
let npos,attrl = list_buff str read_attribute pos in
let _,cattr = G.get_node_attribute graph node in
let nattrl = G.get_new_node_attribute graph node in
let attrl2 = List.fold_left (fun l (id,name,_) ->
......@@ -244,7 +234,24 @@ module GraphEditor (G: GRAPH ) = struct
if not (G.update_node_attribute graph node nat (Some attr)) then
print_endline ("Fail to update attribute:"^str)
) attrl2;
pos := npos
npos
let parse_exchange_string str =
let open GenericSerializer in
let graph = G.new_graph () in
let length = String.length str in
assert (String.sub str 0 3 = "GEX");
let pos = ref 3 in
let map = Hashtbl.create 10 in
let i =ref 0 in
while !pos+4 <= length && str.[!pos] = 'N' do
let node_type = ui_of_b64 str.[!pos+1] in
let p1,f1 = float_buff str (!pos+2) in
let p2,f2 = float_buff str p1 in
let node = G.new_node graph node_type (f1,f2) in
Hashtbl.add map !i node;
incr i;
pos := parse_exchange_node graph str p2 node
done;
while !pos+7 <= length && str.[!pos] = 'A' do
let p1,nid1 = int_buff str (!pos+1) in
......@@ -278,6 +285,7 @@ module GraphEditor (G: GRAPH ) = struct
end
done;
pos := parse_exchange_node graph str (!pos+1) `Empty;
graph
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment