blob: 35a01fa95879bfafdac9f4410ad525228d53d9fc (
plain)
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
|
namespace Eva {
public class Binary : Object, Term {
public void* data {get; private set;}
public long len {get; private set;}
public string string_value {
owned get{
return binary_to_string(data, len);
}
}
public Binary(char[] v) {
data = Memory.dup(v, (uint)(sizeof(char)*v.length));
len = v.length;
}
public string to_string() {
return "#Bin";
}
protected bool do_match(Term o, Gee.Map<string, Term> vars, Gee.Map<string, string> aliases) {
if(o is Var) {
return o.do_match(this, vars, aliases);
}
if(o is Binary) {
Binary b = o as Binary;
if(b.len != len)
return false;
return (Memory.cmp(data, b.data, len) == 0);
}
else {
return false;
}
}
internal void encode(Buffer buffer) {
buffer.buffer.encode_binary(data, len);
}
}
}
|