Fix #5682 - fix path in title of source file
[roojspacker] / src / jsdoc / TextStream.vala
1 //<script type="text/javscript">
2
3  
4
5 /**
6         @constructor
7 */
8 namespace JSDOC {
9     
10     public class TextStreamChar : Object {
11         public char c;
12         public bool eof;
13         public TextStreamChar(char val, bool eof=false) {
14             this.c = val;
15             this.eof = eof;
16         }
17     }
18     
19     public class TextStream : Object {
20         
21         string text;
22         int cursor;
23         int length;
24         
25         public TextStream (string text = "")
26         {
27             
28             
29             this.text = text;
30             //stdout.printf ("%s", text);
31             this.length = text.length; // text.char_count(); //text.length;
32             this.cursor = 0;
33         }
34         
35         public string lookS(int n = 0)
36         {
37                  
38             if (this.cursor+n < 0 || this.cursor+n >= this.length) {
39                 return "";
40             }
41             return  this.text.get_char(this.cursor+n).to_string(); // this.text[this.cursor+n]; // 
42         }
43          public char lookC(int n = 0)
44         {
45                  
46             if (this.cursor+n < 0 || this.cursor+n >= this.length) {
47                 return '\0';
48             }
49             return  this.text[this.cursor+n];
50         }
51         
52         
53         public bool lookEOF(int n = 0)
54         {
55             if (this.cursor+n < 0 || this.cursor+n >= this.length) {
56                 return true;
57             }
58             return  false;
59         }
60         
61         /**
62          * @param n - number of characters to return..
63          */
64         public string nextS(int n = 1)
65         {
66             
67             if (n < 1) { //?? eof???
68                 return "";
69             }
70                 
71             string pulled = "";
72             var i = 0;
73             while (i < n) {
74                 if (this.cursor+i < this.length) {
75                     var add =  this.text.get_char(this.cursor+i).to_string(); 
76                     pulled += add;
77                     i += 1;// add.length;
78                 } else {
79                     return "";
80                     
81                 }
82             }
83             
84             this.cursor +=  pulled.length; // i?
85             return pulled;
86            
87         }
88         
89         public char nextC()
90         {
91             
92             if (this.cursor+1 < this.length) {
93                 return this.text[this.cursor++];;
94             } 
95             return '\0';
96            
97         }
98         
99         
100     }
101 }