Package ghidra.program.model.pcode
Class PackedBytes
java.lang.Object
java.io.OutputStream
ghidra.program.model.pcode.PackedBytes
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
A class for dynamically collecting a stream of bytes and then later dumping those bytes to a stream
It allows the bytes to be edited in the middle of collection
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
find
(int start, int val) int
getByte
(int streampos) Inspect the middle of the byte stream accumulated so farvoid
insertByte
(int streampos, int val) Overwrite bytes that have already been written into the streamint
size()
void
write
(byte[] byteArray, int off, int len) Dump an array of bytes to the packed byte streamvoid
write
(int val) Dump a single byte to the packed byte streamvoid
Write the accumulated packed byte stream onto the output streamMethods inherited from class java.io.OutputStream
close, flush, nullOutputStream, write
-
Constructor Details
-
PackedBytes
public PackedBytes(int startlen)
-
-
Method Details
-
size
public int size() -
getByte
public int getByte(int streampos) Inspect the middle of the byte stream accumulated so far- Parameters:
streampos
- is the index of the byte to inspect- Returns:
- a byte value from the stream
-
insertByte
public void insertByte(int streampos, int val) Overwrite bytes that have already been written into the stream- Parameters:
streampos
- is the index of the byte to overwriteval
- is the value to overwrite with
-
write
public void write(int val) Dump a single byte to the packed byte stream- Specified by:
write
in classOutputStream
- Parameters:
val
- is the byte to be written
-
write
public void write(byte[] byteArray, int off, int len) Dump an array of bytes to the packed byte stream- Overrides:
write
in classOutputStream
- Parameters:
byteArray
- is the byte array
-
find
public int find(int start, int val) -
writeTo
Write the accumulated packed byte stream onto the output stream- Parameters:
s
- is the output stream receiving the bytes- Throws:
IOException
- for stream errors
-