Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::TextChangeMap Class Referencefinal

Bounded metadata-only helper for a text provider; not a PositionResolver. Caller serializes every operation. Creation allocates; publication and resolution allocate nothing, perform no I/O or callbacks, and inspect only bounded metadata. Missing proof returns UNAVAILABLE. The enclosing provider must validate/snap mapped scalar hints to actual grapheme boundaries before publishing TEXT replies. This avoids a whole-document grapheme index requirement. Bookmarks contain scalars only. Content-state tokens are positive, provider-local values, not logical resource identities. More...

#include <text_document.hpp>

Public Member Functions

 ~TextChangeMap ()
 Release metadata; no provider, view or text is retained.
std::expected< void, SourceError > edit (TextSplice change, std::uint64_t contentState) noexcept
std::expected< void, SourceError > traverse (std::uint64_t contentState, std::uint64_t extent) noexcept
std::expected< ModelBookmark, SourceError > bookmark (std::uint64_t offset, PositionAffinity affinity=PositionAffinity::FORWARD) const
std::expected< TextMappedPosition, SourceError > map (const ModelBookmark &bookmark, std::stop_token stop={}) const
std::uint64_t revision () const noexcept
std::uint64_t extent () const noexcept

Static Public Member Functions

static std::expected< std::unique_ptr< TextChangeMap >, SourceError > create (ModelResource resource, std::uint64_t extent, TextAnchorOptions options={}, std::uint64_t initialRevision=1, std::uint64_t initialContentState=1)

Detailed Description

Bounded metadata-only helper for a text provider; not a PositionResolver. Caller serializes every operation. Creation allocates; publication and resolution allocate nothing, perform no I/O or callbacks, and inspect only bounded metadata. Missing proof returns UNAVAILABLE. The enclosing provider must validate/snap mapped scalar hints to actual grapheme boundaries before publishing TEXT replies. This avoids a whole-document grapheme index requirement. Bookmarks contain scalars only. Content-state tokens are positive, provider-local values, not logical resource identities.

Member Function Documentation

◆ bookmark()

std::expected< ModelBookmark, SourceError > portals::TextChangeMap::bookmark ( std::uint64_t offset,
PositionAffinity affinity = PositionAffinity::FORWARD ) const
Parameters
offsetCurrent scalar offset, including end; caller must prove the grapheme boundary.
affinityFORWARD follows insertion; BACKWARD stays before insertion.
Returns
Scalar-only TEXT bookmark or INVALID_ARGUMENT.

◆ create()

std::expected< std::unique_ptr< TextChangeMap >, SourceError > portals::TextChangeMap::create ( ModelResource resource,
std::uint64_t extent,
TextAnchorOptions options = {},
std::uint64_t initialRevision = 1,
std::uint64_t initialContentState = 1 )
static
Parameters
resourceExisting logical resource namespace; no new issuer is introduced.
extentInitial extent in provider-defined text units; may exceed resident memory.
optionsPositive metadata capacity.
initialRevisionPositive initial data revision, normally one.
initialContentStatePositive provider-local baseline token, normally one.
Returns
Map at the supplied baseline, or a typed admission error.

◆ edit()

std::expected< void, SourceError > portals::TextChangeMap::edit ( TextSplice change,
std::uint64_t contentState )
noexcept
Parameters
changeProvider-proven scalar replacement.
contentStateNew strictly increasing provider-local content token.
Returns
Success or validation/exhaustion failure; failures preserve the map.

◆ extent()

std::uint64_t portals::TextChangeMap::extent ( ) const
noexcept
Returns
Current logical scalar extent; no source scan.

◆ map()

std::expected< TextMappedPosition, SourceError > portals::TextChangeMap::map ( const ModelBookmark & bookmark,
std::stop_token stop = {} ) const
Parameters
bookmarkTEXT bookmark captured at a provider-validated grapheme boundary.
stopCooperative cancellation; checked without retaining the token.
Returns
Intermediate mapped scalar hint or typed cancellation/validation failure. EXACT means scalar mapping is exact; the provider may still need a NEAREST grapheme snap.

◆ revision()

std::uint64_t portals::TextChangeMap::revision ( ) const
noexcept
Returns
Current monotonically increasing data revision.

◆ traverse()

std::expected< void, SourceError > portals::TextChangeMap::traverse ( std::uint64_t contentState,
std::uint64_t extent )
noexcept
Parameters
contentStatePrior token proven by the provider's existing Undo/Redo engine.
extentExact scalar extent in that state, even when its old proof was evicted.
Returns
Success or validation/exhaustion failure; no second undo engine is stored.

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