• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • core
abstractbytearraymodel.h
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Core library, made within the KDE community.
3 
4  Copyright 2003,2008-2009 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #ifndef OKTETA_ABSTRACTBYTEARRAYMODEL_H
24 #define OKTETA_ABSTRACTBYTEARRAYMODEL_H
25 
26 // lib
27 #include "oktetacore_export.h"
28 #include "addressrange.h"
29 #include "size.h"
30 #include "byte.h"
31 // Qt
32 #include <QtCore/QObject>
33 #include <QtCore/QByteArray>
34 
35 
36 namespace Okteta
37 {
38 
39 class ArrayChangeMetricsList;
40 class CharCodec;
41 
42 
79 class OKTETACORE_EXPORT AbstractByteArrayModel : public QObject
80 {
81  friend class KAbstractByteArrayModelIterator;
82 
83  Q_OBJECT
84 
85  protected:
86  explicit AbstractByteArrayModel( QObject* parent = 0 );
87  public:
88  virtual ~AbstractByteArrayModel();
89 
90 
91  public: // data access API
99  //virtual bool prepareRange( const Section &Range ) const = 0;
101  //bool prepareRange( int Offset, int Length ) const;
102 
104  //virtual KDataBufferIterator *iterator() const = 0;
111  //virtual const char *dataSet( const Section &Section ) const = 0;
113  //const char *dataSet( int Offset, int Length ) const;
114 
119  virtual Byte byte( Address offset ) const = 0;
120 
124  virtual Size size() const = 0;
125 
126 
127  public: // state read API
132  virtual bool isReadOnly() const;
136  virtual bool isModified() const = 0;
137 
138 // TODO: for data outside the model using char* and int as well as QByteArray should always work, no?
139  public: // modification API
149  virtual Size insert( Address offset, const Byte* insertData, int insertLength );
150  Size insert( Address offset, const QByteArray& insertData );
151 
156  virtual Size remove( const AddressRange& removeRange );
158  Size remove( Address offset, Size removeLength );
159 
166  virtual Size replace( const AddressRange& removeRange, const Byte* insertData, int insertLength ) = 0;
168  Size replace( const AddressRange& removeRange, const QByteArray& insertData );
170  Size replace( Address offset, Size removeLength,
171  const Byte* insertData, Size insertLength );
172 
173  // todo use parameters grouped differrently?
180  virtual bool swap( Address firstStart, const AddressRange& secondRange ) = 0;
181 
189  virtual Size fill( Byte fillByte, Address offset = 0, Size fillLength = -1 ) = 0;
190  Size fill( Byte fillChar, const AddressRange& fillRange );
191 
197  virtual void setByte( Address offset, Byte byte ) = 0;
198 
202  virtual void setModified( bool modified ) = 0;
203 
208  virtual void setReadOnly( bool isReadOnly );
209 
210 
211  public: // service functions
218  virtual Size copyTo( Byte* dest, const AddressRange& copyRange ) const;
220  Size copyTo( Byte* dest, Address offset, Size copyLength ) const;
221 
222 
223  public: // finding API
230  virtual Address indexOf( const Byte* pattern, int patternLength, Address fromOffset = 0, Address toOffset = -1 ) const;
231  Address indexOf( const QByteArray& pattern, Address fromOffset = 0, Address toOffset = -1 ) const;
232  Address indexOfCaseInsensitive( const CharCodec* charCodec, const QByteArray& pattern, Address fromOffset = 0, Address toOffset = -1 ) const;
233 
242 // virtual int indexOf( const char*KeyData, int Length, const Section &Section ) const { return -1; }//= 0;
249  virtual Address lastIndexOf( const Byte* pattern, int patternLength, Address fromOffset = -1, Address toOffset = 0 ) const;
250  Address lastIndexOf( const QByteArray& pattern, Address fromOffset = -1, Address toOffset = 0 ) const;
251  Address lastIndexOfCaseInsensitive( const CharCodec* charCodec, const QByteArray& pattern, Address fromOffset = -1, Address toOffset = 0 ) const;
252 
253 /* virtual int find( const QString &expr, bool cs, bool wo, bool forward = true, int *index = 0 ); */
254 
255  Q_SIGNALS:
256  // TODO: how to deal replacing with fixed size of buffer?
257  void contentsChanged( const Okteta::ArrayChangeMetricsList& changeList );
258 
259  void readOnlyChanged( bool isReadOnly );
260  void modifiedChanged( bool isModified );
261 
262  // TODO: how to handle a typedef with signals
263  void searchedBytes( Okteta::Size bytes ) const;
264 };
265 
266 // TODO: find why static_cast fails
267 inline Size AbstractByteArrayModel::insert( Address offset, const QByteArray& insertData )
268 { return insert( offset, reinterpret_cast<const Byte*>(insertData.constData()), insertData.size() ); }
269 
270 inline Size AbstractByteArrayModel::remove( Address offset, Size removeLength )
271 { return remove( AddressRange::fromWidth(offset,removeLength) ); }
272 
273 inline Size AbstractByteArrayModel::replace( const AddressRange& removeRange, const QByteArray& insertData )
274 { return replace( removeRange, reinterpret_cast<const Byte*>(insertData.constData()), insertData.size() );}
275 
276 inline Size AbstractByteArrayModel::replace( Address offset, Size removeLength,
277  const Byte* insertData, Size insertLength )
278 { return replace( AddressRange::fromWidth(offset,removeLength), insertData, insertLength ); }
279 
280 inline Size AbstractByteArrayModel::fill( const Byte fillChar, const AddressRange& fillRange )
281 { return fill( fillChar, fillRange.start(), fillRange.width() ); }
282 
283 inline Size AbstractByteArrayModel::copyTo( Byte* dest, Address offset, Size copyLength ) const
284 { return copyTo( dest, AddressRange::fromWidth(offset,copyLength) ); }
285 
286 inline Address AbstractByteArrayModel::indexOf( const QByteArray& pattern, Address fromOffset, Address toOffset ) const
287 { return indexOf( reinterpret_cast<const Byte*>(pattern.constData()), pattern.size(), fromOffset, toOffset ); }
288 
289 inline Address AbstractByteArrayModel::lastIndexOf( const QByteArray& pattern, Address fromOffset, Address toOffset ) const
290 { return lastIndexOf( reinterpret_cast<const Byte*>(pattern.constData()), pattern.size(), fromOffset, toOffset ); }
291 
292 }
293 
294 #endif
Okteta::AbstractByteArrayModel::replace
virtual Size replace(const AddressRange &removeRange, const Byte *insertData, int insertLength)=0
replaces as much as possible
Okteta::Address
qint32 Address
Definition: address.h:34
Okteta::AbstractByteArrayModel
could it be useful to hide the data access behind an iterator? * class KDataBufferIterator { public: ...
Definition: abstractbytearraymodel.h:79
Okteta::AbstractByteArrayModel::fill
virtual Size fill(Byte fillByte, Address offset=0, Size fillLength=-1)=0
fills the buffer with the FillChar.
Okteta::AbstractByteArrayModel::insert
virtual Size insert(Address offset, const Byte *insertData, int insertLength)
inserts bytes copied from the given source at Position.
Definition: abstractbytearraymodel.cpp:47
KDE::NumberRange< Address, Size >
KDE::Range::start
T start() const
Definition: range.h:86
Okteta::Byte
unsigned char Byte
Definition: byte.h:29
QObject
OKTETACORE_EXPORT
#define OKTETACORE_EXPORT
Definition: oktetacore_export.h:36
KDE::NumberRange::width
S width() const
Definition: numberrange.h:141
KPieceTable::ArrayChangeMetricsList
Okteta::ArrayChangeMetricsList ArrayChangeMetricsList
Definition: grouppiecetablechange.h:42
Okteta::AbstractByteArrayModel::copyTo
virtual Size copyTo(Byte *dest, const AddressRange &copyRange) const
copies the data of the section into a given array Dest.
Definition: abstractbytearraymodel.cpp:60
addressrange.h
Okteta::AbstractByteArrayModel::lastIndexOf
virtual Address lastIndexOf(const Byte *pattern, int patternLength, Address fromOffset=-1, Address toOffset=0) const
searches for a given data string The section limits the data within which the key has to be found If ...
Definition: abstractbytearraymodel.cpp:104
Okteta::CharCodec
Definition: charcodec.h:42
KDE::NumberRange< Address, Size >::fromWidth
static NumberRange fromWidth(AddressstartIndex, Sizewidth)
constructs a range by width
byte.h
Okteta::ArrayChangeMetricsList
Definition: arraychangemetricslist.h:36
size.h
Okteta::Size
qint32 Size
Definition: size.h:33
oktetacore_export.h
Okteta::AbstractByteArrayModel::indexOf
virtual Address indexOf(const Byte *pattern, int patternLength, Address fromOffset=0, Address toOffset=-1) const
searches beginning with byte at Pos.
Definition: abstractbytearraymodel.cpp:73
Okteta::AbstractByteArrayModel::remove
virtual Size remove(const AddressRange &removeRange)
removes beginning with position as much as possible
Definition: abstractbytearraymodel.cpp:53
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal