|
Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
|
Owning validated UTF-8 and immutable extended grapheme measurements. More...
#include <text.hpp>
Public Member Functions | |
| GraphemeText (const GraphemeText &other)=default | |
| Copy bytes and metadata into independent storage; may allocate. | |
| GraphemeText & | operator= (const GraphemeText &other) |
| Replace storage with an independent copy; invalidates borrowed views. | |
| GraphemeText (GraphemeText &&other) | |
| Transfer storage and empty the source; may allocate debug bookkeeping before changing the source. | |
| GraphemeText & | operator= (GraphemeText &&other) noexcept |
| Transfer storage; invalidates both objects' views and empties a distinct source. Self-move is a no-op. | |
| bool | operator== (const GraphemeText &other) const noexcept |
| Compare logical UTF-8 bytes and the complete captured width policy without allocating. | |
| std::string_view | bytes () const noexcept |
| Borrow original bytes until this object's assignment/move/destruction. | |
| std::span< const Grapheme > | graphemes () const noexcept |
| Borrow metadata until this object's assignment/move/destruction. | |
| std::int32_t | measure () const noexcept |
| Return cached int32_t-compatible total cells; no allocation or errors. | |
| WidthPolicy | policy () const noexcept |
| Return the owning captured cache-key policy; no errors. | |
| std::expected< std::size_t, TextError > | nextCursor (std::size_t byte_offset) const noexcept |
| Advance a byte-boundary cursor by one cluster; end stays at end. | |
| std::expected< std::size_t, TextError > | previousCursor (std::size_t byte_offset) const noexcept |
| Retreat a byte-boundary cursor by one cluster; zero stays at zero. | |
| TextClip | clipPrefix (std::int32_t max_cells) const noexcept |
| Return the maximal prefix fitting a cell budget, stopping before a wide cluster that cannot fit. | |
Static Public Member Functions | |
| static std::expected< GraphemeText, TextError > | from (std::string_view bytes, WidthPolicy policy={}, TextLimits limits={}) |
| Validate, segment and measure a single logical UTF-8 buffer. | |
Friends | |
| struct | detail::EditStorageAccess |
Owning validated UTF-8 and immutable extended grapheme measurements.
Unicode 18.0.0 boundaries are independent of display support: controls, standalone marks and unsupported widths remain whole logical clusters. No I/O, callbacks or mutable global state. Construction/copy can allocate and throw std::bad_alloc or std::length_error; semantic failures use TextError. Any thread may own a value; concurrent reads of one unchanged value are safe. Assignment/move/destruction require caller synchronization and invalidate all borrowed views. Moving resets a distinct source to empty; self-move assignment is a no-op. Policy is captured at construction; replacing a value under a new policy requires layout/paint invalidation by the caller. This component does not own terminal cells.
|
default |
Copy bytes and metadata into independent storage; may allocate.
| other | Validated text whose bytes, metadata and policy are copied. |
| std::bad_alloc | If independent storage or debug bookkeeping cannot be allocated. |
| portals::GraphemeText::GraphemeText | ( | GraphemeText && | other | ) |
Transfer storage and empty the source; may allocate debug bookkeeping before changing the source.
| other | Source whose storage is transferred and whose size becomes zero on success. |
| std::bad_alloc | If preliminary bookkeeping allocation fails; other remains unchanged. |
|
nodiscardnoexcept |
Borrow original bytes until this object's assignment/move/destruction.
|
nodiscardnoexcept |
Return the maximal prefix fitting a cell budget, stopping before a wide cluster that cannot fit.
| max_cells | Available cells; negative values normalize to zero. |
|
staticnodiscard |
Validate, segment and measure a single logical UTF-8 buffer.
| bytes | Borrowed only for this synchronous call; copied on success. |
| policy | Owning policy value, retained on success. |
| limits | Owning resource caps; zero caps permit only empty input. |
|
nodiscardnoexcept |
Borrow metadata until this object's assignment/move/destruction.
|
nodiscardnoexcept |
Return cached int32_t-compatible total cells; no allocation or errors.
|
nodiscardnoexcept |
Advance a byte-boundary cursor by one cluster; end stays at end.
| byte_offset | Valid boundary including zero and byte length. |
| GraphemeText & portals::GraphemeText::operator= | ( | const GraphemeText & | other | ) |
Replace storage with an independent copy; invalidates borrowed views.
| other | Source value; self-assignment is supported. |
| std::bad_alloc | If copying fails; this object retains its previous value. |
|
noexcept |
Transfer storage; invalidates both objects' views and empties a distinct source. Self-move is a no-op.
| other | Source whose storage is transferred; a distinct source becomes empty. |
|
noexcept |
Compare logical UTF-8 bytes and the complete captured width policy without allocating.
| other | Owning immutable text to compare; segmentation is determined by bytes and policy. |
|
nodiscardnoexcept |
Return the owning captured cache-key policy; no errors.
|
nodiscardnoexcept |
Retreat a byte-boundary cursor by one cluster; zero stays at zero.
| byte_offset | Valid boundary including zero and byte length. |