okteta
KHECore::KAbstractByteArrayModel Class Reference
#include <kabstractbytearraymodel.h>

Detailed Description
could it be useful to hide the data access behind an iterator? * class KDataBufferIterator { public: bool hasNext(); char next(); protected:protected: char * int Length; }
bool KDataBufferIterator::hasNext() { } this function should be simple as possible char KDataBufferIterator::next() { if next span is empty if( ) return *NextChar++; } base class for all Data buffers that are used to display TODO: think about a way to inform KHexEdit that there has been a change in the buffer outside. what kind of changes are possible?
Operations on the data:
Finding: is implemented stateless. FindNext has to be done by perhaps a FindManager Replacing: not available. Implement within a ReplaceManager
Definition at line 82 of file kabstractbytearraymodel.h.
Signals | |
| void | contentsChanged (const KHE::ArrayChangeMetricsList &changeList) |
| void | modificationChanged (bool isModified) |
| void | readOnlyChanged (bool isReadOnly) |
| void | searchedBytes (int bytes) const |
Public Member Functions | |
| int | copyTo (char *dest, int offset, unsigned int copyLength) const |
| virtual int | copyTo (char *dest, const KSection ©Section) const |
| virtual char | datum (unsigned int offset) const =0 |
| int | fill (const char fillChar, const KSection &fillSection) |
| virtual int | fill (const char fillChar, unsigned int offset=0, int fillLength=-1)=0 |
| int | indexOf (const QByteArray &pattern, int fromOffset=0) const |
| virtual int | indexOf (const char *pattern, int patternLength, int fromOffset=0) const |
| int | insert (int offset, const QByteArray &insertData) |
| virtual int | insert (int offset, const char *insertData, int insertLength) |
| virtual bool | isModified () const =0 |
| virtual bool | isReadOnly () const |
| int | lastIndexOf (const QByteArray &pattern, int fromOffset=-1) const |
| virtual int | lastIndexOf (const char *pattern, int patternLength, int fromOffset=-1) const |
| int | remove (int offset, int removeLength) |
| virtual int | remove (const KSection &removeSection) |
| unsigned int | replace (unsigned int offset, unsigned int removeLength, const char *insertData, unsigned int insertLength) |
| unsigned int | replace (const KSection &removeSection, const QByteArray &insertData) |
| virtual unsigned int | replace (const KSection &removeSection, const char *insertData, unsigned int insertLength)=0 |
| virtual void | setDatum (unsigned int offset, const char value)=0 |
| virtual void | setModified (bool modified)=0 |
| virtual void | setReadOnly (bool isReadOnly) |
| virtual int | size () const =0 |
| virtual bool | swap (int firstStart, const KSection &secondSection)=0 |
| virtual | ~KAbstractByteArrayModel () |
Protected Member Functions | |
| KAbstractByteArrayModel () | |
Constructor & Destructor Documentation
| KHECore::KAbstractByteArrayModel::KAbstractByteArrayModel | ( | ) | [protected] |
Definition at line 31 of file kabstractbytearraymodel.cpp.
| KHECore::KAbstractByteArrayModel::~KAbstractByteArrayModel | ( | ) | [virtual] |
Definition at line 132 of file kabstractbytearraymodel.cpp.
Member Function Documentation
| void KHECore::KAbstractByteArrayModel::contentsChanged | ( | const KHE::ArrayChangeMetricsList & | changeList | ) | [signal] |
| int KHECore::KAbstractByteArrayModel::copyTo | ( | char * | dest, | |
| const KSection & | copySection | |||
| ) | const [virtual] |
copies the data of the section into a given array Dest.
If the section extends the buffers range the section is limited to the buffer's end. If the section is invalid the behaviour is undefined.
- Parameters:
-
dest pointer to a char array large enough to hold the copied section copySection
- Returns:
- number of copied bytes
Definition at line 53 of file kabstractbytearraymodel.cpp.
| virtual char KHECore::KAbstractByteArrayModel::datum | ( | unsigned int | offset | ) | const [pure virtual] |
locates working range The idea behind is to tell buffer which range will be requested in the following time, so that e.g.
the corresponding pages will be loaded in advance TODO: do we really need this? Where will this lead to real enhancements?
- Parameters:
-
Range
- Returns:
trueif successfully,falseotherwise convenience function, same as above creates an iterator to expects pointer to memory, should be in prepared range it is only expected to be a valid pointer until any further call to this or any modifying function
- Parameters:
-
Section
- Returns:
- pointer to convenience function, same as above requests a single byte if the offset is not valid the behaviout is undefined
- Parameters:
-
offset offset of the datum requested
Implemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
| int KHECore::KAbstractByteArrayModel::fill | ( | const char | fillChar, | |
| const KSection & | fillSection | |||
| ) | [inline] |
Definition at line 278 of file kabstractbytearraymodel.h.
| virtual int KHECore::KAbstractByteArrayModel::fill | ( | const char | fillChar, | |
| unsigned int | offset = 0, |
|||
| int | fillLength = -1 | |||
| ) | [pure virtual] |
fills the buffer with the FillChar.
If the buffer is to small it will be extended as much as possible.
- Parameters:
-
fillChar char to use offset position where the filling starts fillLength number of chars to fill. If Length is -1, the buffer is filled till the end.
- Returns:
- number of filled characters
Implemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
| int KHECore::KAbstractByteArrayModel::indexOf | ( | const QByteArray & | pattern, | |
| int | fromOffset = 0 | |||
| ) | const [inline] |
Definition at line 284 of file kabstractbytearraymodel.h.
| int KHECore::KAbstractByteArrayModel::indexOf | ( | const char * | pattern, | |
| int | patternLength, | |||
| int | fromOffset = 0 | |||
| ) | const [virtual] |
searches beginning with byte at Pos.
- Parameters:
-
pattern patternLength length of search string fromOffset the position to start the search
- Returns:
- index of the first or -1
Reimplemented in KHECore::KByteArrayModel.
Definition at line 65 of file kabstractbytearraymodel.cpp.
| int KHECore::KAbstractByteArrayModel::insert | ( | int | offset, | |
| const QByteArray & | insertData | |||
| ) | [inline] |
Definition at line 265 of file kabstractbytearraymodel.h.
| int KHECore::KAbstractByteArrayModel::insert | ( | int | offset, | |
| const char * | insertData, | |||
| int | insertLength | |||
| ) | [virtual] |
inserts bytes copied from the given source at Position.
The original data beginnung at the position is moved with the buffer enlarged as needed If the buffer is readOnly this is a noop and returns 0.
- Parameters:
-
offset insertData data source insertLength number of bytes to copy
- Returns:
- length of inserted data
Reimplemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
Definition at line 40 of file kabstractbytearraymodel.cpp.
| virtual bool KHECore::KAbstractByteArrayModel::isModified | ( | ) | const [pure virtual] |
- Returns:
trueif the buffer has been modified,falseotherwise
Implemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
| bool KHECore::KAbstractByteArrayModel::isReadOnly | ( | ) | const [virtual] |
Default returns true.
- Returns:
trueif the buffer can only be read,falseif writing is allowed
Reimplemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
Definition at line 33 of file kabstractbytearraymodel.cpp.
| int KHECore::KAbstractByteArrayModel::lastIndexOf | ( | const QByteArray & | pattern, | |
| int | fromOffset = -1 | |||
| ) | const [inline] |
Definition at line 287 of file kabstractbytearraymodel.h.
| int KHECore::KAbstractByteArrayModel::lastIndexOf | ( | const char * | pattern, | |
| int | patternLength, | |||
| int | fromOffset = -1 | |||
| ) | const [virtual] |
searches for a given data string The section limits the data within which the key has to be found If the end of the section is lower then the start the search continues at the start???
- Parameters:
-
@param Length length of search string Section section within the keydata is to be found
- Returns:
- index of the first occurrence or -1 searches backward beginning with byte at Pos.
- Parameters:
-
@param patternLength length of search string fromOffset the position to start the search. If -1 the search starts at the end.
- Returns:
- index of the first or -1
Reimplemented in KHECore::KByteArrayModel.
Definition at line 96 of file kabstractbytearraymodel.cpp.
| void KHECore::KAbstractByteArrayModel::modificationChanged | ( | bool | isModified | ) | [signal] |
| void KHECore::KAbstractByteArrayModel::readOnlyChanged | ( | bool | isReadOnly | ) | [signal] |
removes beginning with position as much as possible
- Parameters:
-
removeSection
- Returns:
- length of removed data
Reimplemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
Definition at line 46 of file kabstractbytearraymodel.cpp.
| unsigned int KHECore::KAbstractByteArrayModel::replace | ( | const KSection & | removeSection, | |
| const QByteArray & | insertData | |||
| ) | [inline] |
| virtual unsigned int KHECore::KAbstractByteArrayModel::replace | ( | const KSection & | removeSection, | |
| const char * | insertData, | |||
| unsigned int | insertLength | |||
| ) | [pure virtual] |
replaces as much as possible
- Parameters:
-
removeSection insertData insertLength
- Returns:
- length of inserted data
Implemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
| void KHECore::KAbstractByteArrayModel::searchedBytes | ( | int | bytes | ) | const [signal] |
| virtual void KHECore::KAbstractByteArrayModel::setDatum | ( | unsigned int | offset, | |
| const char | value | |||
| ) | [pure virtual] |
sets a single byte if the offset is not valid the behaviour is undefined
- Parameters:
-
offset offset of the datum requested value new byte value
Implemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
| virtual void KHECore::KAbstractByteArrayModel::setModified | ( | bool | modified | ) | [pure virtual] |
sets the modified flag for the buffer
- Parameters:
-
modified
Implemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
| void KHECore::KAbstractByteArrayModel::setReadOnly | ( | bool | isReadOnly | ) | [virtual] |
sets the readonly flag for the byte array if this is possible.
Default implementation does not do anything.
- Parameters:
-
isReadOnly new state
Reimplemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
Definition at line 35 of file kabstractbytearraymodel.cpp.
| virtual int KHECore::KAbstractByteArrayModel::size | ( | ) | const [pure virtual] |
- Returns:
- the size of the data
Implemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
| virtual bool KHECore::KAbstractByteArrayModel::swap | ( | int | firstStart, | |
| const KSection & | secondSection | |||
| ) | [pure virtual] |
moves the second section before the start of the first which is the same as moving the first behind the second.
- Parameters:
-
firstStart position of the data where the section should be moved behind secondSection data section to be moved
- Returns:
- if operation was successful, otherwise
Implemented in KHECore::KByteArrayModel, KHECore::KFileByteArrayModel, KHECore::KFixedSizeByteArrayModel, and KHECore::KPieceTableByteArrayModel.
The documentation for this class was generated from the following files:
KDE 4.2 API Reference