|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.HexEdit.HexEditChunks</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.HexEdit.HexEditChunks</h1> |
|
23 <p> |
|
24 Module implementing the storage backend for the hex editor. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>None</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr> |
|
33 <td><a href="#HexEditChunk">HexEditChunk</a></td> |
|
34 <td>Class implementing a container for the data chunks.</td> |
|
35 </tr><tr> |
|
36 <td><a href="#HexEditChunks">HexEditChunks</a></td> |
|
37 <td>Class implementing the storage backend for the hex editor.</td> |
|
38 </tr> |
|
39 </table> |
|
40 <h3>Functions</h3> |
|
41 <table> |
|
42 <tr><td>None</td></tr> |
|
43 </table> |
|
44 <hr /><hr /> |
|
45 <a NAME="HexEditChunk" ID="HexEditChunk"></a> |
|
46 <h2>HexEditChunk</h2> |
|
47 <p> |
|
48 Class implementing a container for the data chunks. |
|
49 </p> |
|
50 <h3>Derived from</h3> |
|
51 object |
|
52 <h3>Class Attributes</h3> |
|
53 <table> |
|
54 <tr><td>None</td></tr> |
|
55 </table> |
|
56 <h3>Class Methods</h3> |
|
57 <table> |
|
58 <tr><td>None</td></tr> |
|
59 </table> |
|
60 <h3>Methods</h3> |
|
61 <table> |
|
62 <tr> |
|
63 <td><a href="#HexEditChunk.__init__">HexEditChunk</a></td> |
|
64 <td>Constructor</td> |
|
65 </tr> |
|
66 </table> |
|
67 <h3>Static Methods</h3> |
|
68 <table> |
|
69 <tr><td>None</td></tr> |
|
70 </table> |
|
71 <a NAME="HexEditChunk.__init__" ID="HexEditChunk.__init__"></a> |
|
72 <h4>HexEditChunk (Constructor)</h4> |
|
73 <b>HexEditChunk</b>(<i></i>) |
|
74 <p> |
|
75 Constructor |
|
76 </p> |
|
77 <div align="right"><a href="#top">Up</a></div> |
|
78 <hr /><hr /> |
|
79 <a NAME="HexEditChunks" ID="HexEditChunks"></a> |
|
80 <h2>HexEditChunks</h2> |
|
81 <p> |
|
82 Class implementing the storage backend for the hex editor. |
|
83 </p><p> |
|
84 When HexEditWidget loads data, HexEditChunks access them using a QIODevice |
|
85 interface. When the app uses a QByteArray or Python bytearray interface, |
|
86 QBuffer is used to provide again a QIODevice like interface. No data will |
|
87 be changed, therefore HexEditChunks opens the QIODevice in |
|
88 QIODevice.ReadOnly mode. After every access HexEditChunks closes the |
|
89 QIODevice. That's why external applications can overwrite files while |
|
90 HexEditWidget shows them. |
|
91 </p><p> |
|
92 When the the user starts to edit the data, HexEditChunks creates a local |
|
93 copy of a chunk of data (4 kilobytes) and notes all changes there. Parallel |
|
94 to that chunk, there is a second chunk, which keeps track of which bytes |
|
95 are changed and which are not. |
|
96 </p> |
|
97 <h3>Derived from</h3> |
|
98 object |
|
99 <h3>Class Attributes</h3> |
|
100 <table> |
|
101 <tr><td>BUFFER_SIZE</td></tr><tr><td>CHUNK_SIZE</td></tr><tr><td>READ_CHUNK_MASK</td></tr> |
|
102 </table> |
|
103 <h3>Class Methods</h3> |
|
104 <table> |
|
105 <tr><td>None</td></tr> |
|
106 </table> |
|
107 <h3>Methods</h3> |
|
108 <table> |
|
109 <tr> |
|
110 <td><a href="#HexEditChunks.__init__">HexEditChunks</a></td> |
|
111 <td>Constructor</td> |
|
112 </tr><tr> |
|
113 <td><a href="#HexEditChunks.__getChunkIndex">__getChunkIndex</a></td> |
|
114 <td>Private method to get the chunk index for a position.</td> |
|
115 </tr><tr> |
|
116 <td><a href="#HexEditChunks.__getitem__">__getitem__</a></td> |
|
117 <td>Special method to get a byte at a position.</td> |
|
118 </tr><tr> |
|
119 <td><a href="#HexEditChunks.data">data</a></td> |
|
120 <td>Public method to get data out of the chunks.</td> |
|
121 </tr><tr> |
|
122 <td><a href="#HexEditChunks.dataChanged">dataChanged</a></td> |
|
123 <td>Public method to test, if some data was changed.</td> |
|
124 </tr><tr> |
|
125 <td><a href="#HexEditChunks.indexOf">indexOf</a></td> |
|
126 <td>Public method to search the first occurrence of some data.</td> |
|
127 </tr><tr> |
|
128 <td><a href="#HexEditChunks.insert">insert</a></td> |
|
129 <td>Public method to insert a byte.</td> |
|
130 </tr><tr> |
|
131 <td><a href="#HexEditChunks.lastIndexOf">lastIndexOf</a></td> |
|
132 <td>Public method to search the last occurrence of some data.</td> |
|
133 </tr><tr> |
|
134 <td><a href="#HexEditChunks.overwrite">overwrite</a></td> |
|
135 <td>Public method to overwrite a byte.</td> |
|
136 </tr><tr> |
|
137 <td><a href="#HexEditChunks.pos">pos</a></td> |
|
138 <td>Public method to get the current position.</td> |
|
139 </tr><tr> |
|
140 <td><a href="#HexEditChunks.removeAt">removeAt</a></td> |
|
141 <td>Public method to remove a byte.</td> |
|
142 </tr><tr> |
|
143 <td><a href="#HexEditChunks.setDataChanged">setDataChanged</a></td> |
|
144 <td>Public method to set highlighting info.</td> |
|
145 </tr><tr> |
|
146 <td><a href="#HexEditChunks.setIODevice">setIODevice</a></td> |
|
147 <td>Public method to set an io device to read the binary data from.</td> |
|
148 </tr><tr> |
|
149 <td><a href="#HexEditChunks.size">size</a></td> |
|
150 <td>Public method to get the current data size.</td> |
|
151 </tr><tr> |
|
152 <td><a href="#HexEditChunks.write">write</a></td> |
|
153 <td>Public method to write data to an io device.</td> |
|
154 </tr> |
|
155 </table> |
|
156 <h3>Static Methods</h3> |
|
157 <table> |
|
158 <tr><td>None</td></tr> |
|
159 </table> |
|
160 <a NAME="HexEditChunks.__init__" ID="HexEditChunks.__init__"></a> |
|
161 <h4>HexEditChunks (Constructor)</h4> |
|
162 <b>HexEditChunks</b>(<i>ioDevice=None</i>) |
|
163 <p> |
|
164 Constructor |
|
165 </p><dl> |
|
166 <dt><i>ioDevice</i> (QIODevice)</dt> |
|
167 <dd> |
|
168 io device to get the data from |
|
169 </dd> |
|
170 </dl><a NAME="HexEditChunks.__getChunkIndex" ID="HexEditChunks.__getChunkIndex"></a> |
|
171 <h4>HexEditChunks.__getChunkIndex</h4> |
|
172 <b>__getChunkIndex</b>(<i>absPos</i>) |
|
173 <p> |
|
174 Private method to get the chunk index for a position. |
|
175 </p><p> |
|
176 This method checks, if there is already a copied chunk available. If |
|
177 there is one, it returns its index. If there is no copied chunk |
|
178 available, original data will be copied into a new chunk. |
|
179 </p><dl> |
|
180 <dt><i>absPos</i> (int)</dt> |
|
181 <dd> |
|
182 absolute position of the data. |
|
183 </dd> |
|
184 </dl><dl> |
|
185 <dt>Returns:</dt> |
|
186 <dd> |
|
187 index of the chunk containing the position |
|
188 </dd> |
|
189 </dl><dl> |
|
190 <dt>Return Type:</dt> |
|
191 <dd> |
|
192 int |
|
193 </dd> |
|
194 </dl><a NAME="HexEditChunks.__getitem__" ID="HexEditChunks.__getitem__"></a> |
|
195 <h4>HexEditChunks.__getitem__</h4> |
|
196 <b>__getitem__</b>(<i>pos</i>) |
|
197 <p> |
|
198 Special method to get a byte at a position. |
|
199 </p><p> |
|
200 Note: This realizes the [] get operator. |
|
201 </p><dl> |
|
202 <dt><i>pos</i> (int)</dt> |
|
203 <dd> |
|
204 position of byte to get |
|
205 </dd> |
|
206 </dl><dl> |
|
207 <dt>Returns:</dt> |
|
208 <dd> |
|
209 requested byte |
|
210 </dd> |
|
211 </dl><dl> |
|
212 <dt>Return Type:</dt> |
|
213 <dd> |
|
214 int (range 0 to 255) |
|
215 </dd> |
|
216 </dl><a NAME="HexEditChunks.data" ID="HexEditChunks.data"></a> |
|
217 <h4>HexEditChunks.data</h4> |
|
218 <b>data</b>(<i>pos=0, maxSize=-1, highlighted=None</i>) |
|
219 <p> |
|
220 Public method to get data out of the chunks. |
|
221 </p><dl> |
|
222 <dt><i>pos</i> (int)</dt> |
|
223 <dd> |
|
224 position to get bytes from |
|
225 </dd><dt><i>maxSize</i> (int)</dt> |
|
226 <dd> |
|
227 maximum amount of bytes to get |
|
228 </dd><dt><i>highlighted</i> (bytearray)</dt> |
|
229 <dd> |
|
230 reference to a byte array storing highlighting info |
|
231 </dd> |
|
232 </dl><dl> |
|
233 <dt>Returns:</dt> |
|
234 <dd> |
|
235 retrieved data |
|
236 </dd> |
|
237 </dl><dl> |
|
238 <dt>Return Type:</dt> |
|
239 <dd> |
|
240 bytearray |
|
241 </dd> |
|
242 </dl><a NAME="HexEditChunks.dataChanged" ID="HexEditChunks.dataChanged"></a> |
|
243 <h4>HexEditChunks.dataChanged</h4> |
|
244 <b>dataChanged</b>(<i>pos</i>) |
|
245 <p> |
|
246 Public method to test, if some data was changed. |
|
247 </p><dl> |
|
248 <dt><i>pos</i> (int)</dt> |
|
249 <dd> |
|
250 byte position to check |
|
251 </dd> |
|
252 </dl><dl> |
|
253 <dt>Returns:</dt> |
|
254 <dd> |
|
255 flag indicating the changed state |
|
256 </dd> |
|
257 </dl><dl> |
|
258 <dt>Return Type:</dt> |
|
259 <dd> |
|
260 bool |
|
261 </dd> |
|
262 </dl><a NAME="HexEditChunks.indexOf" ID="HexEditChunks.indexOf"></a> |
|
263 <h4>HexEditChunks.indexOf</h4> |
|
264 <b>indexOf</b>(<i>byteArray, start</i>) |
|
265 <p> |
|
266 Public method to search the first occurrence of some data. |
|
267 </p><dl> |
|
268 <dt><i>byteArray</i> (bytearray)</dt> |
|
269 <dd> |
|
270 data to search for |
|
271 </dd><dt><i>start</i> (int)</dt> |
|
272 <dd> |
|
273 position to start the search at |
|
274 </dd> |
|
275 </dl><dl> |
|
276 <dt>Returns:</dt> |
|
277 <dd> |
|
278 position the data was found at or -1 if nothing could be found |
|
279 </dd> |
|
280 </dl><dl> |
|
281 <dt>Return Type:</dt> |
|
282 <dd> |
|
283 int |
|
284 </dd> |
|
285 </dl><a NAME="HexEditChunks.insert" ID="HexEditChunks.insert"></a> |
|
286 <h4>HexEditChunks.insert</h4> |
|
287 <b>insert</b>(<i>pos, data</i>) |
|
288 <p> |
|
289 Public method to insert a byte. |
|
290 </p><dl> |
|
291 <dt><i>pos</i> (int)</dt> |
|
292 <dd> |
|
293 position to insert at |
|
294 </dd><dt><i>data</i> (int (range 0 to 255))</dt> |
|
295 <dd> |
|
296 byte to insert |
|
297 </dd> |
|
298 </dl><dl> |
|
299 <dt>Returns:</dt> |
|
300 <dd> |
|
301 flag indicating success |
|
302 </dd> |
|
303 </dl><dl> |
|
304 <dt>Return Type:</dt> |
|
305 <dd> |
|
306 bool |
|
307 </dd> |
|
308 </dl><a NAME="HexEditChunks.lastIndexOf" ID="HexEditChunks.lastIndexOf"></a> |
|
309 <h4>HexEditChunks.lastIndexOf</h4> |
|
310 <b>lastIndexOf</b>(<i>byteArray, start</i>) |
|
311 <p> |
|
312 Public method to search the last occurrence of some data. |
|
313 </p><dl> |
|
314 <dt><i>byteArray</i> (bytearray)</dt> |
|
315 <dd> |
|
316 data to search for |
|
317 </dd><dt><i>start</i> (int)</dt> |
|
318 <dd> |
|
319 position to start the search at |
|
320 </dd> |
|
321 </dl><dl> |
|
322 <dt>Returns:</dt> |
|
323 <dd> |
|
324 position the data was found at or -1 if nothing could be found |
|
325 </dd> |
|
326 </dl><dl> |
|
327 <dt>Return Type:</dt> |
|
328 <dd> |
|
329 int |
|
330 </dd> |
|
331 </dl><a NAME="HexEditChunks.overwrite" ID="HexEditChunks.overwrite"></a> |
|
332 <h4>HexEditChunks.overwrite</h4> |
|
333 <b>overwrite</b>(<i>pos, data</i>) |
|
334 <p> |
|
335 Public method to overwrite a byte. |
|
336 </p><dl> |
|
337 <dt><i>pos</i> (int)</dt> |
|
338 <dd> |
|
339 position to overwrite |
|
340 </dd><dt><i>data</i> (int (range 0 to 255))</dt> |
|
341 <dd> |
|
342 byte to overwrite with |
|
343 </dd> |
|
344 </dl><dl> |
|
345 <dt>Returns:</dt> |
|
346 <dd> |
|
347 flag indicating success |
|
348 </dd> |
|
349 </dl><dl> |
|
350 <dt>Return Type:</dt> |
|
351 <dd> |
|
352 bool |
|
353 </dd> |
|
354 </dl><a NAME="HexEditChunks.pos" ID="HexEditChunks.pos"></a> |
|
355 <h4>HexEditChunks.pos</h4> |
|
356 <b>pos</b>(<i></i>) |
|
357 <p> |
|
358 Public method to get the current position. |
|
359 </p><dl> |
|
360 <dt>Returns:</dt> |
|
361 <dd> |
|
362 current position |
|
363 </dd> |
|
364 </dl><dl> |
|
365 <dt>Return Type:</dt> |
|
366 <dd> |
|
367 int |
|
368 </dd> |
|
369 </dl><a NAME="HexEditChunks.removeAt" ID="HexEditChunks.removeAt"></a> |
|
370 <h4>HexEditChunks.removeAt</h4> |
|
371 <b>removeAt</b>(<i>pos</i>) |
|
372 <p> |
|
373 Public method to remove a byte. |
|
374 </p><dl> |
|
375 <dt><i>pos</i> (int)</dt> |
|
376 <dd> |
|
377 position to remove |
|
378 </dd> |
|
379 </dl><dl> |
|
380 <dt>Returns:</dt> |
|
381 <dd> |
|
382 flag indicating success |
|
383 </dd> |
|
384 </dl><dl> |
|
385 <dt>Return Type:</dt> |
|
386 <dd> |
|
387 bool |
|
388 </dd> |
|
389 </dl><a NAME="HexEditChunks.setDataChanged" ID="HexEditChunks.setDataChanged"></a> |
|
390 <h4>HexEditChunks.setDataChanged</h4> |
|
391 <b>setDataChanged</b>(<i>pos, dataChanged</i>) |
|
392 <p> |
|
393 Public method to set highlighting info. |
|
394 </p><dl> |
|
395 <dt><i>pos</i> (int)</dt> |
|
396 <dd> |
|
397 position to set highlighting info for |
|
398 </dd><dt><i>dataChanged</i> (bool)</dt> |
|
399 <dd> |
|
400 flag indicating changed data |
|
401 </dd> |
|
402 </dl><a NAME="HexEditChunks.setIODevice" ID="HexEditChunks.setIODevice"></a> |
|
403 <h4>HexEditChunks.setIODevice</h4> |
|
404 <b>setIODevice</b>(<i>ioDevice</i>) |
|
405 <p> |
|
406 Public method to set an io device to read the binary data from. |
|
407 </p><dl> |
|
408 <dt><i>ioDevice</i> (QIODevice)</dt> |
|
409 <dd> |
|
410 io device to get the data from |
|
411 </dd> |
|
412 </dl><dl> |
|
413 <dt>Returns:</dt> |
|
414 <dd> |
|
415 flag indicating successful operation |
|
416 </dd> |
|
417 </dl><dl> |
|
418 <dt>Return Type:</dt> |
|
419 <dd> |
|
420 bool |
|
421 </dd> |
|
422 </dl><a NAME="HexEditChunks.size" ID="HexEditChunks.size"></a> |
|
423 <h4>HexEditChunks.size</h4> |
|
424 <b>size</b>(<i></i>) |
|
425 <p> |
|
426 Public method to get the current data size. |
|
427 </p><dl> |
|
428 <dt>Returns:</dt> |
|
429 <dd> |
|
430 current data size |
|
431 </dd> |
|
432 </dl><dl> |
|
433 <dt>Return Type:</dt> |
|
434 <dd> |
|
435 int |
|
436 </dd> |
|
437 </dl><a NAME="HexEditChunks.write" ID="HexEditChunks.write"></a> |
|
438 <h4>HexEditChunks.write</h4> |
|
439 <b>write</b>(<i>ioDevice, pos=0, count=-1</i>) |
|
440 <p> |
|
441 Public method to write data to an io device. |
|
442 </p><dl> |
|
443 <dt><i>ioDevice</i> (QIODevice)</dt> |
|
444 <dd> |
|
445 io device to write the data to |
|
446 </dd><dt><i>pos</i> (int)</dt> |
|
447 <dd> |
|
448 position to write bytes from |
|
449 </dd><dt><i>count</i> (int)</dt> |
|
450 <dd> |
|
451 amount of bytes to write |
|
452 </dd> |
|
453 </dl><dl> |
|
454 <dt>Returns:</dt> |
|
455 <dd> |
|
456 flag indicating success |
|
457 </dd> |
|
458 </dl><dl> |
|
459 <dt>Return Type:</dt> |
|
460 <dd> |
|
461 bool |
|
462 </dd> |
|
463 </dl> |
|
464 <div align="right"><a href="#top">Up</a></div> |
|
465 <hr /> |
|
466 </body></html> |