edbee - Qt Editor Library
Public Member Functions | Protected Member Functions | List of all members
edbee::AbstractRangedChange Class Referenceabstract

This is an abstract class for ranged changes This are changes (text changes and line changes) that span a range in an array. These ranges share a common alogrithm for performing merges, detecting overlaps etc. More...

#include <abstractrangedchange.h>

+ Inheritance diagram for edbee::AbstractRangedChange:
+ Collaboration diagram for edbee::AbstractRangedChange:

Public Member Functions

virtual ~AbstractRangedChange ()
 default destructor is empty More...
 
virtual int offset () const =0
 this method should return the offset of the change More...
 
virtual void setOffset (int value)=0
 this method should set the offset More...
 
void addOffset (int amount)
 Adds the given amount to the offset. More...
 
virtual void setDocLength (int value)=0
 this method should set the old length More...
 
virtual int docLength () const =0
 this method should return the length in the document More...
 
virtual int storedLength () const =0
 this method should return the length of this item in memory More...
 
bool isOverlappedBy (AbstractRangedChange *secondChange)
 This method checks if this textchange is overlapped by the second text change overlapping is an exclusive overlap, which means the changes are really on top of eachother to test if the changes are touching use isTouchedBy. More...
 
bool isTouchedBy (AbstractRangedChange *secondChange)
 Touched ranges are ranges that are next to eachother Touching means the end offset of one range is the start offset of the other range. More...
 
- Public Member Functions inherited from edbee::Change
virtual ~Change ()
 a virtual empty destructor More...
 
virtual void execute (TextDocument *document)=0
 This method should execute the command. More...
 
virtual void revert (TextDocument *)
 this method reverts the given operation More...
 
virtual bool giveAndMerge (TextDocument *document, Change *textChange)
 Gives the change and merges it if possible. This method should return false if the change couldn't be merged. When the method returns true the ownership of the given textchange is transfered to this class. More...
 
virtual bool canUndo ()
 This method should return true if the change can be reverted. More...
 
virtual bool isPersistenceRequired ()
 This flag is used to mark this stack item as non-persistence requirable The default behaviour is that every textchange requires persistence. It is also possible to have certain changes that do not require persitence but should be placed on the undo stack. More...
 
virtual TextEditorControllercontrollerContext ()
 A text command can belong to a controller/view When it's a view only command. The undo only applies only to this view warning a DOCUMENT change may NEVER return a controllerContext!! More...
 
bool isDocumentChange ()
 this method can be used to check if the given change is a document change More...
 
virtual bool isGroup ()
 This method returns true if this change is a group change. When an object is group change it should be inherited by TextChangeGroup. More...
 
virtual QString toString ()=0
 

Protected Member Functions

virtual void mergeStoredData (AbstractRangedChange *change)=0
 implement this method to merge to old data. Sample implementation More...
 
int getMergedDocLength (AbstractRangedChange *change)
 Calculates the merged length. More...
 
int getMergedStoredLength (AbstractRangedChange *change)
 Calculates the merge data size, that's required for merging the given change. More...
 
void mergeStoredDataViaMemcopy (void *targetData, void *data, void *changeData, AbstractRangedChange *change, int itemSize)
 This method merges the data via a memcopy. I really don't like this way of merging the data. though this is a way which support all kinds of arrays. I cannot use inheritance, because the types like QString don't have a common ancestor. More...
 
bool merge (AbstractRangedChange *change)
 This method merges the change. More...
 

Detailed Description

This is an abstract class for ranged changes This are changes (text changes and line changes) that span a range in an array. These ranges share a common alogrithm for performing merges, detecting overlaps etc.

Constructor & Destructor Documentation

◆ ~AbstractRangedChange()

edbee::AbstractRangedChange::~AbstractRangedChange ( )
virtual

default destructor is empty

Member Function Documentation

◆ addOffset()

void edbee::AbstractRangedChange::addOffset ( int  amount)

Adds the given amount to the offset.

Parameters
amountthe offset to add

◆ docLength()

virtual int edbee::AbstractRangedChange::docLength ( ) const
pure virtual

this method should return the length in the document

Implemented in edbee::TextChange, and edbee::LineDataListChange.

◆ getMergedDocLength()

int edbee::AbstractRangedChange::getMergedDocLength ( AbstractRangedChange change)
protected

Calculates the merged length.

Parameters
changethe change that't being merged

◆ getMergedStoredLength()

int edbee::AbstractRangedChange::getMergedStoredLength ( AbstractRangedChange change)
protected

Calculates the merge data size, that's required for merging the given change.

Parameters
changethe change to merge with this change
Returns
the size of this change

◆ isOverlappedBy()

bool edbee::AbstractRangedChange::isOverlappedBy ( AbstractRangedChange secondChange)

This method checks if this textchange is overlapped by the second text change overlapping is an exclusive overlap, which means the changes are really on top of eachother to test if the changes are touching use isTouchedBy.

Parameters
secondChangethe other change to compare it to
Returns
tue if the changes overlap

◆ isTouchedBy()

bool edbee::AbstractRangedChange::isTouchedBy ( AbstractRangedChange secondChange)

Touched ranges are ranges that are next to eachother Touching means the end offset of one range is the start offset of the other range.

Parameters
secondChangethe other change to match
Returns
true if the changes overlap

◆ merge()

bool edbee::AbstractRangedChange::merge ( AbstractRangedChange change)
protected

This method merges the change.

Parameters
documentthe document to merges
changethe change change to merge

◆ mergeStoredData()

virtual void edbee::AbstractRangedChange::mergeStoredData ( AbstractRangedChange change)
protectedpure virtual

implement this method to merge to old data. Sample implementation

SingleTextChange* singleTextChange = dynamic_cast<SingleTextChange*>(change); QString newText; newText.resize( calculateMergeDataSize( change) ); mergeData( newText.data(), text_.data(), singleTextChange->text_.data(), change, sizeof(QChar) );

Implemented in edbee::LineDataListChange, and edbee::TextChange.

◆ mergeStoredDataViaMemcopy()

void edbee::AbstractRangedChange::mergeStoredDataViaMemcopy ( void *  targetData,
void *  data,
void *  changeData,
AbstractRangedChange change,
int  itemSize 
)
protected

This method merges the data via a memcopy. I really don't like this way of merging the data. though this is a way which support all kinds of arrays. I cannot use inheritance, because the types like QString don't have a common ancestor.

Parameters
targetDatathe target of the data, (be sure enough space is reserved!!
datapointer to the data of this change (this can be a 0 pointer!, which results in 0-filling the target)
changeDatapointer to the of the other change data (this can be a 0 pointer!, which results in 0-filling the target)
changethe other change of the data to merge
itemSizethe size of single item

◆ offset()

virtual int edbee::AbstractRangedChange::offset ( ) const
pure virtual

this method should return the offset of the change

Implemented in edbee::TextChange, and edbee::LineDataListChange.

◆ setDocLength()

virtual void edbee::AbstractRangedChange::setDocLength ( int  value)
pure virtual

this method should set the old length

Implemented in edbee::TextChange, and edbee::LineDataListChange.

◆ setOffset()

virtual void edbee::AbstractRangedChange::setOffset ( int  value)
pure virtual

this method should set the offset

Implemented in edbee::TextChange, and edbee::LineDataListChange.

◆ storedLength()

virtual int edbee::AbstractRangedChange::storedLength ( ) const
pure virtual

this method should return the length of this item in memory

Implemented in edbee::LineDataListChange, and edbee::TextChange.


The documentation for this class was generated from the following files: