import EbmlParser from "./ebmlParser"; import EbmlParserOptions from "./ebmlParserOptions"; import { ByteVector } from "../byteVector"; import { File } from "../file"; import { ILazy } from "../interfaces"; /** * An element that allows accessing typed information from a parser at a later time than parsing. */ export default class EbmlElement implements ILazy { private readonly _dataOffset; private readonly _dataSize; private readonly _file; private readonly _id; private readonly _options; private _data; /** * Constructs and initializes a new instance using a file, an offset where the target data * resides, and the number of bytes of data at that position. * @param file File containing the data * @param dataOffset Offset into the file where the data begins, must be a safe, positive integer * @param id ID of the EBML element * @param dataSize Size of the data in bytes, must be a safe, positive integer * @param parserOptions Options from the parser that read the element * @internal */ constructor(file: File, dataOffset: number, id: number, dataSize: number, parserOptions: EbmlParserOptions); /** * Gets the ID of the EBML element represented by the current instance. */ get id(): number; /** * Gets the size of the data section of the current instance. */ get length(): number; /** @inheritDoc */ get isLoaded(): boolean; /** * Reads a boolean from the current element's data section. * @returns `true` if the data stored in the element is > 0, `false` if 0 is stored */ getBool(): boolean; /** * Reads raw binary bytes from the current element's data section. * @returns Raw bytes contained in the element. */ getBytes(): ByteVector; /** * Reads a double-precision or single-precision number from the current element's data section. * @returns Floating point value contained in the element. */ getDouble(): number; /** * Creates a parser for reading the elements contained inside the current instance. */ getParser(): EbmlParser; /** * Reads a UTF8 string from the current element's data section. * @returns string String value contained in the element. */ getString(): string; /** * Read an integer from the current element's data section. * @remarks * The EBML spec supports up to 64-bit unsigned integers. Due to javascript's * implementation of `number`s and wanting to avoid using `BigInt`s everywhere an integer * is needed in this implementation, we will only support up to 52-bit unsigned integers. * @returns A `safe` integer contained in the element. */ getSafeUint(): number; /** * Read an integer from the data section. * @remarks Use this method if there's a high likelihood that the data will be >52 bits. * @returns A `safe` integer contained in the element. */ getUlong(): bigint; /** @inheritDoc */ load(): void; }