sbin/res/jsdoc/app/lib/JSDOC/TextStream.js
author hamidouk
Fri, 23 Dec 2011 11:38:47 +0100
branchjsdoc
changeset 520 fe008e95a716
permissions -rw-r--r--
added jsdoc support, and a script to generate the docs. Also added sample documentation for the IriSP.widget base class.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
520
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     1
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     2
/**
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     3
	@constructor
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     4
*/
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     5
JSDOC.TextStream = function(text) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     6
	if (typeof(text) == "undefined") text = "";
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     7
	text = ""+text;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     8
	this.text = text;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
     9
	this.cursor = 0;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    10
}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    11
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    12
JSDOC.TextStream.prototype.look = function(n) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    13
	if (typeof n == "undefined") n = 0;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    14
	
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    15
	if (this.cursor+n < 0 || this.cursor+n >= this.text.length) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    16
		var result = new String("");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    17
		result.eof = true;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    18
		return result;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    19
	}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    20
	return this.text.charAt(this.cursor+n);
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    21
}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    22
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    23
JSDOC.TextStream.prototype.next = function(n) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    24
	if (typeof n == "undefined") n = 1;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    25
	if (n < 1) return null;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    26
	
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    27
	var pulled = "";
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    28
	for (var i = 0; i < n; i++) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    29
		if (this.cursor+i < this.text.length) {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    30
			pulled += this.text.charAt(this.cursor+i);
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    31
		}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    32
		else {
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    33
			var result = new String("");
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    34
			result.eof = true;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    35
			return result;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    36
		}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    37
	}
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    38
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    39
	this.cursor += n;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    40
	return pulled;
fe008e95a716 added jsdoc support, and a script to generate the docs.
hamidouk
parents:
diff changeset
    41
}