• 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
  • piecetable
piece.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 2008 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 KPIECETABLE_PIECE_H
24 #define KPIECETABLE_PIECE_H
25 
26 
27 // lib
28 #include <addressrange.h>
29 
30 namespace KPieceTable
31 {
32 
33 typedef Okteta::Size Size;
34 typedef Okteta::Address Address;
35 typedef Okteta::AddressRange AddressRange;
36 
37 
38 class Piece : public AddressRange
39 {
40  public:
41  enum {
42  OriginalStorage,
43  ChangeStorage
44  };
45 
46  public:
47  Piece( Address storageOffset, Size size, int storageId );
48  Piece( const AddressRange& storageRange, int storageId );
49  Piece();
50 
51  public:
52  int storageId() const;
53 
54  public:
55  void setStorageId( int storageId );
56  Piece splitAt( Address storageOffset );
57  Piece splitAtLocal( Address localStorageOffset );
58  Piece remove( const AddressRange& removeStorageRange );
59  Piece removeLocal( const AddressRange& localRemoveStorageRange );
60  Piece removeStartBeforeLocal( Address storageOffset );
61  Piece removeEndBehindLocal( Address storageOffset );
62  bool prepend( const Piece& other );
63  bool append( const Piece& other );
64 
65  public:
66  Piece subPiece( const AddressRange& local ) const;
67 
68  protected:
69  int mStorageId;
70 };
71 
72 
73 inline Piece::Piece( Address storageOffset, Size size, int storageId )
74  : AddressRange( AddressRange::fromWidth(storageOffset,size) ),
75  mStorageId( storageId )
76 {}
77 inline Piece::Piece( const AddressRange& storageRange, int storageId )
78  : AddressRange( storageRange ),
79  mStorageId( storageId )
80 {}
81 inline Piece::Piece() : mStorageId(OriginalStorage) {}
82 
83 inline int Piece::storageId() const { return mStorageId; }
84 
85 inline void Piece::setStorageId( int storageId ) { mStorageId = storageId; }
86 
87 inline Piece Piece::splitAt( Address storageOffset )
88 {
89  return Piece( AddressRange::splitAt(storageOffset), mStorageId );
90 }
91 inline Piece Piece::splitAtLocal( Address localStorageOffset )
92 {
93  return Piece( AddressRange::splitAtLocal(localStorageOffset), mStorageId );
94 }
95 inline Piece Piece::remove( const AddressRange& removeStorageRange )
96 {
97  return Piece( AddressRange::remove(removeStorageRange), mStorageId );
98 }
99 inline Piece Piece::removeLocal( const AddressRange& localRemoveStorageRange )
100 {
101  return Piece( AddressRange::removeLocal(localRemoveStorageRange), mStorageId );
102 }
103 inline Piece Piece::removeStartBeforeLocal( Address storageOffset )
104 {
105  const Address oldStart = start();
106  moveStartBy( storageOffset );
107  return Piece( AddressRange(oldStart,nextBeforeStart()), mStorageId );
108 }
109 inline Piece Piece::removeEndBehindLocal( Address storageOffset )
110 {
111  const Address oldEnd = end();
112  setEndByWidth( storageOffset+1 );
113  return Piece( AddressRange(nextBehindEnd(),oldEnd), mStorageId );
114 }
115 
116 inline Piece Piece::subPiece( const AddressRange& local ) const
117 {
118  return Piece( AddressRange::subRange(local), mStorageId );
119 }
120 
121 inline bool Piece::prepend( const Piece& other )
122 {
123  const bool result = ( mStorageId == other.mStorageId && AddressRange::prepend(other) );
124  return result;
125 }
126 inline bool Piece::append( const Piece& other )
127 {
128  const bool result = ( mStorageId == other.mStorageId && AddressRange::append(other) );
129  return result;
130 }
131 
132 }
133 
134 #endif
Okteta::Address
qint32 Address
Definition: address.h:34
KDE::NumberRange< Address, Size >::splitAt
NumberRange splitAt(Addressindex)
KPieceTable::Piece::subPiece
Piece subPiece(const AddressRange &local) const
Definition: piece.h:116
KDE::Range< N >::moveStartBy
void moveStartBy(ND)
moves the start by D.
Definition: range.h:78
KPieceTable::Size
Okteta::Size Size
Definition: piece.h:33
KPieceTable::Piece::splitAtLocal
Piece splitAtLocal(Address localStorageOffset)
Definition: piece.h:91
KDE::NumberRange::nextBehindEnd
N nextBehindEnd() const
Definition: numberrange.h:145
KPieceTable::Piece::Piece
Piece()
Definition: piece.h:81
KDE::NumberRange
describes a range of numbers which have a distance of 1 each
Definition: numberrange.h:37
KDE::Range< N >::start
N start() const
Definition: range.h:86
KPieceTable::Piece::OriginalStorage
Definition: piece.h:42
KPieceTable::Piece::removeLocal
Piece removeLocal(const AddressRange &localRemoveStorageRange)
Definition: piece.h:99
KDE::NumberRange< Address, Size >::removeLocal
NumberRange removeLocal(const NumberRange &removeRange)
KPieceTable::Piece::append
bool append(const Piece &other)
Definition: piece.h:126
addressrange.h
KDE::NumberRange< Address, Size >::subRange
NumberRange subRange(const NumberRange &localRange) const
KDE::Range< N >::end
N end() const
Definition: range.h:88
KPieceTable::Piece::ChangeStorage
Definition: piece.h:43
KPieceTable::Piece::removeStartBeforeLocal
Piece removeStartBeforeLocal(Address storageOffset)
Definition: piece.h:103
KPieceTable::AddressRange
Okteta::AddressRange AddressRange
Definition: piece.h:35
KPieceTable::Piece::mStorageId
int mStorageId
Definition: piece.h:69
KPieceTable::Address
Okteta::Address Address
Definition: piece.h:34
KDE::NumberRange::setEndByWidth
void setEndByWidth(S width)
sets the last index of the range's range to be width-1 behind the start If the range is invalid the b...
Definition: numberrange.h:152
KPieceTable::Piece
Definition: piece.h:38
KDE::NumberRange< Address, Size >::splitAtLocal
NumberRange splitAtLocal(Addressindex)
KPieceTable::Piece::prepend
bool prepend(const Piece &other)
Definition: piece.h:121
KPieceTable::Piece::splitAt
Piece splitAt(Address storageOffset)
Definition: piece.h:87
KPieceTable::Piece::storageId
int storageId() const
Definition: piece.h:83
KDE::NumberRange< Address, Size >::remove
NumberRange remove(const NumberRange &removeRange)
KDE::NumberRange< Address, Size >::prepend
bool prepend(const NumberRange &other)
Okteta::Size
qint32 Size
Definition: size.h:33
KPieceTable::Piece::setStorageId
void setStorageId(int storageId)
Definition: piece.h:85
KPieceTable::Piece::remove
Piece remove(const AddressRange &removeStorageRange)
Definition: piece.h:95
KPieceTable::Piece::removeEndBehindLocal
Piece removeEndBehindLocal(Address storageOffset)
Definition: piece.h:109
KDE::NumberRange::nextBeforeStart
N nextBeforeStart() const
Definition: numberrange.h:143
KDE::NumberRange< Address, Size >::append
bool append(const NumberRange &other)
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:08 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