1 /**
  2  * outputBuffers, like {@link inputBuffer}s assist in working with raw binary data 
  3  * as a basic datastream. Much of its functionality mimics inputBuffer, but with 
  4  * write-only equivalents
  5  *
  6  * @example
  7  * // Creates a new, empty outputBuffer.
  8  * var myBuffer = sandboxe.outputBuffer.create();
  9  *
 10  * // Writes a decimal value to the outputBuffer. (standard single precision of 4 bytes)
 11  * myBuffer.write(sandboxe.type.float, 3.14);
 12  *
 13  * // Writes a string to the buffer as well
 14  * myBuffer.writeString('Hello, world!');
 15  *
 16  * // Send all written data to a binary file
 17  * myBuffer.commit('binaryFile');
 18  * @class outputBuffer
 19  */
 20 function outputBuffer() {
 21     
 22     /**
 23      * Appends the data to the outputBuffer.
 24      * @param {Number} type Refer to {@link sandboxe.type} for valid values to be read.
 25      * @param {Number} data The data to write to the outputBuffer 
 26      */
 27     this.write = function(type, data){};
 28 
 29 
 30     /**
 31      * Appends the given byte data to the outputBuffer.
 32      * @param {Array} bytes The array of byte values to write.
 33      */
 34     this.writeBytes = function(bytes){};
 35 
 36     
 37     /**
 38      * Appends the given string to the outputBuffer. Only the UTF8 data is 
 39      * written to the string.
 40      * @param {String} string The string object to write.
 41      */
 42     this.writeString = function(string){};
 43     
 44     /**
 45      * Returns a copy of the written data as an array of raw byte values.
 46      * This does not modify the outputBuffer in any way.
 47      * @returns {Array} An array of raw byte values.
 48      */
 49     this.getData = function(){};
 50         
 51     /**
 52      * Removes all written bytes to the outputBuffer and puts the outputBuffer in a default state.
 53      */
 54     this.clear = function(){};
 55     
 56     /**
 57      * Writes a file containing exactly the bytes written to the outputBuffer
 58      * @param {String} path The path to write the file to.
 59      */
 60     this.commit = function(path){}
 61     
 62     
 63     
 64     
 65     /**
 66      * The total size of the data written to the outputBuffer in bytes.
 67      * @type {Number}
 68      */
 69     this.size = 0;
 70     
 71     return this;
 72 }