smartinspectpython.sibinarycontext

@export
class SIBinaryContext(smartinspectpython.siviewercontext.SIViewerContext):

This is the base class for all viewer contexts which deal with binary data. A viewer context is the library-side representation of a viewer in the Console.

Threadsafety:

This class is not guaranteed to be thread-safe.

Initializes a new instance of the class.

Arguments:
  • vi (SIViewerId): The viewer ID to use.
ViewerData: _io.BytesIO

Overridden. Returns the actual binary data which will be displayed in the viewer specified by the viewer id.

def AppendBytes(self, buffer: bytes) -> None:

Appends a buffer of data to the stream.

Arguments:
  • buffer (bytes): The buffer to append.
Raises:
  • SIArgumentNullException: The buffer argument is null.
def AppendBytesWithOffset(self, buffer: bytes, offset: int, count: int) -> None:

Appends a buffer of data to the stream, specifying the offset in the buffer and the amount of bytes to append.

Arguments:
  • buffer (bytes): The buffer to append.
  • offset (int): The offset at which to begin appending.
  • count (int): The number of bytes to append.
Raises:
  • SIArgumentNullException: The buffer argument is null
  • ArgumentException: The sum of the offset and count parameters is greater than the actual buffer length.
  • SIArgumentOutOfRangeException: The offset or count parameter is negative.
def Dispose(self, disposing: bool) -> None:

Releases any resources.

Arguments:
  • disposing (bool): True if managed resources should be released and false otherwise.
def LoadFromFile(self, fileName: str) -> None:

Loads the binary data from a file.

Arguments:
  • fileName (str): The name of the file to load the binary data from.
Raises:
  • SIArgumentNullException: The filename argument is null.
  • IOException: An I/O error occurred.
def LoadFromStream(self, stream: _io.BytesIO) -> None:

Loads the binary data from a stream.

Arguments:
  • stream (BytesIO): The stream to load the binary data from.
Raises:
  • SIArgumentNullException: The stream argument is null.
  • IOException: An I/O error occurred.

If the supplied stream supports seeking then the entire stream content will be read and the stream position will be restored correctly. Otherwise the data will be read from the current position to the end and the original position can not be restored.

def ResetData(self) -> None:

Resets the internal data stream.

This method is intended to reset the internal data stream if custom handling of data is needed by derived classes.