Learn R Programming

automerge (version 0.3.0)

am_cursor_to_bytes: Serialize a cursor to bytes

Description

Converts a cursor to a raw vector representation that can be persisted and later restored with am_cursor_from_bytes(). This enables saving cursor positions across R sessions.

Usage

am_cursor_to_bytes(cursor)

Value

A raw vector containing the serialized cursor

Arguments

cursor

An am_cursor object created by am_cursor()

See Also

am_cursor_from_bytes(), am_cursor_to_string()

Examples

Run this code
doc <- am_create()
am_put(doc, AM_ROOT, "text", am_text("Hello World"))
text_obj <- am_get(doc, AM_ROOT, "text")

cursor <- am_cursor(text_obj, 5)
bytes <- am_cursor_to_bytes(cursor)
bytes

# Restore cursor later
restored <- am_cursor_from_bytes(bytes, text_obj)
am_cursor_position(restored)  # 5

am_close(doc)

Run the code above in your browser using DataLab