src/eric7/Documentation/Source/eric7.HexEdit.HexEditChunks.html

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

eric ide

mercurial