Class DataStreamAbstract

General purpose class used for encapsulating the reading and writing of data from and to various sources using a common interface.

Hierarchy

  • FrameworkObject
    • DataStream

Constructors

  • Parameters

    • OptionalisInternalConstructor: boolean

    Returns DataStream

Accessors

  • get accessMode(): number
  • Gets the access mode of the stream.

    Returns number

  • get isFile(): boolean
  • Checks whether the stream reads/writes from a file system.

    Returns boolean

  • get isReadable(): boolean
  • Determines if the stream is readable.

    Returns boolean

  • get isValid(): boolean
  • Checks whether the stream is valid.

    Returns boolean

  • get isWriteable(): boolean
  • Determines if the stream is writable.

    Returns boolean

  • get name(): string
  • Gets the name of the stream.

    Returns string

  • get size(): number
  • Returns the total size of the data to be read from the stream, or 0 if this is indeterminate for this stream.

    Returns number

Methods

  • Aligns the read/write cursor to a byte boundary. count determines the alignment in bytes. Note the requested alignment might not be achieved if count > 1 and it would move the cursor past the capacity of the buffer, as the cursor will be clamped to buffer end regardless of alignment.

    Parameters

    • Optionalcount: number

    Returns void

  • Creates a copy of this stream.

    Parameters

    • OptionalcopyData: boolean

      If true the internal stream data will be copied as well, otherwise it will just reference the data from the original stream (in which case the caller must ensure the original stream outlives the clone). This is not relevant for file streams.

    Returns DataStream

  • Close the stream. This makes further operations invalid.

    Returns void

  • Returns true if the stream has reached the end.

    Returns boolean

  • Flushes any cached written data to the actual stream destination.

    Returns void

  • Returns a string containing the entire stream.

    Returns string

    String data encoded as UTF-8.

    This is a convenience method for text streams only, allowing you to retrieve a String object containing all the data in the stream.

  • Read the requisite number of character from the stream as UTF-8 string. Advances the read pointer.

    Parameters

    • count: number

      Number of bytes to read.

    Returns string

    The resulting string.

    Stream must be created with READ access mode.

  • Repositions the read point to a specified byte.

    Parameters

    • pos: number

    Returns void

  • Skip a defined number of bytes. This can also be a negative value, in which case the file pointer rewinds a defined number of bytes.

    Parameters

    • count: number

    Returns void

  • Returns the current byte offset from beginning.

    Returns number

  • Writes the provided narrow string to the steam. String is convered to the required encoding before being written.

    Parameters

    • string: string

      String containing narrow characters to write, encoded as UTF8.

    • Optionalencoding: EnumValue<StringEncoding, number>

      Encoding to convert the string to before writing.

    • OptionalisWritingBOM: boolean

    Returns void