Add source files
This commit is contained in:
320
Projects/BanquetForFools/Source/Assembly-CSharp/StringFast.cs
Normal file
320
Projects/BanquetForFools/Source/Assembly-CSharp/StringFast.cs
Normal file
@@ -0,0 +1,320 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// Token: 0x02000091 RID: 145
|
||||
public class StringFast
|
||||
{
|
||||
// Token: 0x06000E18 RID: 3608 RVA: 0x0010F638 File Offset: 0x0010D838
|
||||
public StringFast(int initialCapacity = 32)
|
||||
{
|
||||
this.m_charsCapacity = initialCapacity;
|
||||
this.m_buffer = new char[initialCapacity];
|
||||
}
|
||||
|
||||
// Token: 0x06000E19 RID: 3609 RVA: 0x0010F676 File Offset: 0x0010D876
|
||||
public bool IsEmpty()
|
||||
{
|
||||
if (!this.m_isStringGenerated)
|
||||
{
|
||||
return this.m_bufferPos == 0;
|
||||
}
|
||||
return this.m_stringGenerated == null;
|
||||
}
|
||||
|
||||
// Token: 0x06000E1A RID: 3610 RVA: 0x0010F693 File Offset: 0x0010D893
|
||||
public override string ToString()
|
||||
{
|
||||
if (!this.m_isStringGenerated)
|
||||
{
|
||||
this.m_stringGenerated = new string(this.m_buffer, 0, this.m_bufferPos);
|
||||
this.m_isStringGenerated = true;
|
||||
}
|
||||
return this.m_stringGenerated;
|
||||
}
|
||||
|
||||
// Token: 0x06000E1B RID: 3611 RVA: 0x0010F6C2 File Offset: 0x0010D8C2
|
||||
public bool IsModified(int newControlValue)
|
||||
{
|
||||
bool flag = newControlValue != this.m_valueControlInt;
|
||||
if (flag)
|
||||
{
|
||||
this.m_valueControlInt = newControlValue;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000E1C RID: 3612 RVA: 0x0010F6DA File Offset: 0x0010D8DA
|
||||
public bool IsModified(object newControlValue)
|
||||
{
|
||||
bool flag = !newControlValue.Equals(this.m_valueControl);
|
||||
if (flag)
|
||||
{
|
||||
this.m_valueControl = newControlValue;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000E1D RID: 3613 RVA: 0x0010F6F5 File Offset: 0x0010D8F5
|
||||
public void Set(string str)
|
||||
{
|
||||
this.Clear();
|
||||
this.Append(str);
|
||||
this.m_stringGenerated = str;
|
||||
this.m_isStringGenerated = true;
|
||||
}
|
||||
|
||||
// Token: 0x06000E1E RID: 3614 RVA: 0x0010F714 File Offset: 0x0010D914
|
||||
public void Set(object str)
|
||||
{
|
||||
this.Set(str.ToString());
|
||||
}
|
||||
|
||||
// Token: 0x06000E1F RID: 3615 RVA: 0x0010F722 File Offset: 0x0010D922
|
||||
public void Set<T1, T2>(T1 str1, T2 str2)
|
||||
{
|
||||
this.Clear();
|
||||
this.Append(str1);
|
||||
this.Append(str2);
|
||||
}
|
||||
|
||||
// Token: 0x06000E20 RID: 3616 RVA: 0x0010F745 File Offset: 0x0010D945
|
||||
public void Set<T1, T2, T3>(T1 str1, T2 str2, T3 str3)
|
||||
{
|
||||
this.Clear();
|
||||
this.Append(str1);
|
||||
this.Append(str2);
|
||||
this.Append(str3);
|
||||
}
|
||||
|
||||
// Token: 0x06000E21 RID: 3617 RVA: 0x0010F775 File Offset: 0x0010D975
|
||||
public void Set<T1, T2, T3, T4>(T1 str1, T2 str2, T3 str3, T4 str4)
|
||||
{
|
||||
this.Clear();
|
||||
this.Append(str1);
|
||||
this.Append(str2);
|
||||
this.Append(str3);
|
||||
this.Append(str4);
|
||||
}
|
||||
|
||||
// Token: 0x06000E22 RID: 3618 RVA: 0x0010F7B4 File Offset: 0x0010D9B4
|
||||
public void Set(params object[] str)
|
||||
{
|
||||
this.Clear();
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
this.Append(str[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000E23 RID: 3619 RVA: 0x0010F7E0 File Offset: 0x0010D9E0
|
||||
public StringFast Clear()
|
||||
{
|
||||
this.m_bufferPos = 0;
|
||||
this.m_isStringGenerated = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Token: 0x06000E24 RID: 3620 RVA: 0x0010F7F4 File Offset: 0x0010D9F4
|
||||
public StringFast Append(string value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
this.ReallocateIFN(value.Length);
|
||||
int length = value.Length;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
this.m_buffer[this.m_bufferPos + i] = value[i];
|
||||
}
|
||||
this.m_bufferPos += length;
|
||||
this.m_isStringGenerated = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Token: 0x06000E25 RID: 3621 RVA: 0x0010F856 File Offset: 0x0010DA56
|
||||
public StringFast Append(object value)
|
||||
{
|
||||
this.Append(value.ToString());
|
||||
return this;
|
||||
}
|
||||
|
||||
// Token: 0x06000E26 RID: 3622 RVA: 0x0010F868 File Offset: 0x0010DA68
|
||||
public StringFast Append(int value)
|
||||
{
|
||||
this.ReallocateIFN(16);
|
||||
if (value < 0)
|
||||
{
|
||||
value = -value;
|
||||
char[] buffer = this.m_buffer;
|
||||
int num = this.m_bufferPos;
|
||||
this.m_bufferPos = num + 1;
|
||||
buffer[num] = 45;
|
||||
}
|
||||
int num2 = 0;
|
||||
do
|
||||
{
|
||||
char[] buffer2 = this.m_buffer;
|
||||
int num = this.m_bufferPos;
|
||||
this.m_bufferPos = num + 1;
|
||||
buffer2[num] = (ushort)(48 + value % 10);
|
||||
value /= 10;
|
||||
num2++;
|
||||
}
|
||||
while (value != 0);
|
||||
for (int i = num2 / 2 - 1; i >= 0; i--)
|
||||
{
|
||||
char c = this.m_buffer[this.m_bufferPos - i - 1];
|
||||
this.m_buffer[this.m_bufferPos - i - 1] = this.m_buffer[this.m_bufferPos - num2 + i];
|
||||
this.m_buffer[this.m_bufferPos - num2 + i] = c;
|
||||
}
|
||||
this.m_isStringGenerated = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Token: 0x06000E27 RID: 3623 RVA: 0x0010F92C File Offset: 0x0010DB2C
|
||||
public StringFast Append(float valueF)
|
||||
{
|
||||
double num = (double)valueF;
|
||||
this.m_isStringGenerated = false;
|
||||
this.ReallocateIFN(32);
|
||||
if (num == 0.0)
|
||||
{
|
||||
char[] buffer = this.m_buffer;
|
||||
int num2 = this.m_bufferPos;
|
||||
this.m_bufferPos = num2 + 1;
|
||||
buffer[num2] = 48;
|
||||
return this;
|
||||
}
|
||||
if (num < 0.0)
|
||||
{
|
||||
num = -num;
|
||||
char[] buffer2 = this.m_buffer;
|
||||
int num2 = this.m_bufferPos;
|
||||
this.m_bufferPos = num2 + 1;
|
||||
buffer2[num2] = 45;
|
||||
}
|
||||
int num3 = 0;
|
||||
while (num < 1000000.0)
|
||||
{
|
||||
num *= 10.0;
|
||||
num3++;
|
||||
}
|
||||
long num4 = (long)Math.Round(num);
|
||||
int num5 = 0;
|
||||
bool flag = true;
|
||||
while (num4 != 0L || num3 >= 0)
|
||||
{
|
||||
if (num4 % 10L != 0L || num3 <= 0)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
this.m_buffer[this.m_bufferPos + num5++] = (char)(48L + num4 % 10L);
|
||||
}
|
||||
if (--num3 == 0 && !flag)
|
||||
{
|
||||
this.m_buffer[this.m_bufferPos + num5++] = '.';
|
||||
}
|
||||
num4 /= 10L;
|
||||
}
|
||||
this.m_bufferPos += num5;
|
||||
for (int i = num5 / 2 - 1; i >= 0; i--)
|
||||
{
|
||||
char c = this.m_buffer[this.m_bufferPos - i - 1];
|
||||
this.m_buffer[this.m_bufferPos - i - 1] = this.m_buffer[this.m_bufferPos - num5 + i];
|
||||
this.m_buffer[this.m_bufferPos - num5 + i] = c;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// Token: 0x06000E28 RID: 3624 RVA: 0x0010FA9C File Offset: 0x0010DC9C
|
||||
public StringFast Replace(string oldStr, string newStr)
|
||||
{
|
||||
if (this.m_bufferPos == 0)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
if (this.m_replacement == null)
|
||||
{
|
||||
this.m_replacement = new List<char>();
|
||||
}
|
||||
for (int i = 0; i < this.m_bufferPos; i++)
|
||||
{
|
||||
bool flag = false;
|
||||
if (this.m_buffer[i] == oldStr[0])
|
||||
{
|
||||
int num = 1;
|
||||
while (num < oldStr.Length && this.m_buffer[i + num] == oldStr[num])
|
||||
{
|
||||
num++;
|
||||
}
|
||||
flag = num >= oldStr.Length;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
i += oldStr.Length - 1;
|
||||
if (newStr != null)
|
||||
{
|
||||
for (int j = 0; j < newStr.Length; j++)
|
||||
{
|
||||
this.m_replacement.Add(newStr[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_replacement.Add(this.m_buffer[i]);
|
||||
}
|
||||
}
|
||||
this.ReallocateIFN(this.m_replacement.Count - this.m_bufferPos);
|
||||
for (int k = 0; k < this.m_replacement.Count; k++)
|
||||
{
|
||||
this.m_buffer[k] = this.m_replacement[k];
|
||||
}
|
||||
this.m_bufferPos = this.m_replacement.Count;
|
||||
this.m_replacement.Clear();
|
||||
this.m_isStringGenerated = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Token: 0x06000E29 RID: 3625 RVA: 0x0010FBD8 File Offset: 0x0010DDD8
|
||||
private void ReallocateIFN(int nbCharsToAdd)
|
||||
{
|
||||
if (this.m_bufferPos + nbCharsToAdd > this.m_charsCapacity)
|
||||
{
|
||||
this.m_charsCapacity = Math.Max(this.m_charsCapacity + nbCharsToAdd, this.m_charsCapacity * 2);
|
||||
this.newChars = new char[this.m_charsCapacity];
|
||||
this.m_buffer.CopyTo(this.newChars, 0);
|
||||
this.m_buffer = this.newChars;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04001686 RID: 5766
|
||||
private string m_stringGenerated = "";
|
||||
|
||||
// Token: 0x04001687 RID: 5767
|
||||
private bool m_isStringGenerated;
|
||||
|
||||
// Token: 0x04001688 RID: 5768
|
||||
private char[] newChars;
|
||||
|
||||
// Token: 0x04001689 RID: 5769
|
||||
private char[] m_buffer;
|
||||
|
||||
// Token: 0x0400168A RID: 5770
|
||||
private int m_bufferPos;
|
||||
|
||||
// Token: 0x0400168B RID: 5771
|
||||
private int m_charsCapacity;
|
||||
|
||||
// Token: 0x0400168C RID: 5772
|
||||
private List<char> m_replacement;
|
||||
|
||||
// Token: 0x0400168D RID: 5773
|
||||
private object m_valueControl;
|
||||
|
||||
// Token: 0x0400168E RID: 5774
|
||||
private int m_valueControlInt = int.MinValue;
|
||||
}
|
Reference in New Issue
Block a user