1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
mod rdbhandeling;
pub fn rdbData(name:&str) -> dataBook{
return returner(name);
}
pub fn findValue(name: &str, xs: &dataBook,typ: &str) -> usize{
return findValueB(name, xs, typ)
}
pub fn addData(name:&str,newdata:&str){
rdbhandeling::addData(name, newdata)
}
pub fn changeData(name:&str,newdata:&str,cname:&str){
rdbhandeling::changeData(name, newdata,cname)
}
pub fn removeData(name:&str,newdata:&str){
rdbhandeling::removeData(name, newdata)
}
pub struct dataBook{
pub NM:Vec<String>,
pub ND:Vec<String>,
pub D:Vec<i64>,
pub M:Vec<String>,
pub A:Vec<Vec<String>>,
pub AN:Vec<String>
}
fn returner(name: &str) -> dataBook{
let XX:dataBook = dataBook{
NM : rdbhandeling::getVal_MN(name),
ND : rdbhandeling::getVal_ND(name),
D : rdbhandeling::getVal_D(name),
M : rdbhandeling::getVal_M(name),
A : rdbhandeling::getVal_A(name),
AN: rdbhandeling::getVal_AN(name)
};
return XX;
}
fn findValueB(name: &str, xs: &dataBook,typ: &str) -> usize{
if typ == "_D"{
for x in 0..xs.ND.len(){
if xs.ND[x] == name.to_string(){
return x;
}
}
}else if typ == "_M"{
for x in 0..xs.NM.len(){
if xs.NM[x] == name.to_string(){
return x;
}
}
}else if typ == "_A"{
for x in 0..xs.AN.len(){
if xs.AN[x] == name.to_string(){
return x;
}
}
}
return 0;
}
pub fn copyValueToNew(name:&str,newName:&str, copyName:&str,xx: dataBook,typ:&str){
let mut x: String = "".to_string();
if typ == "_M"{
x = "|".to_owned()+&newName+&"_M|".to_owned()+&xx.M[findValue(copyName, &xx, "_M")];
}
if typ == "_D"{
x = "|".to_owned()+&newName+&"_D|".to_owned()+&xx.D[findValue(copyName, &xx, "_D")].to_string();
}
if typ == "_A"{
let mut xf: String = "".to_string();
for x in &xx.A[findValue(copyName, &xx, "_A")]{
let xo = x.to_owned()+",";
xf.push_str(&xo);
}
x = "|".to_owned()+&newName+&"_A|".to_owned()+&xf;
}
rdbhandeling::addData(name, &x)
}