Mercurial > projects > dwt-mac
comparison dwt/dwthelper/ByteArrayInputStream.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /* language convertion www.dsource.org/project/tioport */ | |
2 module dwt.dwthelper.ByteArrayInputStream; | |
3 | |
4 import dwt.dwthelper.InputStream; | |
5 | |
6 public class ByteArrayInputStream : dwt.dwthelper.InputStream.InputStream { | |
7 | |
8 alias dwt.dwthelper.InputStream.InputStream.read read; | |
9 alias dwt.dwthelper.InputStream.InputStream.skip skip; | |
10 alias dwt.dwthelper.InputStream.InputStream.available available; | |
11 alias dwt.dwthelper.InputStream.InputStream.close close; | |
12 alias dwt.dwthelper.InputStream.InputStream.mark mark; | |
13 alias dwt.dwthelper.InputStream.InputStream.reset reset; | |
14 alias dwt.dwthelper.InputStream.InputStream.markSupported markSupported; | |
15 | |
16 protected byte[] buf; | |
17 protected int pos; | |
18 protected int fld_mark = 0; | |
19 //protected int count; | |
20 public this ( byte[] aBuf ){ | |
21 this.buf = aBuf; | |
22 } | |
23 | |
24 public this ( byte[] aBuf, int offset, int length_ESCAPE ){ | |
25 this.buf = aBuf[ offset .. offset+length_ESCAPE ]; | |
26 } | |
27 | |
28 public synchronized int read(){ | |
29 if( pos >= this.buf.length ){ | |
30 return -1; | |
31 } | |
32 int result = this.buf[pos]; | |
33 pos++; | |
34 return result & 0xFF; | |
35 } | |
36 | |
37 public synchronized int read( byte[] b, int off, int len ){ | |
38 return super.read( b, off, len ); | |
39 } | |
40 | |
41 public synchronized long skip( long n ){ | |
42 pos += n; | |
43 return 0L; | |
44 } | |
45 | |
46 public synchronized int available(){ | |
47 if( pos >= this.buf.length ){ | |
48 return 0; | |
49 } | |
50 return this.buf.length - pos; | |
51 } | |
52 | |
53 public bool markSupported(){ | |
54 return false; | |
55 } | |
56 | |
57 public void mark( int readAheadLimit ){ | |
58 } | |
59 | |
60 public synchronized void reset(){ | |
61 pos = 0; | |
62 } | |
63 | |
64 public void close(){ | |
65 } | |
66 | |
67 | |
68 } | |
69 | |
70 |