Repository navigation
Expand file tree
/
Copy pathText.cs
More file actions
100 lines (82 loc) · 2.6 KB
/
Copy pathText.cs
File metadata and controls
100 lines (82 loc) · 2.6 KB
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
93
94
95
96
97
98
99
100
using System;
namespace QsScript {
[Serializable] public class Text : BasicConst
{
public string Value;
public static Text Null = new Text(null);
public static implicit operator string(Text b) => b.Value;
public Text()
{
Value = string.Empty;
}
public Text(string b)
{
Value = b;
}
public override BasicObject Div( BasicObject r)
{
throw new NotImplementedException();
}
public override BasicObject Equal( BasicObject r)
{
if (r is Text)
return new Bool(string.Compare(((Text)r).Value, Value, true) == 0);
else if (r != null)
return new Bool(string.Compare(r.ToString(), Value, true) == 0);
return new Bool(false);
}
public override BasicObject Gte( BasicObject r)
{
throw new NotImplementedException();
}
public override BasicObject Gth( BasicObject r)
{
if (!r.IsNumbre()) return this;
int i = r.ToNumbre<int>();
var v = Value ?? "";
i = Expression.Swap(i, 0, v.Length);
return new Text(v.Substring(i));
}
public override BasicObject IDiv( BasicObject r)
{
throw new NotImplementedException();
}
public override bool IsNumbre()
{
return false;
}
public override BasicObject Lth( BasicObject r)
{
if (!r.IsNumbre()) return this;
int i = r.ToNumbre<int>();
var v = Value ?? "";
i = Expression.Swap(i, 0, v.Length);
return new Text(v.Substring(0, i));
}
public override BasicObject Lte( BasicObject r)
{
throw new NotImplementedException();
}
public override BasicObject Like( BasicObject r)
{
System.Text.RegularExpressions.Regex e = new System.Text.RegularExpressions.Regex(r.ToString());
return new Bool(e.Match(Value).Success);
}
public override BasicObject Minus( BasicObject r)
{
throw new NotImplementedException();
}
public override BasicObject Mod( BasicObject r)
{
throw new NotImplementedException();
}
public override BasicObject Mul( BasicObject r)
{
throw new NotImplementedException();
}
public override BasicObject Plus( BasicObject r)
{
return new Text(Value + r.ToString());
}
}
}