From 84332ab81c1b445195f1d9be8bbeae0725c8e758 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 6 Mar 2012 10:58:25 -0800 Subject: Squashed commit of preload-fix into Master - Requiring all the previously pre-loaded files - RDGE, Codemirror and gl-matrix are not included via a script tag. Signed-off-by: Valerio Virgillito --- js/helper-classes/backup-delete/ParseUtils.js | 84 +++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 js/helper-classes/backup-delete/ParseUtils.js (limited to 'js/helper-classes/backup-delete/ParseUtils.js') diff --git a/js/helper-classes/backup-delete/ParseUtils.js b/js/helper-classes/backup-delete/ParseUtils.js new file mode 100755 index 00000000..556253e9 --- /dev/null +++ b/js/helper-classes/backup-delete/ParseUtils.js @@ -0,0 +1,84 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +/////////////////////////////////////////////////////////////////////// +// Class Utils +// Vector Utility functions +/////////////////////////////////////////////////////////////////////// +function ParseUtils( theStr ) +{ + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + this._strBuffer = theStr; + + /////////////////////////////////////////////////////////////////////// + // Property accessors + /////////////////////////////////////////////////////////////////////// + this.getBuffer = function() { return this._strBuffer; } + this.setBuffer = function(b) { this._strBuffer = b; } + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + this.nextValue = function( prop, endKeyArg, advanceBufferArg ) + { + if (!this._strBuffer) return; + + // make the 2 & 3rd argument optional. default is to advance the string + var endKey = "\n", advanceBuffer = true; + if (endKeyArg) + endKey = endKeyArg; + if (advanceBufferArg) + advanceBuffer = advanceBufferArg; + + var iStart = this._strBuffer.indexOf( prop ); + if (iStart < 0) return; + + var iEnd = this._strBuffer.indexOf( endKey, iStart ); + if (iEnd < 0) throw new Error( "property " + prop + " improperly terminated: " + this._strBuffer); + + iStart += prop.length; + var nChars = iEnd - iStart; + var rtnStr = this._strBuffer.substr( iStart, nChars ); + + if (advanceBuffer) + this._strBuffer = this._strBuffer.substr( iEnd + endKey.length ); + + return rtnStr; + } + + this.nextToken = function() + { + if (!this._strBuffer) return; + + // find the limits + var index = this._strBuffer.search( /\S/ ); // first non-whitespace character + if (index > 0) this._strBuffer = this._strBuffer.slice(index); + index = this._strBuffer.search( /\s/ ); // first whitespace character marking the end of the token + + var token; + if (index > 0) + { + token = this._strBuffer.slice(0, index); + this._strBuffer = this._strBuffer.slice( index ); + } + + return token; + } + + this.advancePastToken = function( token ) + { + var index = this._strBuffer.indexOf( token ); + if (index < 0) + console.log( "could not find token: " + token + " in string: " + this._strBuffer ); + else + this._strBuffer = this._strBuffer.substr( index + token.length ); + } + +} + + -- cgit v1.2.3