blob: 30b0afb40d70f8a257824f9cd0a2d3a82aa0f95d (
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
|
using System.IO;
namespace Com.Xagasoft.Gats
{
public class GatsString : GatsObject
{
public byte[] Value { get; set; }
public GatsString()
{
}
public GatsString( byte[] val )
{
Value = val;
}
public override string ToString()
{
return Value.ToString();
}
public override void Read( Stream s, char cType )
{
int Size = (int)GatsInteger.ReadPackedInt( s );
Value = new byte[Size];
int SoFar = 0;
do
{
SoFar += s.Read( Value, SoFar, Size-SoFar );
} while( SoFar < Size );
}
public override void Write( Stream s )
{
s.WriteByte( (byte)'s' );
if( Value == null )
{
GatsInteger.WritePackedInt( s, 0 );
}
else
{
GatsInteger.WritePackedInt( s, Value.Length );
s.Write( Value, 0, Value.Length );
}
}
};
}
|