• 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
revertablepiecetable.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_REVERTABLEPIECETABLE_H
24 #define KPIECETABLE_REVERTABLEPIECETABLE_H
25 
26 // lib
27 #include "piecetablechangehistory.h"
28 #include "piecetable.h"
29 
30 
31 namespace KPieceTable
32 {
33 
34 class RevertablePieceTable
35 {
36  public:
37  RevertablePieceTable();
38 
39  public:
40  void init( Size size );
41 
42  public: // operations return true if it results in a new change and is not merged to the current
43  bool insert( Address pos, Size length, Size* storageSize );
44  bool remove( const AddressRange& removeRange );
45 // bool remove( Address start, Address end );
46  bool replace( const AddressRange& removeRange, Size insertLength, Size* storageSize );
47  bool replace( Address removeStart, Size removeLength, Size insertLength, Size* storageSize );
48  bool replaceOne( Address dataOffset, Size* storageSize );
49  bool swap( Address firstStart, const AddressRange& secondRange );
50  bool swap( Address firstStart, Address secondStart, Size secondLength );
51 // int fill( const char FillChar, unsigned int Pos = 0, int Length = -1 ); TODO: filter change, calculated
52 
53  public:
58  void openGroupedChange( const QString& description ); // TODO: hand over description? user change id?
63  void closeGroupedChange( const QString& description );
64 
65  public:
69  void finishChange();
77  bool revertBeforeChange( int changeId,
78  AddressRangeList* changedRanges, ArrayChangeMetricsList* changeList );
79  //TODO: hide should be a flag with or just an own function unsetBase();
83  void setBeforeCurrentChangeAsBase( bool hide );
84 
85  public:
86  bool getStorageData( int* storageId, Address* storageOffset, Address dataOffset ) const;
87  Size size() const;
88  void getChangeData( ArrayChangeMetrics* metrics, Address* storageOffset, int versionIndex ) const;
89 
90  public:
91  int changesCount() const;
92  int appliedChangesCount() const;
93  QString changeDescription( int change ) const;
94  QString headChangeDescription() const;
95  bool isAtBase() const;
96 
97  protected:
98  PieceTable mPieceTable;
99  PieceTableChangeHistory mChangeHistory;
100 };
101 
102 
103 inline bool RevertablePieceTable::getStorageData( int* storageId, Address* storageOffset, Address dataOffset ) const
104 {
105  return mPieceTable.getStorageData( storageId, storageOffset, dataOffset );
106 }
107 
108 inline void RevertablePieceTable::setBeforeCurrentChangeAsBase( bool hide )
109 {
110  mChangeHistory.setBeforeCurrentChangeAsBase( hide );
111 }
112 
113 inline Size RevertablePieceTable::size() const { return mPieceTable.size(); }
114 inline int RevertablePieceTable::changesCount() const { return mChangeHistory.count(); }
115 inline int RevertablePieceTable::appliedChangesCount() const { return mChangeHistory.appliedChangesCount(); }
116 inline bool RevertablePieceTable::isAtBase() const { return mChangeHistory.isAtBase(); }
117 inline QString RevertablePieceTable::changeDescription( int change ) const
118 {
119  return mChangeHistory.changeDescription( change );
120 }
121 inline QString RevertablePieceTable::headChangeDescription() const
122 {
123  return mChangeHistory.headChangeDescription();
124 }
125 
126 // inline bool RevertablePieceTable::remove( Address start, Size length )
127 // {
128 // return remove( AddressRange::fromWidth(start,length) );
129 // }
130 inline bool RevertablePieceTable::replace( Address removeStart, Size removeLength, Size insertLength, Size* storageSize )
131 {
132  return replace( AddressRange::fromWidth(removeStart,removeLength), insertLength, storageSize );
133 }
134 inline bool RevertablePieceTable::swap( Address firstStart, Address secondStart, Size secondLength )
135 {
136  return swap( firstStart, AddressRange::fromWidth(secondStart,secondLength) );
137 }
138 
139 inline void RevertablePieceTable::openGroupedChange( const QString& description )
140 {
141  mChangeHistory.openGroupedChange(description);
142 }
143 
144 inline void RevertablePieceTable::closeGroupedChange( const QString& description )
145 {
146  mChangeHistory.closeGroupedChange(description);
147 }
148 inline void RevertablePieceTable::finishChange() { mChangeHistory.finishChange(); }
149 
150 inline bool RevertablePieceTable::revertBeforeChange( int changeId,
151  AddressRangeList* changedRanges,
152  ArrayChangeMetricsList* changeList )
153 {
154  return mChangeHistory.revertBeforeChange( &mPieceTable, changeId, changedRanges, changeList );
155 }
156 
157 
158 }
159 
160 #endif
KPieceTable::RevertablePieceTable::init
void init(Size size)
Definition: revertablepiecetable.cpp:39
KPieceTable::PieceTableChangeHistory::changeDescription
QString changeDescription(int changeId) const
Definition: piecetablechangehistory.h:126
KPieceTable::RevertablePieceTable::headChangeDescription
QString headChangeDescription() const
Definition: revertablepiecetable.h:121
KPieceTable::RevertablePieceTable::changeDescription
QString changeDescription(int change) const
Definition: revertablepiecetable.h:117
KPieceTable::RevertablePieceTable::size
Size size() const
Definition: revertablepiecetable.h:113
KPieceTable::RevertablePieceTable::mPieceTable
PieceTable mPieceTable
Definition: revertablepiecetable.h:98
KPieceTable::Size
Okteta::Size Size
Definition: piece.h:33
KPieceTable::RevertablePieceTable
Definition: revertablepiecetable.h:34
KDE::NumberRange< Address, Size >
KPieceTable::PieceTableChangeHistory::appliedChangesCount
int appliedChangesCount() const
Definition: piecetablechangehistory.h:118
KPieceTable::PieceTableChangeHistory::openGroupedChange
void openGroupedChange(const QString &description)
Definition: piecetablechangehistory.cpp:63
KPieceTable::PieceTableChangeHistory::finishChange
void finishChange()
closes the current change, so any following operation will not be tried to merge
Definition: piecetablechangehistory.cpp:81
KPieceTable::RevertablePieceTable::getChangeData
void getChangeData(ArrayChangeMetrics *metrics, Address *storageOffset, int versionIndex) const
Definition: revertablepiecetable.cpp:45
KPieceTable::RevertablePieceTable::replace
bool replace(const AddressRange &removeRange, Size insertLength, Size *storageSize)
Definition: revertablepiecetable.cpp:72
KPieceTable::RevertablePieceTable::RevertablePieceTable
RevertablePieceTable()
Definition: revertablepiecetable.cpp:37
KPieceTable::RevertablePieceTable::finishChange
void finishChange()
closes the current change, so any following operation will not be tried to merge
Definition: revertablepiecetable.h:148
KPieceTable::RevertablePieceTable::appliedChangesCount
int appliedChangesCount() const
Definition: revertablepiecetable.h:115
KPieceTable::PieceTable::getStorageData
bool getStorageData(int *storageId, Address *storageOffset, Address dataOffset) const
Definition: piecetable.cpp:47
KPieceTable::PieceTable::size
Size size() const
Definition: piecetable.h:64
KPieceTable::PieceTableChangeHistory::revertBeforeChange
bool revertBeforeChange(PieceTable *pieceTable, int changeId, AddressRangeList *changedRanges, ArrayChangeMetricsList *changeList)
Definition: piecetablechangehistory.cpp:133
KPieceTable::RevertablePieceTable::swap
bool swap(Address firstStart, const AddressRange &secondRange)
Definition: revertablepiecetable.cpp:85
KPieceTable::PieceTableChangeHistory::headChangeDescription
QString headChangeDescription() const
Definition: piecetablechangehistory.h:119
KPieceTable::RevertablePieceTable::setBeforeCurrentChangeAsBase
void setBeforeCurrentChangeAsBase(bool hide)
Definition: revertablepiecetable.h:108
KPieceTable::RevertablePieceTable::isAtBase
bool isAtBase() const
Definition: revertablepiecetable.h:116
KPieceTable::RevertablePieceTable::replaceOne
bool replaceOne(Address dataOffset, Size *storageSize)
Definition: revertablepiecetable.cpp:95
KPieceTable::RevertablePieceTable::getStorageData
bool getStorageData(int *storageId, Address *storageOffset, Address dataOffset) const
Definition: revertablepiecetable.h:103
KDE::NumberRange< Address, Size >::fromWidth
static NumberRange fromWidth(AddressstartIndex, Sizewidth)
constructs a range by width
piecetablechangehistory.h
KPieceTable::RevertablePieceTable::openGroupedChange
void openGroupedChange(const QString &description)
opens a group of changes
Definition: revertablepiecetable.h:139
Okteta::ArrayChangeMetricsList
Definition: arraychangemetricslist.h:36
KPieceTable::PieceTableChangeHistory::isAtBase
bool isAtBase() const
Definition: piecetablechangehistory.h:120
KPieceTable::RevertablePieceTable::mChangeHistory
PieceTableChangeHistory mChangeHistory
Definition: revertablepiecetable.h:99
KPieceTable::PieceTableChangeHistory::closeGroupedChange
void closeGroupedChange(const QString &description)
Definition: piecetablechangehistory.cpp:71
KPieceTable::PieceTableChangeHistory::setBeforeCurrentChangeAsBase
void setBeforeCurrentChangeAsBase(bool hide)
Definition: piecetablechangehistory.cpp:57
KPieceTable::Address
Okteta::Address Address
Definition: piece.h:34
KPieceTable::PieceTableChangeHistory
Definition: piecetablechangehistory.h:46
KPieceTable::PieceTable
Definition: piecetable.h:35
KPieceTable::PieceTableChangeHistory::count
int count() const
Definition: piecetablechangehistory.h:117
KPieceTable::RevertablePieceTable::changesCount
int changesCount() const
Definition: revertablepiecetable.h:114
Okteta::ArrayChangeMetrics
Definition: arraychangemetrics.h:38
KPieceTable::RevertablePieceTable::closeGroupedChange
void closeGroupedChange(const QString &description)
closes the current group and sets the parent group as current if there is one
Definition: revertablepiecetable.h:144
piecetable.h
KPieceTable::RevertablePieceTable::revertBeforeChange
bool revertBeforeChange(int changeId, AddressRangeList *changedRanges, ArrayChangeMetricsList *changeList)
closes the current change, so any following operation will not be tried to merge currently it also cl...
Definition: revertablepiecetable.h:150
Okteta::AddressRangeList
Definition: addressrangelist.h:38
KPieceTable::RevertablePieceTable::insert
bool insert(Address pos, Size length, Size *storageSize)
Definition: revertablepiecetable.cpp:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:09 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