aboutsummaryrefslogtreecommitdiff
path: root/cs-dotnet/src/gatsstring.cs
diff options
context:
space:
mode:
Diffstat (limited to 'cs-dotnet/src/gatsstring.cs')
-rw-r--r--cs-dotnet/src/gatsstring.cs49
1 files changed, 49 insertions, 0 deletions
diff --git a/cs-dotnet/src/gatsstring.cs b/cs-dotnet/src/gatsstring.cs
new file mode 100644
index 0000000..30b0afb
--- /dev/null
+++ b/cs-dotnet/src/gatsstring.cs
@@ -0,0 +1,49 @@
1using System.IO;
2
3namespace Com.Xagasoft.Gats
4{
5 public class GatsString : GatsObject
6 {
7 public byte[] Value { get; set; }
8
9 public GatsString()
10 {
11 }
12
13 public GatsString( byte[] val )
14 {
15 Value = val;
16 }
17
18 public override string ToString()
19 {
20 return Value.ToString();
21 }
22
23 public override void Read( Stream s, char cType )
24 {
25 int Size = (int)GatsInteger.ReadPackedInt( s );
26 Value = new byte[Size];
27 int SoFar = 0;
28 do
29 {
30 SoFar += s.Read( Value, SoFar, Size-SoFar );
31 } while( SoFar < Size );
32 }
33
34 public override void Write( Stream s )
35 {
36 s.WriteByte( (byte)'s' );
37 if( Value == null )
38 {
39 GatsInteger.WritePackedInt( s, 0 );
40 }
41 else
42 {
43 GatsInteger.WritePackedInt( s, Value.Length );
44 s.Write( Value, 0, Value.Length );
45 }
46 }
47 };
48}
49