JSDOC/BuildDocs.js
[gnome.introspection-doc-generator] / JSDOC / TextStream.js
1 //<script type="text/javscript">
2
3 XObject = imports.XObject.XObject;
4
5
6 /**
7         @constructor
8 */
9 TextStream = XObject.define(
10     function(text) {
11         if (typeof(text) == "undefined") text = "";
12         text = ""+text;
13         this.text = text;
14         this.cursor = 0;
15     },
16     Object, 
17     { 
18         
19         look : function(n) {
20             if (typeof n == "undefined") n = 0;
21             
22             if (this.cursor+n < 0 || this.cursor+n >= this.text.length) {
23                 var result = new String("");
24                 result.eof = true;
25                 return result;
26             }
27             return this.text.charAt(this.cursor+n);
28         },
29
30         next : function(n) {
31             if (typeof n == "undefined") n = 1;
32             if (n < 1) return null;
33             
34             var pulled = "";
35             for (var i = 0; i < n; i++) {
36                 if (this.cursor+i < this.text.length) {
37                     pulled += this.text.charAt(this.cursor+i);
38                 }
39                 else {
40                     var result = new String("");
41                     result.eof = true;
42                     return result;
43                 }
44             }
45
46             this.cursor += n;
47             return pulled;
48         }
49 });