X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=JSDOC%2FTextStream.vala;h=e5f85b59083ee07fe6b3f5875b9058195e10c8a1;hb=ac90c725e0e9b792fe2604c97285670a16cf1bf8;hp=ff5f98c9607ff42d0cd75dd952df8df2e725aae9;hpb=1b6e0daaa70405d89fbc13b37286c96966eccbc2;p=gnome.introspection-doc-generator diff --git a/JSDOC/TextStream.vala b/JSDOC/TextStream.vala index ff5f98c..e5f85b5 100644 --- a/JSDOC/TextStream.vala +++ b/JSDOC/TextStream.vala @@ -20,55 +20,58 @@ namespace JSDOC { string text; int cursor; + int length; public TextStream (string text = "") { this.text = text; + this.length = text.char_count(); this.cursor = 0; } - public char look(int n = 0, out bool eof) + public char look(int n = 0) { - eof = false; - - if (this.cursor+n < 0 || this.cursor+n >= this.text.length) { - eof = true; + + if (this.cursor+n < 0 || this.cursor+n >= this.length) { return '\0'; } - return this.text[this.cursor+n]; - }, + return this.get_char(this.cursor+n); + } public bool lookEOF(int n = 0) { - if (this.cursor+n < 0 || this.cursor+n >= this.text.length) { + if (this.cursor+n < 0 || this.cursor+n >= this.length) { return true; } - return false - }, + return false; + } - - public char next(int n = 1, out bool eof) + /** + * @param n - number of characters to return.. + */ + public string next(int n = 1) { - eof = false; + if (n < 1) { //?? eof??? return '\0'; } - char pulled; - for (var i = 0; i < n; i++) { - if (this.cursor+i < this.text.length) { - pulled += this.text.charAt(this.cursor+i); + string pulled; + var i = 0; + while (i < n) { + if (this.cursor+i < this.length) { + var add = this.text.get_char(this.cursor+i).to_string(); + pulled += add; + i += add.length; } else { - eof =true; - return '\0'; - + return ""; } } - this.cursor += n; + this.cursor += pulled.length; return pulled; }