|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.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> |
|
22 <a NAME="top" ID="top"></a> |
|
23 <h1>eric7.HexEdit.HexEditChunks</h1> |
|
24 |
|
25 <p> |
|
26 Module implementing the storage backend for the hex editor. |
|
27 </p> |
|
28 <h3>Global Attributes</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <h3>Classes</h3> |
|
34 |
|
35 <table> |
|
36 |
|
37 <tr> |
|
38 <td><a href="#HexEditChunk">HexEditChunk</a></td> |
|
39 <td>Class implementing a container for the data chunks.</td> |
|
40 </tr> |
|
41 <tr> |
|
42 <td><a href="#HexEditChunks">HexEditChunks</a></td> |
|
43 <td>Class implementing the storage backend for the hex editor.</td> |
|
44 </tr> |
|
45 </table> |
|
46 <h3>Functions</h3> |
|
47 |
|
48 <table> |
|
49 <tr><td>None</td></tr> |
|
50 </table> |
|
51 <hr /> |
|
52 <hr /> |
|
53 <a NAME="HexEditChunk" ID="HexEditChunk"></a> |
|
54 <h2>HexEditChunk</h2> |
|
55 |
|
56 <p> |
|
57 Class implementing a container for the data chunks. |
|
58 </p> |
|
59 <h3>Derived from</h3> |
|
60 None |
|
61 <h3>Class Attributes</h3> |
|
62 |
|
63 <table> |
|
64 <tr><td>None</td></tr> |
|
65 </table> |
|
66 <h3>Class Methods</h3> |
|
67 |
|
68 <table> |
|
69 <tr><td>None</td></tr> |
|
70 </table> |
|
71 <h3>Methods</h3> |
|
72 |
|
73 <table> |
|
74 |
|
75 <tr> |
|
76 <td><a href="#HexEditChunk.__init__">HexEditChunk</a></td> |
|
77 <td>Constructor</td> |
|
78 </tr> |
|
79 </table> |
|
80 <h3>Static Methods</h3> |
|
81 |
|
82 <table> |
|
83 <tr><td>None</td></tr> |
|
84 </table> |
|
85 |
|
86 <a NAME="HexEditChunk.__init__" ID="HexEditChunk.__init__"></a> |
|
87 <h4>HexEditChunk (Constructor)</h4> |
|
88 <b>HexEditChunk</b>(<i></i>) |
|
89 |
|
90 <p> |
|
91 Constructor |
|
92 </p> |
|
93 <div align="right"><a href="#top">Up</a></div> |
|
94 <hr /> |
|
95 <hr /> |
|
96 <a NAME="HexEditChunks" ID="HexEditChunks"></a> |
|
97 <h2>HexEditChunks</h2> |
|
98 |
|
99 <p> |
|
100 Class implementing the storage backend for the hex editor. |
|
101 </p> |
|
102 <p> |
|
103 When HexEditWidget loads data, HexEditChunks access them using a QIODevice |
|
104 interface. When the app uses a QByteArray or Python bytearray interface, |
|
105 QBuffer is used to provide again a QIODevice like interface. No data will |
|
106 be changed, therefore HexEditChunks opens the QIODevice in |
|
107 QIODevice.OpenModeFlag.ReadOnly mode. After every access HexEditChunks |
|
108 closes the QIODevice. That's why external applications can overwrite |
|
109 files while HexEditWidget shows them. |
|
110 </p> |
|
111 <p> |
|
112 When the the user starts to edit the data, HexEditChunks creates a local |
|
113 copy of a chunk of data (4 kilobytes) and notes all changes there. Parallel |
|
114 to that chunk, there is a second chunk, which keeps track of which bytes |
|
115 are changed and which are not. |
|
116 </p> |
|
117 <h3>Derived from</h3> |
|
118 None |
|
119 <h3>Class Attributes</h3> |
|
120 |
|
121 <table> |
|
122 <tr><td>BUFFER_SIZE</td></tr><tr><td>CHUNK_SIZE</td></tr><tr><td>READ_CHUNK_MASK</td></tr> |
|
123 </table> |
|
124 <h3>Class Methods</h3> |
|
125 |
|
126 <table> |
|
127 <tr><td>None</td></tr> |
|
128 </table> |
|
129 <h3>Methods</h3> |
|
130 |
|
131 <table> |
|
132 |
|
133 <tr> |
|
134 <td><a href="#HexEditChunks.__init__">HexEditChunks</a></td> |
|
135 <td>Constructor</td> |
|
136 </tr> |
|
137 <tr> |
|
138 <td><a href="#HexEditChunks.__getChunkIndex">__getChunkIndex</a></td> |
|
139 <td>Private method to get the chunk index for a position.</td> |
|
140 </tr> |
|
141 <tr> |
|
142 <td><a href="#HexEditChunks.__getitem__">__getitem__</a></td> |
|
143 <td>Special method to get a byte at a position.</td> |
|
144 </tr> |
|
145 <tr> |
|
146 <td><a href="#HexEditChunks.data">data</a></td> |
|
147 <td>Public method to get data out of the chunks.</td> |
|
148 </tr> |
|
149 <tr> |
|
150 <td><a href="#HexEditChunks.dataChanged">dataChanged</a></td> |
|
151 <td>Public method to test, if some data was changed.</td> |
|
152 </tr> |
|
153 <tr> |
|
154 <td><a href="#HexEditChunks.indexOf">indexOf</a></td> |
|
155 <td>Public method to search the first occurrence of some data.</td> |
|
156 </tr> |
|
157 <tr> |
|
158 <td><a href="#HexEditChunks.insert">insert</a></td> |
|
159 <td>Public method to insert a byte.</td> |
|
160 </tr> |
|
161 <tr> |
|
162 <td><a href="#HexEditChunks.lastIndexOf">lastIndexOf</a></td> |
|
163 <td>Public method to search the last occurrence of some data.</td> |
|
164 </tr> |
|
165 <tr> |
|
166 <td><a href="#HexEditChunks.overwrite">overwrite</a></td> |
|
167 <td>Public method to overwrite a byte.</td> |
|
168 </tr> |
|
169 <tr> |
|
170 <td><a href="#HexEditChunks.pos">pos</a></td> |
|
171 <td>Public method to get the current position.</td> |
|
172 </tr> |
|
173 <tr> |
|
174 <td><a href="#HexEditChunks.removeAt">removeAt</a></td> |
|
175 <td>Public method to remove a byte.</td> |
|
176 </tr> |
|
177 <tr> |
|
178 <td><a href="#HexEditChunks.setDataChanged">setDataChanged</a></td> |
|
179 <td>Public method to set highlighting info.</td> |
|
180 </tr> |
|
181 <tr> |
|
182 <td><a href="#HexEditChunks.setIODevice">setIODevice</a></td> |
|
183 <td>Public method to set an io device to read the binary data from.</td> |
|
184 </tr> |
|
185 <tr> |
|
186 <td><a href="#HexEditChunks.size">size</a></td> |
|
187 <td>Public method to get the current data size.</td> |
|
188 </tr> |
|
189 <tr> |
|
190 <td><a href="#HexEditChunks.write">write</a></td> |
|
191 <td>Public method to write data to an io device.</td> |
|
192 </tr> |
|
193 </table> |
|
194 <h3>Static Methods</h3> |
|
195 |
|
196 <table> |
|
197 <tr><td>None</td></tr> |
|
198 </table> |
|
199 |
|
200 <a NAME="HexEditChunks.__init__" ID="HexEditChunks.__init__"></a> |
|
201 <h4>HexEditChunks (Constructor)</h4> |
|
202 <b>HexEditChunks</b>(<i>ioDevice=None</i>) |
|
203 |
|
204 <p> |
|
205 Constructor |
|
206 </p> |
|
207 <dl> |
|
208 |
|
209 <dt><i>ioDevice</i> (QIODevice)</dt> |
|
210 <dd> |
|
211 io device to get the data from |
|
212 </dd> |
|
213 </dl> |
|
214 <a NAME="HexEditChunks.__getChunkIndex" ID="HexEditChunks.__getChunkIndex"></a> |
|
215 <h4>HexEditChunks.__getChunkIndex</h4> |
|
216 <b>__getChunkIndex</b>(<i>absPos</i>) |
|
217 |
|
218 <p> |
|
219 Private method to get the chunk index for a position. |
|
220 </p> |
|
221 <p> |
|
222 This method checks, if there is already a copied chunk available. If |
|
223 there is one, it returns its index. If there is no copied chunk |
|
224 available, original data will be copied into a new chunk. |
|
225 </p> |
|
226 <dl> |
|
227 |
|
228 <dt><i>absPos</i> (int)</dt> |
|
229 <dd> |
|
230 absolute position of the data. |
|
231 </dd> |
|
232 </dl> |
|
233 <dl> |
|
234 <dt>Return:</dt> |
|
235 <dd> |
|
236 index of the chunk containing the position |
|
237 </dd> |
|
238 </dl> |
|
239 <dl> |
|
240 <dt>Return Type:</dt> |
|
241 <dd> |
|
242 int |
|
243 </dd> |
|
244 </dl> |
|
245 <a NAME="HexEditChunks.__getitem__" ID="HexEditChunks.__getitem__"></a> |
|
246 <h4>HexEditChunks.__getitem__</h4> |
|
247 <b>__getitem__</b>(<i>pos</i>) |
|
248 |
|
249 <p> |
|
250 Special method to get a byte at a position. |
|
251 </p> |
|
252 <p> |
|
253 Note: This realizes the [] get operator. |
|
254 </p> |
|
255 <dl> |
|
256 |
|
257 <dt><i>pos</i> (int)</dt> |
|
258 <dd> |
|
259 position of byte to get |
|
260 </dd> |
|
261 </dl> |
|
262 <dl> |
|
263 <dt>Return:</dt> |
|
264 <dd> |
|
265 requested byte |
|
266 </dd> |
|
267 </dl> |
|
268 <dl> |
|
269 <dt>Return Type:</dt> |
|
270 <dd> |
|
271 int (range 0 to 255) |
|
272 </dd> |
|
273 </dl> |
|
274 <a NAME="HexEditChunks.data" ID="HexEditChunks.data"></a> |
|
275 <h4>HexEditChunks.data</h4> |
|
276 <b>data</b>(<i>pos=0, maxSize=-1, highlighted=None</i>) |
|
277 |
|
278 <p> |
|
279 Public method to get data out of the chunks. |
|
280 </p> |
|
281 <dl> |
|
282 |
|
283 <dt><i>pos</i> (int)</dt> |
|
284 <dd> |
|
285 position to get bytes from |
|
286 </dd> |
|
287 <dt><i>maxSize</i> (int)</dt> |
|
288 <dd> |
|
289 maximum amount of bytes to get |
|
290 </dd> |
|
291 <dt><i>highlighted</i> (bytearray)</dt> |
|
292 <dd> |
|
293 reference to a byte array storing highlighting info |
|
294 </dd> |
|
295 </dl> |
|
296 <dl> |
|
297 <dt>Return:</dt> |
|
298 <dd> |
|
299 retrieved data |
|
300 </dd> |
|
301 </dl> |
|
302 <dl> |
|
303 <dt>Return Type:</dt> |
|
304 <dd> |
|
305 bytearray |
|
306 </dd> |
|
307 </dl> |
|
308 <a NAME="HexEditChunks.dataChanged" ID="HexEditChunks.dataChanged"></a> |
|
309 <h4>HexEditChunks.dataChanged</h4> |
|
310 <b>dataChanged</b>(<i>pos</i>) |
|
311 |
|
312 <p> |
|
313 Public method to test, if some data was changed. |
|
314 </p> |
|
315 <dl> |
|
316 |
|
317 <dt><i>pos</i> (int)</dt> |
|
318 <dd> |
|
319 byte position to check |
|
320 </dd> |
|
321 </dl> |
|
322 <dl> |
|
323 <dt>Return:</dt> |
|
324 <dd> |
|
325 flag indicating the changed state |
|
326 </dd> |
|
327 </dl> |
|
328 <dl> |
|
329 <dt>Return Type:</dt> |
|
330 <dd> |
|
331 bool |
|
332 </dd> |
|
333 </dl> |
|
334 <a NAME="HexEditChunks.indexOf" ID="HexEditChunks.indexOf"></a> |
|
335 <h4>HexEditChunks.indexOf</h4> |
|
336 <b>indexOf</b>(<i>byteArray, start</i>) |
|
337 |
|
338 <p> |
|
339 Public method to search the first occurrence of some data. |
|
340 </p> |
|
341 <dl> |
|
342 |
|
343 <dt><i>byteArray</i> (bytearray)</dt> |
|
344 <dd> |
|
345 data to search for |
|
346 </dd> |
|
347 <dt><i>start</i> (int)</dt> |
|
348 <dd> |
|
349 position to start the search at |
|
350 </dd> |
|
351 </dl> |
|
352 <dl> |
|
353 <dt>Return:</dt> |
|
354 <dd> |
|
355 position the data was found at or -1 if nothing could be found |
|
356 </dd> |
|
357 </dl> |
|
358 <dl> |
|
359 <dt>Return Type:</dt> |
|
360 <dd> |
|
361 int |
|
362 </dd> |
|
363 </dl> |
|
364 <a NAME="HexEditChunks.insert" ID="HexEditChunks.insert"></a> |
|
365 <h4>HexEditChunks.insert</h4> |
|
366 <b>insert</b>(<i>pos, data</i>) |
|
367 |
|
368 <p> |
|
369 Public method to insert a byte. |
|
370 </p> |
|
371 <dl> |
|
372 |
|
373 <dt><i>pos</i> (int)</dt> |
|
374 <dd> |
|
375 position to insert at |
|
376 </dd> |
|
377 <dt><i>data</i> (int (range 0 to 255))</dt> |
|
378 <dd> |
|
379 byte to insert |
|
380 </dd> |
|
381 </dl> |
|
382 <dl> |
|
383 <dt>Return:</dt> |
|
384 <dd> |
|
385 flag indicating success |
|
386 </dd> |
|
387 </dl> |
|
388 <dl> |
|
389 <dt>Return Type:</dt> |
|
390 <dd> |
|
391 bool |
|
392 </dd> |
|
393 </dl> |
|
394 <a NAME="HexEditChunks.lastIndexOf" ID="HexEditChunks.lastIndexOf"></a> |
|
395 <h4>HexEditChunks.lastIndexOf</h4> |
|
396 <b>lastIndexOf</b>(<i>byteArray, start</i>) |
|
397 |
|
398 <p> |
|
399 Public method to search the last occurrence of some data. |
|
400 </p> |
|
401 <dl> |
|
402 |
|
403 <dt><i>byteArray</i> (bytearray)</dt> |
|
404 <dd> |
|
405 data to search for |
|
406 </dd> |
|
407 <dt><i>start</i> (int)</dt> |
|
408 <dd> |
|
409 position to start the search at |
|
410 </dd> |
|
411 </dl> |
|
412 <dl> |
|
413 <dt>Return:</dt> |
|
414 <dd> |
|
415 position the data was found at or -1 if nothing could be found |
|
416 </dd> |
|
417 </dl> |
|
418 <dl> |
|
419 <dt>Return Type:</dt> |
|
420 <dd> |
|
421 int |
|
422 </dd> |
|
423 </dl> |
|
424 <a NAME="HexEditChunks.overwrite" ID="HexEditChunks.overwrite"></a> |
|
425 <h4>HexEditChunks.overwrite</h4> |
|
426 <b>overwrite</b>(<i>pos, data</i>) |
|
427 |
|
428 <p> |
|
429 Public method to overwrite a byte. |
|
430 </p> |
|
431 <dl> |
|
432 |
|
433 <dt><i>pos</i> (int)</dt> |
|
434 <dd> |
|
435 position to overwrite |
|
436 </dd> |
|
437 <dt><i>data</i> (int (range 0 to 255))</dt> |
|
438 <dd> |
|
439 byte to overwrite with |
|
440 </dd> |
|
441 </dl> |
|
442 <dl> |
|
443 <dt>Return:</dt> |
|
444 <dd> |
|
445 flag indicating success |
|
446 </dd> |
|
447 </dl> |
|
448 <dl> |
|
449 <dt>Return Type:</dt> |
|
450 <dd> |
|
451 bool |
|
452 </dd> |
|
453 </dl> |
|
454 <a NAME="HexEditChunks.pos" ID="HexEditChunks.pos"></a> |
|
455 <h4>HexEditChunks.pos</h4> |
|
456 <b>pos</b>(<i></i>) |
|
457 |
|
458 <p> |
|
459 Public method to get the current position. |
|
460 </p> |
|
461 <dl> |
|
462 <dt>Return:</dt> |
|
463 <dd> |
|
464 current position |
|
465 </dd> |
|
466 </dl> |
|
467 <dl> |
|
468 <dt>Return Type:</dt> |
|
469 <dd> |
|
470 int |
|
471 </dd> |
|
472 </dl> |
|
473 <a NAME="HexEditChunks.removeAt" ID="HexEditChunks.removeAt"></a> |
|
474 <h4>HexEditChunks.removeAt</h4> |
|
475 <b>removeAt</b>(<i>pos</i>) |
|
476 |
|
477 <p> |
|
478 Public method to remove a byte. |
|
479 </p> |
|
480 <dl> |
|
481 |
|
482 <dt><i>pos</i> (int)</dt> |
|
483 <dd> |
|
484 position to remove |
|
485 </dd> |
|
486 </dl> |
|
487 <dl> |
|
488 <dt>Return:</dt> |
|
489 <dd> |
|
490 flag indicating success |
|
491 </dd> |
|
492 </dl> |
|
493 <dl> |
|
494 <dt>Return Type:</dt> |
|
495 <dd> |
|
496 bool |
|
497 </dd> |
|
498 </dl> |
|
499 <a NAME="HexEditChunks.setDataChanged" ID="HexEditChunks.setDataChanged"></a> |
|
500 <h4>HexEditChunks.setDataChanged</h4> |
|
501 <b>setDataChanged</b>(<i>pos, dataChanged</i>) |
|
502 |
|
503 <p> |
|
504 Public method to set highlighting info. |
|
505 </p> |
|
506 <dl> |
|
507 |
|
508 <dt><i>pos</i> (int)</dt> |
|
509 <dd> |
|
510 position to set highlighting info for |
|
511 </dd> |
|
512 <dt><i>dataChanged</i> (bool)</dt> |
|
513 <dd> |
|
514 flag indicating changed data |
|
515 </dd> |
|
516 </dl> |
|
517 <a NAME="HexEditChunks.setIODevice" ID="HexEditChunks.setIODevice"></a> |
|
518 <h4>HexEditChunks.setIODevice</h4> |
|
519 <b>setIODevice</b>(<i>ioDevice</i>) |
|
520 |
|
521 <p> |
|
522 Public method to set an io device to read the binary data from. |
|
523 </p> |
|
524 <dl> |
|
525 |
|
526 <dt><i>ioDevice</i> (QIODevice)</dt> |
|
527 <dd> |
|
528 io device to get the data from |
|
529 </dd> |
|
530 </dl> |
|
531 <dl> |
|
532 <dt>Return:</dt> |
|
533 <dd> |
|
534 flag indicating successful operation |
|
535 </dd> |
|
536 </dl> |
|
537 <dl> |
|
538 <dt>Return Type:</dt> |
|
539 <dd> |
|
540 bool |
|
541 </dd> |
|
542 </dl> |
|
543 <a NAME="HexEditChunks.size" ID="HexEditChunks.size"></a> |
|
544 <h4>HexEditChunks.size</h4> |
|
545 <b>size</b>(<i></i>) |
|
546 |
|
547 <p> |
|
548 Public method to get the current data size. |
|
549 </p> |
|
550 <dl> |
|
551 <dt>Return:</dt> |
|
552 <dd> |
|
553 current data size |
|
554 </dd> |
|
555 </dl> |
|
556 <dl> |
|
557 <dt>Return Type:</dt> |
|
558 <dd> |
|
559 int |
|
560 </dd> |
|
561 </dl> |
|
562 <a NAME="HexEditChunks.write" ID="HexEditChunks.write"></a> |
|
563 <h4>HexEditChunks.write</h4> |
|
564 <b>write</b>(<i>ioDevice, pos=0, count=-1</i>) |
|
565 |
|
566 <p> |
|
567 Public method to write data to an io device. |
|
568 </p> |
|
569 <dl> |
|
570 |
|
571 <dt><i>ioDevice</i> (QIODevice)</dt> |
|
572 <dd> |
|
573 io device to write the data to |
|
574 </dd> |
|
575 <dt><i>pos</i> (int)</dt> |
|
576 <dd> |
|
577 position to write bytes from |
|
578 </dd> |
|
579 <dt><i>count</i> (int)</dt> |
|
580 <dd> |
|
581 amount of bytes to write |
|
582 </dd> |
|
583 </dl> |
|
584 <dl> |
|
585 <dt>Return:</dt> |
|
586 <dd> |
|
587 flag indicating success |
|
588 </dd> |
|
589 </dl> |
|
590 <dl> |
|
591 <dt>Return Type:</dt> |
|
592 <dd> |
|
593 bool |
|
594 </dd> |
|
595 </dl> |
|
596 <div align="right"><a href="#top">Up</a></div> |
|
597 <hr /> |
|
598 </body></html> |