import { IEncodable } from '../factory/factories_baseobject'; import { Int8, UInt8, Int16, UInt32, UInt16 } from './integers'; /** * Compute the number of bytes `str` occupies once UTF-8 encoded, without * allocating an intermediate buffer. Matches `TextEncoder.encode(str).length` * byte-for-byte, including the U+FFFD (3-byte) replacement `TextEncoder` emits * for unpaired surrogates. Used by the size-calculation pass so a string is not * fully UTF-8 encoded twice (once to measure, once to write). */ export declare function utf8ByteLength(str: string): number; export declare class DataStream { constructor(data: DataView | ArrayBufferLike | ArrayBufferView | number); get view(): DataView; set view(v: DataView); get pos(): number; get length(): number; set length(newLen: number); get byteLength(): number; protected _view: DataView; protected _pos: number; static binaryStoreSize(obj: IEncodable & { __namespaceArray?: string[]; }): number; /** * Gets the Float32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getFloat32(littleEndian?: boolean): number; /** * Gets the Float64 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getFloat64(littleEndian?: boolean): number; /** * Gets the Int8 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getInt8(): number; /** * Gets the Int16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getInt16(littleEndian?: boolean): number; /** * Gets the Int32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getInt32(littleEndian?: boolean): number; /** * Gets the Uint8 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getUint8(): number; getByte(): number; /** * Gets the Uint16 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getUint16(littleEndian?: boolean): number; /** * Gets the Uint32 value at the specified byte offset from the start of the view. There is * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getUint32(littleEndian?: boolean): number; /** * Stores an Float32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setFloat32(value: number, littleEndian?: boolean): void; /** * Stores an Float64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setFloat64(value: number, littleEndian?: boolean): void; /** * Stores an Int8 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. */ setInt8(value: number): void; /** * Stores an Int16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setInt16(value: number, littleEndian?: boolean): void; /** * Stores an Int32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setInt32(value: number, littleEndian?: boolean): void; /** * Stores an Uint8 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. */ setUint8(value: number): void; setByte(value: number): void; /** * Stores an Uint16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setUint16(value: number, littleEndian?: boolean): void; /** * Stores an Uint32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setUint32(value: number, littleEndian?: boolean): void; goBack(bytes: number): void; skip(bytes: number): void; rewind(): void; writeByteStream(buf?: Uint8Array | null): void; /** * read a byte stream to the stream. * the data is cloned to avoid references to huge memory blocks * ( and avoid potential problems when using the underlying ArrayBuffer directly) * * The method reads the length of the byte array from the stream as a 32 bits integer before reading the byte stream. * * @method readByteStream * @return {Uint8Array} */ readByteStream(): Uint8Array | undefined; readString(): string | undefined; writeString(str?: string | null): void; /** * @method writeArrayBuffer * @param arrayBuf {ArrayBuffer} * @param offset {Number} * @param length {Number} */ writeArrayBuffer(arrayBuf: ArrayBuffer, offset: number, length?: number): void; /** * returns an Uint8Array reprentation of the underlying arraybuffer at the current position * It does NOT COPY the data, it' just referencing it * @method readByteArray * @param length * @returns {Uint8Array} */ readByteArray(length: number): Uint8Array; /** * returns an array buffer holding a COPY of the original data * @param length * @param constructorFn */ readArrayBuffer(lengthInBytes: number): ArrayBuffer; /** * !!! important !!! * this method returns an Uint8Array from the position in the stream WITHOUT * advancing the position variable * @param pos defaults to the current position of the stream */ getUint8ArrayWithoutAdvancingPositionPointer(pos?: number, length?: number): Uint8Array; /** * !!! important !!! * this method sets an Uint8Array at the position in the stream WITHOUT * advancing the position variable * @param arr the uint8array to set at the defined position * @param pos defaults to the current position of the stream */ setUint8ArrayWithoutAdvancingPositionPointer(arr: Uint8Array, pos?: number): void; } /** * a BinaryStreamSizeCalculator can be used to quickly evaluate the required size * of a buffer by performing the same sequence of write operation. * * a BinaryStreamSizeCalculator has the same writeXXX methods as the BinaryStream stream * object. * * @class BinaryStreamSizeCalculator * @extends BinaryStream * @constructor * */ export declare class BinaryStreamSizeCalculator { length: number; constructor(); rewind(): void; setInt8(value: Int8): void; setUint8(value: UInt8): void; setInt16(value: Int16): void; setInt32(value: number): void; setInteger(value: number): void; setUint32(value: UInt32): void; setUint16(value: UInt16): void; setFloat32(value: number): void; setFloat64(value: number | [number, number]): void; setDouble(value: number | [number, number]): void; writeArrayBuffer(arrayBuf: ArrayBuffer, offset: number, byteLength: number): void; writeByteStream(buf: Uint8Array): void; writeString(str: string): void; } export declare function stringToUint8Array(str: string): Uint8Array; //# sourceMappingURL=DataStream.d.ts.map