summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/SubString.cs
blob: 62701128217911ab5b1080e4a6f13395a7b42172 (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
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
using System;

public struct SubString
{
	public readonly int Start;

	public readonly int Length;

	public readonly string Source;

	public SubString(string source, int start, int length)
	{
		this.Source = source;
		this.Start = start;
		this.Length = length;
	}

	public override string ToString()
	{
		return this.Source.Substring(this.Start, this.Length);
	}

	public int GetKvpValue()
	{
		int num = this.Start + this.Length;
		for (int i = this.Start; i < num; i++)
		{
			if (this.Source[i] == '=')
			{
				i++;
				return new SubString(this.Source, i, num - i).ToInt();
			}
		}
		throw new InvalidCastException();
	}

	public int ToInt()
	{
		int num = 0;
		int num2 = this.Start + this.Length;
		bool flag = false;
		for (int i = this.Start; i < num2; i++)
		{
			char c = this.Source[i];
			if (c == '-')
			{
				flag = true;
			}
			else if (c >= '0' && c <= '9')
			{
				int num3 = (int)(c - '0');
				num = 10 * num + num3;
			}
		}
		if (!flag)
		{
			return num;
		}
		return -num;
	}

	public bool StartsWith(string v)
	{
		if (v.Length > this.Length)
		{
			return false;
		}
		for (int i = 0; i < v.Length; i++)
		{
			if (this.Source[i + this.Start] != v[i])
			{
				return false;
			}
		}
		return true;
	}
}