1 /**
  2  * Class that assists in reading byte-based datastreams. granting 
  3  * the ability to read wherever in the stream you wish. You can convert 
  4  * groups of byte data into familiar types, or just retrieve the raw data itself.
  5  *
  6  * When working with binary assets, it's often necessary to work with raw byte data. 
  7  * Inherently, Javascript doesn't provide many ways to handle 
  8  * non-text data manipulation. inputBuffer Allows for reading that sort of 
  9  * data to be interpreted later, or read stream-wise. This contrasts with 
 10  * {@link outputBuffer}, which aims to be the write-only complement to inputBuffer.
 11  *
 12  * @example js
 13  * // Creates a new inputbuffer from the static helper in sandboxe
 14  * var myBuffer = sandboxe.inputBuffer.create();
 15  *
 16  * // Opens a file named 'binaryFile' and dumps its contents within the buffer.
 17  * myBuffer.open('binaryFile');
 18  *
 19  * // Reads a floating point (decimal) value from the buffer 
 20  * value1 = myBuffer.read(sandboxe.type.float);
 21  *
 22  * // Then reads the next 10 bytes as a UTF8 string.
 23  * str1 = myBuffer.readString(13);
 24  *
 25  * @class inputBuffer
 26  */ 
 27  function inputBuffer() {
 28      
 29      /**
 30       * Opens the given array as the source of an input buffer. The data is copied and 
 31       * placed within the input buffer, so the input array does not need to be preserved.
 32       *
 33       * @param {Array} array An array of raw byte values. 
 34       */     
 35      this.openBuffer = function(array){};
 36 
 37      /**
 38       * Opens the given file as the source of an input buffer. 
 39       *
 40       * @param {String} path Path to the file to open as an input buffer.
 41       */     
 42      this.open = function(path){};
 43      
 44      /**
 45       * Reads a UTF8 string object from the input buffer.
 46       *
 47       * @param {Number} numBytes The number of characters to read from the buffer.
 48       */          
 49      this.readString = function(numBytes){};
 50      
 51      
 52      /**
 53       * Reads the next object from the given byte stream.
 54       * @param {Number} type Refer to {@link sandboxe.type} for valid values to be read.
 55       * @returns {Object} The value requested.
 56       */
 57      this.read = function(){};
 58      
 59     /**
 60      * Size of the input bufer stream in bytes. Writing this property does nothing.
 61      * @type {Number}
 62      *
 63      */
 64     this.size = 0;
 65     
 66     /**
 67      * The current byte index being read. The position is automatically updated 
 68      * when reading using {@link inputBuffer.read} and similar functions
 69      * @type {Number}
 70      */
 71     this.position = 0;
 72      
 73 
 74     
 75     
 76     
 77      
 78     return this;
 79 }