Package ghidra.program.model.pcode

# Interface ByteIngest

All Known Subinterfaces:
  `Decoder`

All Known Implementing Classes:
  `PackedDecode`, `PackedDecodeOverlay`, `StringIngest`

public interface ByteIngest
An object that can ingest bytes from a stream in preparation for decoding

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clear()`
  Clear any previous cached bytes.
  `void`
  `endIngest()`
  Formal indicator that ingesting of bytes is complete and processing can begin
  `void`
  `ingestBytes(byte[] byteArray, int off, int sz)`
  Ingest bytes directly from a byte array.
  `void`
  `ingestStream(InputStream inStream)`
  Ingest bytes from the stream until the end of stream is encountered.
  `void`
  `ingestStreamToNextTerminator(InputStream inStream)`
  Ingest bytes from the stream up to (and including) the first 0 byte.
  `boolean`
  `isEmpty()`
  `void`
  `open(int max, String desc)`
  Open the ingester for receiving bytes.

- ## Method Details

  - ### clear

    void clear()
    Clear any previous cached bytes.

  - ### open

    void open(int max, String desc)
    Open the ingester for receiving bytes. This establishes the description of the source of the bytes and maximum number of bytes that can be read
    Parameters:
      `max` - is the maximum number of bytes that can be read
      `desc` - is the description of the byte source

  - ### ingestStreamToNextTerminator

    void ingestStreamToNextTerminator(InputStream inStream) throws IOException
    Ingest bytes from the stream up to (and including) the first 0 byte. This can be called multiple times to read in bytes in different chunks. An absolute limit is set on the number of bytes that can be ingested via the max parameter to a previous call to open(). If this limit is exceeded, an exception is thrown.
    Parameters:
      `inStream` - is the input stream to read from
    Throws:
      `IOException` - for errors reading from the stream

  - ### ingestStream

    void ingestStream(InputStream inStream) throws IOException
    Ingest bytes from the stream until the end of stream is encountered. An absolute limit is set on the number of bytes that can be ingested via the max parameter to a previous call to open(). If this limit is exceeded, an exception is thrown.
    Parameters:
      `inStream` - is the input stream to read from
    Throws:
      `IOException` - for errors reading from the stream

  - ### ingestBytes

    void ingestBytes(byte[] byteArray, int off, int sz) throws IOException
    Ingest bytes directly from a byte array. If these bytes would cause the total number of bytes ingested to exceed the maximum (as set by the call to open()), an exception is thrown. This can be called multiple times to read in different chunks.
    Parameters:
      `byteArray` - is the array of bytes
      `off` - is the index of the first byte to ingest
      `sz` - is the number of bytes to ingest
    Throws:
      `IOException` - if the max number of bytes to ingest is exceeded

  - ### endIngest

    void endIngest() throws IOException
    Formal indicator that ingesting of bytes is complete and processing can begin
    Throws:
      `IOException` - for errors processing the underlying stream

  - ### isEmpty

    boolean isEmpty()
    Returns:
      true if no bytes have yet been ingested via ingestStream()