diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-14 23:55:29 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-14 23:55:29 +0000 |
commit | 63628550708a616c5c58bc5c707db1e7fd9cd7c2 (patch) | |
tree | b6b7d466db687ba360cd760245d1146e973863c0 /cs-dotnet/src/gatsobject.cs | |
parent | 9d86cba840252b451c4b86d9ea16c821b6c97245 (diff) | |
download | libgats-63628550708a616c5c58bc5c707db1e7fd9cd7c2.tar.gz libgats-63628550708a616c5c58bc5c707db1e7fd9cd7c2.tar.bz2 libgats-63628550708a616c5c58bc5c707db1e7fd9cd7c2.tar.xz libgats-63628550708a616c5c58bc5c707db1e7fd9cd7c2.zip |
Strings, bools, and ints all seem fine, the more complex container types are
coming next, and will implement the full range of appropriate interfaces.
Diffstat (limited to 'cs-dotnet/src/gatsobject.cs')
-rw-r--r-- | cs-dotnet/src/gatsobject.cs | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/cs-dotnet/src/gatsobject.cs b/cs-dotnet/src/gatsobject.cs index f782f95..a0b9276 100644 --- a/cs-dotnet/src/gatsobject.cs +++ b/cs-dotnet/src/gatsobject.cs | |||
@@ -4,7 +4,58 @@ namespace Com.Xagasoft.Gats | |||
4 | { | 4 | { |
5 | public abstract class GatsObject | 5 | public abstract class GatsObject |
6 | { | 6 | { |
7 | public abstract void Read( Stream s, byte cType ); | 7 | public abstract void Read( Stream s, char cType ); |
8 | public abstract void Write( Stream s ); | 8 | public abstract void Write( Stream s ); |
9 | |||
10 | public static GatsObject Read( Stream s ) | ||
11 | { | ||
12 | int b = s.ReadByte(); | ||
13 | if( b == -1 ) | ||
14 | throw new GatsException( GatsException.Type.PrematureEnd ); | ||
15 | char type = (char)b; | ||
16 | GatsObject goRet = null; | ||
17 | switch( type ) | ||
18 | { | ||
19 | case 'i': | ||
20 | goRet = new GatsInteger(); | ||
21 | break; | ||
22 | |||
23 | case 's': | ||
24 | goRet = new GatsString(); | ||
25 | break; | ||
26 | |||
27 | case '0': | ||
28 | case '1': | ||
29 | goRet = new GatsBoolean(); | ||
30 | break; | ||
31 | |||
32 | case 'l': | ||
33 | // goRet = new GatsList(); | ||
34 | break; | ||
35 | |||
36 | case 'd': | ||
37 | // goRet = new GatsDictionary(); | ||
38 | break; | ||
39 | |||
40 | case 'f': | ||
41 | case 'F': | ||
42 | // goRet = new GatsFloat(); | ||
43 | break; | ||
44 | |||
45 | case 'n': | ||
46 | // goRet = new GatsNull(); | ||
47 | break; | ||
48 | |||
49 | case 'e': | ||
50 | return null; | ||
51 | |||
52 | default: | ||
53 | throw new GatsException( GatsException.Type.InvalidType ); | ||
54 | } | ||
55 | |||
56 | goRet.Read( s, type ); | ||
57 | |||
58 | return goRet; | ||
59 | } | ||
9 | } | 60 | } |
10 | } | 61 | } |