summaryrefslogtreecommitdiffstats
path: root/khexedit/lib/kwrappingrobuffer.h
blob: 97ae33c893ac6a0172060651cbce439ed688caa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/***************************************************************************
                          kwrappingrobuffer.h  -  description
                             -------------------
    begin                : Mit Mai 14 2003
    copyright            : (C) 2003 by Friedrich W. H. Kossebau
    email                : Friedrich.W.H@Kossebau.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License version 2 as published by the Free Software Foundation.       *
 *                                                                         *
 ***************************************************************************/


#ifndef KHE_KWRAPPINGROBUFFER_H
#define KHE_KWRAPPINGROBUFFER_H

#include "kreadonlybuffer.h"

namespace KHE
{

/**
  *@author Friedrich W. H. Kossebau
  */

class KWrappingROBuffer : public KReadOnlyBuffer
{
  public:
    static const int NothingFound = -1;

  public:
    KWrappingROBuffer();
    KWrappingROBuffer( const char* D, int L );
    virtual ~KWrappingROBuffer();


  public: // KDataBuffer API
    virtual bool prepareRange( KSection Range ) const;
    virtual const char *dataSet( KSection S ) const;
    virtual char datum( unsigned int Offset ) const;
    virtual int size() const;
    virtual bool isModified() const;

    virtual int insert( int Pos, const char*, int Length );
    virtual int remove( KSection S );
    virtual unsigned int tqreplace( KSection S, const char*, unsigned int Length );
    virtual int fill( const char FillChar, int, int );
    virtual void setDatum( unsigned int Offset, const char Char );

    virtual void setModified( bool M );

    virtual int tqfind( const char*KeyData, int Length, KSection Section ) const;
    virtual int rfind( const char*, int Length, int Pos = -1 ) const;


  public: //
    void set( const char* D, int L );

  protected:
    const char* Data;
    int Size;
    bool Modified;
};

inline int KWrappingROBuffer::size() const { return Size; }

inline bool KWrappingROBuffer::isModified() const { return Modified; }

inline bool KWrappingROBuffer::prepareRange( KSection ) const     { return true; }
inline char KWrappingROBuffer::datum( unsigned int Offset ) const { return Data[Offset]; }

inline int KWrappingROBuffer::insert( int, const char*, int )        { return 0; }
inline int KWrappingROBuffer::remove( KSection )                     { return 0; }
inline unsigned int KWrappingROBuffer::tqreplace( KSection, const char*, unsigned int )  { return 0; }
inline int KWrappingROBuffer::fill( const char , int, int )          { return 0; }
inline void KWrappingROBuffer::setDatum( unsigned int, const char )  {}

inline void KWrappingROBuffer::setModified( bool M )  { Modified = M; }
}

#endif