[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Hex editor widget
From: "Friedrich W. H. Kossebau" <Friedrich.W.H () Kossebau ! de>
Date: 2003-06-22 10:48:50
[Download RAW message or body]
Am Samstag, 21. Juni 2003 17:37 schrieb Gerold J. Wucherpfennig:
> On Saturday 21 June 2003 00:45, Russell Miller wrote:
> > I would also be interested in such a widget - one of the apps that I have
> > written, kbview, would benefit greatly from such a widget. What I would
> > like to see (not a list of demands, but a list of wishes):
> >
<snip 1-6>
> 7. On demand loading - don't load the whole file at once.
> This is needed to work with huge files.
Also this had been in my mind when introducing the data abstraction layer (I
called KDataBuffer, anyone a better name?). As this is a special need it
should be implemented on a per-app base I think (although I wouldn't mind if
someone comes up with a general pattern class for this :)
But I still have no real clue how to support an on-demand loading in the API
of the layer. I thought of something like a call
prepareRange( Offset, Length )
where the actual working range (whatever this defines) is ensured to be loaded
and accessable in memory by call to data()/datum().
Does anyone know of a design pattern for this?
FWIW here is my actual draft:
class KDataBuffer
{
public:
KDataBuffer();
virtual ~KDataBuffer();
public:
int size() const;
public:
/** locates working range, returns false if failed */
virtual bool prepareRange( int Offset, int Length ) = 0;
/** expects pointer to memory, should be in prepared range */
virtual const char *data( int Offset, int Length ) = 0;
/** */
virtual const char datum( int Offset ) = 0;
/** is the buffer changeable ?*/
virtual bool isReadOnly() const = 0;
/** is the buffer resizeable ?*/
virtual bool isResizeable() const = 0;
/** inserts at Position */
virtual int insert( const char*, int Length, int Pos = 0 ) = 0;
/** removes beginning with position as much as possible, returns length of
removed */
virtual int remove( int Pos, int Length ) = 0;
/** replaces as much as possible, returns length of substituted */
virtual int replace( const char*, int Length, int Pos ) = 0;
/** searches beginning with byte at Pos, returns -1 if nothing found */
virtual int find( const char*, int Length, int Pos = 0 ) = 0;
/** searches backward beginning with byte at Pos, returns -1 if nothing
found */
virtual int rfind( const char*, int Length, int Pos = -1 ) = 0;
/* virtual int find( const QString &expr, bool cs, bool wo, bool forward =
true, int *index = 0 ); */
protected:
/** size of the data */
int Size;
};
Friedrich
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic