The binaryXHR Javascript module implements a set of functions and classes that can be used to retrieve binary files using the XMLHttpRequest API. |
This module provides two functions, FetchBinaryURL and FetchBinaryURLAsync, that are wrappers around the XMLHttpRequest API and return an object of type BinaryFile. The first one implements a straight load, while the second one initiates an asynchronous operation handled by a callback function.
The BinaryFile class implements the methods needed to access the elements of the binary files, such as strings, integers and real numbers.
Both the functions and the class internally handle the differences between different Web Browsers, so the user of this module does not need to worry about them.
Load a binary file.
Arguments:
url:string - URL from where to load the binary file.
Output:
An object of type BinaryFile.
Initiate an asynchronous binary load.
Arguments:
url:string - URL from where to load the binary file.
callback:function(obj) - Pointer to the function that will be called when the binary file has been loaded. He function will be given a single argument; an object of type BinaryFile.
Output:
A reference to the XMLHttpRequest object.
It may be used to verify the status of the load or to implement timeouts.
The callback function will receive the loaded binary file.
This class implements the methods needed to access the content of the binary file.
Method |
Description |
---|---|
getLength() |
Return the number of bytes held by the object. |
getByteAt(idx) |
Return an 8 bit unsigned integer from offset idx. |
getShortAt(idx) |
Return a 16 bit little endian unsigned integer from offset idx. |
getLongAt(idx) |
Return a 32 bit little endian unsigned integer from offset idx. |
getSByteAt(idx) |
Return an 8 bit signed integer from offset idx. |
getSShortAt(idx) |
Return a 16 bit little endian signed integer from offset idx. |
getSLongAt(idx) |
Return a 32 bit little endian signed integer from offset idx. |
getDoubleAt(idx) |
Return a double float (64 bit little endian) from offset idx. |
getFastDoubleAt(idx) |
Return a low resolution (20 bit mantissa) double flat obtained from the high 32 bits of the original little endian double float from offset idx. |
getCharAt(idx) |
Get a character from offset idx. |
getCStringAt(idx,maxlen) |
Get a zero terminated string of limited size from offset idx. |
getStringAt(idx,len) |
Get a fixed length string from offset idx. |
This is a helper exception class that can be thrown while loading the binary file.
This module is part of the javascriptRRD
package hosted at http://javascript.sourceforge.net.
|