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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
using System;
using System.IO;
namespace XUtliPoolLib
{
public abstract class CVSReader
{
public string error
{
get
{
return " line: " + this.lineno.ToString() + " column: " + this.columnno.ToString();
}
}
protected static CVSReader.FloatParse floatParse = new CVSReader.FloatParse();
protected static CVSReader.DoubleParse doubleParse = new CVSReader.DoubleParse();
protected static CVSReader.UIntParse uintParse = new CVSReader.UIntParse();
protected static CVSReader.IntParse intParse = new CVSReader.IntParse();
protected static CVSReader.LongParse longParse = new CVSReader.LongParse();
protected static CVSReader.StringParse stringParse = new CVSReader.StringParse();
protected static CVSReader.BoolParse boolParse = new CVSReader.BoolParse();
protected static CVSReader.ByteParse byteParse = new CVSReader.ByteParse();
protected static CVSReader.ShortParse shortParse = new CVSReader.ShortParse();
public int lineno = -1;
public int columnno = -1;
protected DataHandler m_DataHandler = null;
public abstract class ValueParse<T>
{
public abstract T[] GetBuffer(DataHandler dh);
public abstract void Read(XBinaryReader stream, ref T t, CVSReader reader);
}
public sealed class UIntParse : CVSReader.ValueParse<uint>
{
public override uint[] GetBuffer(DataHandler dh)
{
return dh.uintBuffer;
}
public override void Read(XBinaryReader stream, ref uint t, CVSReader reader)
{
t = stream.ReadUInt32();
}
}
public sealed class IntParse : CVSReader.ValueParse<int>
{
public override int[] GetBuffer(DataHandler dh)
{
return dh.intBuffer;
}
public override void Read(XBinaryReader stream, ref int t, CVSReader reader)
{
t = stream.ReadInt32();
}
}
public sealed class LongParse : CVSReader.ValueParse<long>
{
public override long[] GetBuffer(DataHandler dh)
{
return dh.longBuffer;
}
public override void Read(XBinaryReader stream, ref long t, CVSReader reader)
{
t = stream.ReadInt64();
}
}
public sealed class FloatParse : CVSReader.ValueParse<float>
{
public override float[] GetBuffer(DataHandler dh)
{
return dh.floatBuffer;
}
public override void Read(XBinaryReader stream, ref float t, CVSReader reader)
{
t = stream.ReadSingle();
}
}
public sealed class DoubleParse : CVSReader.ValueParse<double>
{
public override double[] GetBuffer(DataHandler dh)
{
return dh.doubleBuffer;
}
public override void Read(XBinaryReader stream, ref double t, CVSReader reader)
{
t = stream.ReadDouble();
}
}
public sealed class StringParse : CVSReader.ValueParse<string>
{
public override string[] GetBuffer(DataHandler dh)
{
return dh.stringBuffer;
}
public override void Read(XBinaryReader stream, ref string t, CVSReader reader)
{
bool flag = reader.m_DataHandler != null;
if (flag)
{
t = reader.m_DataHandler.ReadString(stream);
}
else
{
t = string.Intern(stream.ReadString(-1));
}
}
}
public sealed class BoolParse : CVSReader.ValueParse<bool>
{
public override bool[] GetBuffer(DataHandler dh)
{
return null;
}
public override void Read(XBinaryReader stream, ref bool t, CVSReader reader)
{
t = stream.ReadBoolean();
}
}
public sealed class ByteParse : CVSReader.ValueParse<byte>
{
public override byte[] GetBuffer(DataHandler dh)
{
return null;
}
public override void Read(XBinaryReader stream, ref byte t, CVSReader reader)
{
t = stream.ReadByte();
}
}
public sealed class ShortParse : CVSReader.ValueParse<short>
{
public short[] buffer = null;
public override short[] GetBuffer(DataHandler dh)
{
return null;
}
public override void Read(XBinaryReader stream, ref short t, CVSReader reader)
{
t = stream.ReadInt16();
}
}
public delegate int RowDataCompare<Trowdata, Ttype>(Trowdata rowData, Ttype key);
public static void Init()
{
SeqRef<string>.parser = CVSReader.stringParse;
SeqRef<int>.parser = CVSReader.intParse;
SeqRef<uint>.parser = CVSReader.uintParse;
SeqRef<long>.parser = CVSReader.longParse;
SeqRef<float>.parser = CVSReader.floatParse;
SeqRef<double>.parser = CVSReader.doubleParse;
SeqListRef<string>.parser = CVSReader.stringParse;
SeqListRef<int>.parser = CVSReader.intParse;
SeqListRef<uint>.parser = CVSReader.uintParse;
SeqListRef<long>.parser = CVSReader.longParse;
SeqListRef<float>.parser = CVSReader.floatParse;
SeqListRef<double>.parser = CVSReader.doubleParse;
}
public CVSReader()
{
this.lineno = 1;
}
public bool ReadFile(XBinaryReader reader)
{
this.lineno = 0;
this.columnno = -1;
int num = reader.ReadInt32();
int num2 = reader.ReadInt32();
this.OnClear(num2);
this.m_DataHandler = new DataHandler();
this.m_DataHandler.Init(reader);
byte b = reader.ReadByte();
for (int i = 0; i < (int)b; i++)
{
byte b2 = reader.ReadByte();
byte b3 = reader.ReadByte();
}
for (int j = 0; j < num2; j++)
{
int num3 = reader.ReadInt32();
int position = reader.GetPosition();
this.ReadLine(reader);
int position2 = reader.GetPosition();
int num4 = position2 - position;
bool flag = num3 > num4;
if (flag)
{
reader.Seek(num3 - num4, SeekOrigin.Current);
}
else
{
bool flag2 = num3 < num4;
if (flag2)
{
XSingleton<XDebug>.singleton.AddErrorLog2("read table error:{0} line:{1} column:{2}", new object[]
{
base.GetType().Name,
this.lineno + 1,
this.columnno
});
break;
}
}
this.lineno++;
bool flag3 = this.columnno > 0;
if (flag3)
{
break;
}
}
int position3 = reader.GetPosition();
bool flag4 = position3 != num;
if (flag4)
{
XSingleton<XDebug>.singleton.AddErrorLog2("read table error:{0} size:{1} read size:{2}", new object[]
{
base.GetType().Name,
num,
position3
});
}
this.m_DataHandler.UnInit(false);
return this.columnno == -1;
}
public void Clear()
{
this.OnClear(0);
}
protected bool Read<T>(XBinaryReader stream, ref T v, CVSReader.ValueParse<T> parse)
{
parse.Read(stream, ref v, this);
return true;
}
protected bool ReadArray<T>(XBinaryReader stream, ref T[] v, CVSReader.ValueParse<T> parse)
{
byte b = stream.ReadByte();
bool flag = b > 0;
if (flag)
{
v = new T[(int)b];
for (byte b2 = 0; b2 < b; b2 += 1)
{
parse.Read(stream, ref v[(int)b2], this);
}
}
else
{
v = null;
}
return true;
}
protected abstract void OnClear(int lineCount);
protected virtual void ReadLine(XBinaryReader reader)
{
}
public static void GetRowDataListByField<Trowdata, Ttype>(Trowdata[] table, Ttype field, out int startIndex, out int endIndex, CVSReader.RowDataCompare<Trowdata, Ttype> comp) where Ttype : IComparable
{
startIndex = -1;
endIndex = -1;
int num = 0;
int num2 = table.Length - 1;
int num3 = -1;
int num4;
for (;;)
{
Trowdata rowData = table[num];
bool flag = comp(rowData, field) == 0;
if (flag)
{
break;
}
Trowdata rowData2 = table[num2];
bool flag2 = comp(rowData2, field) == 0;
if (flag2)
{
goto Block_2;
}
bool flag3 = num2 - num <= 1;
if (flag3)
{
goto Block_3;
}
num4 = num + (num2 - num) / 2;
Trowdata rowData3 = table[num4];
bool flag4 = comp(rowData3, field) < 0;
if (flag4)
{
num2 = num4;
}
else
{
bool flag5 = comp(rowData3, field) > 0;
if (!flag5)
{
goto IL_AE;
}
num = num4;
}
if (num >= num2)
{
goto IL_C2;
}
}
num3 = num;
goto IL_C2;
Block_2:
num3 = num2;
Block_3:
goto IL_C2;
IL_AE:
num3 = num4;
IL_C2:
bool flag6 = num3 >= 0;
if (flag6)
{
startIndex = num3;
endIndex = num3;
bool flag7 = num3 > 0;
if (flag7)
{
for (int i = num3 - 1; i >= 0; i--)
{
Trowdata rowData4 = table[i];
bool flag8 = comp(rowData4, field) != 0;
if (flag8)
{
break;
}
startIndex = i;
}
}
bool flag9 = num3 < table.Length - 1;
if (flag9)
{
for (int j = num3 + 1; j < table.Length; j++)
{
Trowdata rowData5 = table[j];
bool flag10 = comp(rowData5, field) != 0;
if (flag10)
{
break;
}
endIndex = j;
}
}
}
}
}
}
|