Home ⌂Doc Index ◂Up ▴

eric6.HexEdit.HexEditChunks

Module implementing the storage backend for the hex editor.

Global Attributes

None

Classes

HexEditChunk Class implementing a container for the data chunks.
HexEditChunks Class implementing the storage backend for the hex editor.

Functions

None


HexEditChunk

Class implementing a container for the data chunks.

Derived from

object

Class Attributes

None

Class Methods

None

Methods

HexEditChunk Constructor

Static Methods

None

HexEditChunk (Constructor)

HexEditChunk()

Constructor

Up


HexEditChunks

Class implementing the storage backend for the hex editor.

When HexEditWidget loads data, HexEditChunks access them using a QIODevice interface. When the app uses a QByteArray or Python bytearray interface, QBuffer is used to provide again a QIODevice like interface. No data will be changed, therefore HexEditChunks opens the QIODevice in QIODevice.ReadOnly mode. After every access HexEditChunks closes the QIODevice. That's why external applications can overwrite files while HexEditWidget shows them.

When the the user starts to edit the data, HexEditChunks creates a local copy of a chunk of data (4 kilobytes) and notes all changes there. Parallel to that chunk, there is a second chunk, which keeps track of which bytes are changed and which are not.

Derived from

object

Class Attributes

BUFFER_SIZE
CHUNK_SIZE
READ_CHUNK_MASK

Class Methods

None

Methods

HexEditChunks Constructor
__getChunkIndex Private method to get the chunk index for a position.
__getitem__ Special method to get a byte at a position.
data Public method to get data out of the chunks.
dataChanged Public method to test, if some data was changed.
indexOf Public method to search the first occurrence of some data.
insert Public method to insert a byte.
lastIndexOf Public method to search the last occurrence of some data.
overwrite Public method to overwrite a byte.
pos Public method to get the current position.
removeAt Public method to remove a byte.
setDataChanged Public method to set highlighting info.
setIODevice Public method to set an io device to read the binary data from.
size Public method to get the current data size.
write Public method to write data to an io device.

Static Methods

None

HexEditChunks (Constructor)

HexEditChunks(ioDevice=None)

Constructor

ioDevice (QIODevice)
io device to get the data from

HexEditChunks.__getChunkIndex

__getChunkIndex(absPos)

Private method to get the chunk index for a position.

This method checks, if there is already a copied chunk available. If there is one, it returns its index. If there is no copied chunk available, original data will be copied into a new chunk.

absPos (int)
absolute position of the data.
Returns:
index of the chunk containing the position
Return Type:
int

HexEditChunks.__getitem__

__getitem__(pos)

Special method to get a byte at a position.

Note: This realizes the [] get operator.

pos (int)
position of byte to get
Returns:
requested byte
Return Type:
int (range 0 to 255)

HexEditChunks.data

data(pos=0, maxSize=-1, highlighted=None)

Public method to get data out of the chunks.

pos (int)
position to get bytes from
maxSize (int)
maximum amount of bytes to get
highlighted (bytearray)
reference to a byte array storing highlighting info
Returns:
retrieved data
Return Type:
bytearray

HexEditChunks.dataChanged

dataChanged(pos)

Public method to test, if some data was changed.

pos (int)
byte position to check
Returns:
flag indicating the changed state
Return Type:
bool

HexEditChunks.indexOf

indexOf(byteArray, start)

Public method to search the first occurrence of some data.

byteArray (bytearray)
data to search for
start (int)
position to start the search at
Returns:
position the data was found at or -1 if nothing could be found
Return Type:
int

HexEditChunks.insert

insert(pos, data)

Public method to insert a byte.

pos (int)
position to insert at
data (int (range 0 to 255))
byte to insert
Returns:
flag indicating success
Return Type:
bool

HexEditChunks.lastIndexOf

lastIndexOf(byteArray, start)

Public method to search the last occurrence of some data.

byteArray (bytearray)
data to search for
start (int)
position to start the search at
Returns:
position the data was found at or -1 if nothing could be found
Return Type:
int

HexEditChunks.overwrite

overwrite(pos, data)

Public method to overwrite a byte.

pos (int)
position to overwrite
data (int (range 0 to 255))
byte to overwrite with
Returns:
flag indicating success
Return Type:
bool

HexEditChunks.pos

pos()

Public method to get the current position.

Returns:
current position
Return Type:
int

HexEditChunks.removeAt

removeAt(pos)

Public method to remove a byte.

pos (int)
position to remove
Returns:
flag indicating success
Return Type:
bool

HexEditChunks.setDataChanged

setDataChanged(pos, dataChanged)

Public method to set highlighting info.

pos (int)
position to set highlighting info for
dataChanged (bool)
flag indicating changed data

HexEditChunks.setIODevice

setIODevice(ioDevice)

Public method to set an io device to read the binary data from.

ioDevice (QIODevice)
io device to get the data from
Returns:
flag indicating successful operation
Return Type:
bool

HexEditChunks.size

size()

Public method to get the current data size.

Returns:
current data size
Return Type:
int

HexEditChunks.write

write(ioDevice, pos=0, count=-1)

Public method to write data to an io device.

ioDevice (QIODevice)
io device to write the data to
pos (int)
position to write bytes from
count (int)
amount of bytes to write
Returns:
flag indicating success
Return Type:
bool
Up



Home ⌂Doc Index ◂Up ▴