Led 3.0 Class Library Documentation

Module TextStore


Classes and Global Functions Index

Module Description:

This module introduces one of Led's key abstractions - the TextStore. A TextStore - as the name suggests - is where Led keeps track of text. It is abstract enuf to keep track in many different representations of the text.

A TextStore also keeps track of Markers associated with the text.

Important Design Notes:


Class: CompareSameMarkerOwner [public]

Description:

A MarkerSink which filters on the given MarkerOwner.

OBSOLETE. Use MarkerOwner arg CollectAllMarkersInRange () etc...


Class: MarkerOfATypeMarkerSink < T > [public]

Base Classes: TextStore::MarkerSink
Description:

A MarkerSink template which grabs only Markers of subtype 'T' (using dynamic_cast<>). Similar to MarkersOfATypeMarkerSink2Vector except that this class only grabs a SINGLE marker in that range (which is stored in fResult). It is an error (detected via an assertion) if this class is ever used to sink more than one marker (though its OK if it gets none - fResult will be NULL).


Class: MarkersOfATypeMarkerSink < T > [public]

Base Classes: TextStore::MarkerSink
Description:

A MarkerSink which filters on the given type T using dynamic_cast.


Class: MarkersOfATypeMarkerSink2Vector < T > [public]

Base Classes: TextStore::MarkerSink
Description:

A MarkerSink template which grabs only Markers of subtype 'T' (using dynamic_cast<>). Dumps results into a vector named 'fResult'.


Class: MarkersOfATypeMarkerSinkWithCompare2List < T,COMPARE > [public]

Base Classes: TextStore::MarkerSink
Description:

A MarkerSink template which filters using the template-argument COMPARE type. Useful in conjunction with CompareSameMarkerOwner. Dumps results into a list named 'fResult'.

Now OBSOLETE. Use MarkerOwner arg CollectAllMarkersInRange () etc...


Class: MarkersOfATypeMarkerSinkWithCompare2Vector < T,COMPARE > [public]

Base Classes: TextStore::MarkerSink
Description:

A MarkerSink template which filters using the template-argument COMPARE type. Useful in conjunction with CompareSameMarkerOwner. Dumps results into a vector named 'fResult'.

Now OBSOLETE. Use MarkerOwner arg CollectAllMarkersInRange () etc...


Class: TextStore [public]

Base Classes: MarkerOwner
Description:

An abstraction of something which contains text, and special objects called markers, which can be used to represent embedded data, or hypertext links, or font style runs. Markers have a left and right edge (named by indexes into the text buffer), and conceptually stick to the text they wrap as the text is modified (edited).

There are two concrete TextStore implementations you can use (with Led 3.0).

Future versions of Led may include TextStore implementations which:

Member Details

TextStore::AddMarker [public]

virtual void AddMarker (Marker* marker, size_t lhs, size_t length, MarkerOwner* owner) = 0;

Add the given marker to this TextStore, starting at position lhs, and give the marker length 'length'. Record that its owner is 'owner'.

NB: the MarkerOwner - must be a valid MarkerOwner. Either this TestStore, or a class which has been added to this TextStore by TextStore::AddMarkerOwner. This requirement is new to Led 2.3 (but unlikely ever violated before).

It is an error to add a marker which is already added to some TextStore (even this TextStore).

It is an error to destroy a TextStore without first removing all markers you had added. It is in order to make that more efficient that we provide the RemoveMarkers () method.

We are strict about markers extenting outside valid index ranges - this is an prohibited.

TextStore::AddMarkerOwner [public]

void TextStore::AddMarkerOwner (MarkerOwner* owner)

Register the given MarkerOwner with the TextStore for later notification of updates to the text. Remove via RemoveMarkerOwner ().

NB: It is illegal to add a MarkerOwner to more than one TextStore at a time, or to the same one multiple times.

TextStore::CollectAllMarkersInRange [public]

vector < Marker* > TextStore::CollectAllMarkersInRange (size_t from, size_t to, const MarkerOwner* owner) const

CollectAllMarkersInRange () is part of a family of routines to retreive markers of interest in a particular range of the text.

The TextStore::Overlap method is what is used to see if a marker is considered to be in the given from/to range for the purpose of collection (does the obvious intersection test with the added caveat of not including markers which only overlap at one edge or the other - and not including any common characters - except special case of zero-sized marker).

You can either specify a callback function/object to be called with each found marker. If you only need the first such, you can throw to terminate the search. There is a help class and helper fuctions to allow you to fill an array with the all the matching Markers.

NB: this has changed somewhat since Led22 - see SPR#0489.

TextStore::CollectAllMarkersInRangeInto [public]

static const MarkerOwner* kAnyMarkerOwner;

Note - owner can be any valid MarkerOwner, or TextStore::kAnyMarkerOwner.

TextStore::CopyOut [public]

virtual void CopyOut (size_t from, size_t count, Led_tChar* buffer) const throw () = 0;

CopyOut does NOT null terminate. It is an error to call with withWhatBytes causing access past end of TextStore buffer.

Note that it IS NOT an error to call CopyOut for multibyte characters and split them. This is one of the few API routines where that is so.

TextStore::DoAboutToUpdateCalls [public]

void TextStore::DoAboutToUpdateCalls (const UpdateInfo& updateInfo, const vector < Marker* > & markers)

Utility to call AboutToUpdateText on registered MarkerOwners, and Markers. Don't call directly. Called by concrete TextStore subclasses. Note: we call the AbouToUpdate() calls first on the markers, and then on the MarkerOwners. And in TextStore::DoDidUpdateCalls we will call them in the reverse order.

TextStore::DoDidUpdateCalls [public]

void TextStore::DoDidUpdateCalls (const UpdateInfo& updateInfo, const vector < Marker* > & markers) throw ()

Utility to call DidUpdateText on registered MarkerOwners, and Markers. Don't call directly. Called by concrete TextStore subclasses.

NB: See TextStore::DoAboutToUpdateCalls. And note that we call the MarkerOwner::DidUpdateText calls in the reverse order in which the MarkerOwner::AboutToUpdateText calls were made.

TextStore::Find [public]

size_t TextStore::Find (const SearchParameters& params, size_t searchFrom, size_t searchTo)

Search within the given range for the text specified in SearchParameters. The SearchParameters specify a bunch of different matching criteria, as well. No 'regexp' searching supported as of yet.

TextStore::FindPreviousCharacter [public]

size_t TextStore::FindPreviousCharacter (size_t beforePos) const

Returns the marker position of the previous character. If at the start of the buffer, it returns 0. Use this instead of pos--, in order to deal properly with multibyte character sets.

TextStore::GetEnd [public]

size_t TextStore::GetEnd () const

Returns the marker position of the end of the text buffer.

TextStore::GetEndOfLine [public]

size_t TextStore::GetEndOfLine (size_t lineNumber) const

Returns the marker position of the end of the given line #.

TextStore::GetEndOfLineContainingPosition [public]

size_t TextStore::GetEndOfLineContainingPosition (size_t afterPos) const

Returns the marker position of the end of the line contains the character after 'afterPos'.

TextStore::GetLength [public]

virtual size_t GetLength () const throw () = 0;

Returns the number of Led_tChars in this TextStore.

TextStore::GetLineContainingPosition [public]

size_t TextStore::GetLineContainingPosition (size_t charPosition) const

Returns the # of the line which contains the given charPosition. NB: we use charPosition here to deal with the ambiguity of what line a markerPosition is at when it straddles two lines.

TextStore::GetLineCount [public]

size_t TextStore::GetLineCount () const

Returns the # of the lines in the TextStore.

TextStore::GetMarkerOwners [public]

const vector < MarkerOwner* > & TextStore::GetMarkerOwners () const throw ()

Returns the list of all MarkerOwners registered for notification of changes to the text.

TextStore::GetStart [public]

size_t TextStore::GetStart ()

Returns the marker position of the beginning of the text buffer (always 0).

TextStore::GetStartOfLine [public]

size_t TextStore::GetStartOfLine (size_t lineNumber) const

Returns the marker position of the start of the given line #.

TextStore::GetStartOfLineContainingPosition [public]

size_t TextStore::GetStartOfLineContainingPosition (size_t afterPos) const

Returns the marker position of the start of the line contains the character after 'afterPos'.

TextStore::GetTextBreaker [public]

Led_RefCntPtr < TextBreaks > TextStore::GetTextBreaker () const

Returns a Led_RefCntPtr wrapper on the TextBreaks subclass associated with this TextStore. This procedure can be changed at any time (though if any information in other parts of Led is cached and dependent on this procedures results - you may wish to invalidate those caches).

If none is associated with the TextStore right now - and default one is built and returned.

See also See TextStore::SetTextBreaker.

TextStore::Invariant_ [public]

void TextStore::Invariant_ () const

Check internal consitency of data structures. Don't call this directly. Call TextStore::Invariant instead. And only call at quiesent times; not in the midst of some update where data structures might not be fully consistent.

TextStore::Overlap [public]

bool TextStore::Overlap (const Marker& m, size_t from, size_t to)

The idea here is to test if a marker overlaps with a given range of the document. But only in some INTERESTING way.

The one case one might plausibly consider overlap which this routine does NOT is the case where two markers touch only at the edges (lhs of one == rhs of the other). For the purposes for which markers are used - in my experience - this is NOT an interesting case and it makes code using TextStore::CollectAllMarkersInRange nearly always simpler and more efficient to be able to avoid those cases.

There is one further refinement added here in Led 2.3 (970929, for spr#0489). When the marker is zero-length (not the from/to args, but the 'm' arg), then the overlap is allowed to be zero width and it is still considerd a valid overlap. This is true because we want CollectAllMarkersInRange () to be usable to pick up zero-length markers. Essentially, this means it is "OverlapOrStrictlyContains".

NB: The details of this special 'zero-width' overlap case were further clarified, and improved, and revised in Led 3.0d6 (2000/04/26, SPR#0745).

Important:
The definition of overlap is now that a marker overlaps with a given region if it overlaps by ONE FULL marker position, or one special case of ZERO overlap. The only ZERO-overlap case which is supported is simply if the marker-width is zero sized.

The part which is a change from Led 2.3 (and earlier) is the details of WHICH zero-width overlap cases are now considered overlap. I think the new rule is simpler, and more intuitive. See Led 2.3 for the old rule/code.

NB: This routine is mainly called by the TextStore::CollectAllMarkersInRange () family of functions.

NB: This routine is NOT symetric. By this I mean that Overlap (A,B) is not always the same as Overlap (B,A). The reason for this is because we specially treat the case of a zero-width first arg to overlap. And we make no such special treatment of the second argument.

See SPR#0745 for more details. Also, SPR#0489, and SPR#420.

TextStore::PeekAtTextStore [public]

TextStore* TextStore::PeekAtTextStore () const

Since a TextStore is a MarkerOwner, is must override the PeekAtTextStore method, and return itself.

TextStore::PreRemoveMarker [public]

virtual void PreRemoveMarker (Marker* marker) = 0;

Don't entirely remove the marker (so it can still be queried for size etc). But mark it so it will not appear in future CollectAllXXX methods.

This is NOT required before calling TextStore::RemoveMarker, but can be handy from classes like MarkerMortuary.

This method was added to fix SPR#0822 - see for details.

TextStore::RemoveMarker [public]

Remove the given marker from the TextStore. It is an error if the given marker is not already in this TextStore. See TextStore::AddMarker for more details.

TextStore::RemoveMarker (overload 1) [public]

void TextStore::RemoveMarker (Marker* marker)

Remove the given marker from the text.

TextStore::RemoveMarkerOwner [public]

void TextStore::RemoveMarkerOwner (MarkerOwner* owner)

Unregister the given MarkerOwner which was previously registed with AddMarkerOwner ().

TextStore::RemoveMarkers [public]

virtual void RemoveMarkers (Marker*const markerArray[], size_t markerCount) = 0;

Remove the given markers from the TextStore. This is essentially the same as doing multiple TextStore::RemoveMarker calls, except that it may be more efficient for removing large numbers of markers.

See also TextStore::PreRemoveMarker.

TextStore::Replace [public]

virtual void Replace (size_t from, size_t to, const Led_tChar* withWhat, size_t withWhatCount) = 0;

Replace the text in the range {from,to} with the withWhatCount Led_tChars of text pointed to by withWhat. This update will have the side effect of notifying MarkerOwners, and affected Markers.

TextStore::SetMarkerEnd [public]

void TextStore::SetMarkerEnd (Marker* marker, size_t end) throw ()

Similar to TextStore::SetMarkerRange, except that the start-point doesn't change. Vectors to TextStore::SetMarkerRange. See TextStore::SetMarkerStart.

TextStore::SetMarkerLength [public]

void TextStore::SetMarkerLength (Marker* marker, size_t length) throw ()

Similar to TextStore::SetMarkerRange, except that the start-point doesn't change. Similar to TextStore::SetMarkerEnd except that it takes a length, not an end-point. Vectors to TextStore::SetMarkerRange. See TextStore::SetMarkerStart.

TextStore::SetMarkerRange [public]

virtual void SetMarkerRange (Marker* marker, size_t start, size_t end) throw () = 0;

Set the bounds of the given marker. The given marker must already be in this TextStore (see TextStore::AddMarker). And it is required that the start/end values be within the valid marker range for this buffer.

TextStore::SetMarkerStart [public]

void TextStore::SetMarkerStart (Marker* marker, size_t start) throw ()

Similar to TextStore::SetMarkerRange, except that the end-point doesn't change. Vectors to TextStore::SetMarkerRange. See TextStore::SetMarkerEnd.

TextStore::SetTextBreaker [public]

void TextStore::SetTextBreaker (const Led_RefCntPtr < TextBreaks > & textBreaker)

See TextStore::GetTextBreaker.

TextStore::kAnyMarkerOwner [public]

const MarkerOwner* TextStore::kAnyMarkerOwner = reinterpret_cast < MarkerOwner* > (1);

Sentinal value meaning to match on ANY marker owner for TextStore::CollectAllMarkersInRangeInto etc calls.


Class: TextStore::MarkerSink [public]

Description:

An abstract "callback class", used to be notified in calls to CollectAllMarkersInRangeInto. To use this class, subclass, and override the Append () method. Pass an instance of your subclass to TextStore::CollectAllMarkersInRangeInto (or some variant). Your classes Append method will be called for each marker in the given range.

Member Details

TextStore::MarkerSink::Append [public]

virtual void Append (Marker* m) = 0;

Don't call directly. Called by TextStore::CollectAllMarkersInRangeInto (). Override this method and pass an instance of your subclass to TextStore::CollectAllMarkersInRangeInto ().


Class: TextStore::VectorMarkerSink [public]

Base Classes: TextStore::MarkerSink
Description:

A utility class which gathers all the markers passed to it into an array (vector).

Member Details

TextStore::VectorMarkerSink::Append [public]

void TextStore::VectorMarkerSink::Append (Marker* m)

Don't call directly. Called as a by-product of TextStore::CollectAllMarkersInRange (). This TextStore::VectorMarkerSink produces a vector for such collect calls.


Config Variable: qUseWin32CompareStringCallForCaseInsensitiveSearch [public]

Description:

Produces better internationalized results - but - of course - is Win32 specific - and a bit slower. Based on SPR#0864


Return to Led Page Return to Led ClassLib Documentation Index Return to Led Reference Manual Index
Last Updated 2001-10-20