From 63628550708a616c5c58bc5c707db1e7fd9cd7c2 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 14 Nov 2012 23:55:29 +0000 Subject: Strings, bools, and ints all seem fine, the more complex container types are coming next, and will implement the full range of appropriate interfaces. --- cs-dotnet/src/gatsstring.cs | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 cs-dotnet/src/gatsstring.cs (limited to 'cs-dotnet/src/gatsstring.cs') 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 @@ +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 ); + } + } + }; +} + -- cgit v1.2.3