Last change
on this file since 28388 was 28388, checked in by davidb, 11 years ago |
Set of JS, CSS, PNG etc web resources to support a mixture of audio player/document display capabilities
|
File size:
1.1 KB
|
Line | |
---|
1 | Mad.BinaryStrings.StringStream = function(string) {
|
---|
2 | this.offset = 0;
|
---|
3 | this.buffer = string;
|
---|
4 | this.amountRead = string.length;
|
---|
5 | this.length = string.length;
|
---|
6 | }
|
---|
7 |
|
---|
8 | Mad.BinaryStrings.StringStream.prototype = new Mad.BinaryStrings.ByteStream();
|
---|
9 |
|
---|
10 | Mad.BinaryStrings.StringStream.prototype.absoluteAvailable = function(n, updated) {
|
---|
11 | return n < this['amountRead'];
|
---|
12 | }
|
---|
13 |
|
---|
14 | Mad.BinaryStrings.StringStream.prototype.seek = function(n) {
|
---|
15 | this['offset'] += n;
|
---|
16 | }
|
---|
17 |
|
---|
18 | Mad.BinaryStrings.StringStream.prototype.read = function(n) {
|
---|
19 | var result = this.peek(n);
|
---|
20 |
|
---|
21 | this.seek(n);
|
---|
22 |
|
---|
23 | return result;
|
---|
24 | }
|
---|
25 |
|
---|
26 | Mad.BinaryStrings.StringStream.prototype.peek = function(n) {
|
---|
27 | if (this.available(n)) {
|
---|
28 | var offset = this['offset'];
|
---|
29 |
|
---|
30 | var result = this.get(offset, n);
|
---|
31 |
|
---|
32 | return result;
|
---|
33 | } else {
|
---|
34 | throw 'TODO: THROW PEEK ERROR!';
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | Mad.BinaryStrings.StringStream.prototype.get = function(offset, length) {
|
---|
39 | if (this.absoluteAvailable(offset + length)) {
|
---|
40 | return this['buffer'].slice(offset, offset + length);
|
---|
41 | } else {
|
---|
42 | throw 'TODO: THROW GET ERROR!';
|
---|
43 | }
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.