Gets or creates a new shared YArray
data type instance as a root-level type of a given document.
This structure can later be accessed using its name
, which must be a null-terminated UTF-8
compatible string.
Returns a sequence of changes produced by sequence component of shared collections (such as
YText
, YXmlText
and XML nodes added to YXmlElement
). len
output parameter is used to
provide information about number of changes produced.
Returns a path from a root type down to a current shared collection (which can be obtained using
yarray_event_target
function). It can consist of either integer indexes (used by sequence
components) of *char keys (used by map components). len
output parameter is used to provide
information about length of the path.
Returns a pointer to a shared collection, which triggered passed event e
.
Returns a pointer to a YOutput
value stored at a given index
of a current YArray
.
If index
is outside of the bounds of an array, a null pointer will be returned.
Inserts a range of items
into current YArray
, starting at given index
. An items_len
parameter is used to determine the size of items
array - it can also be used to insert
a single element given its pointer.
Returns an iterator, which can be used to traverse over all elements of an
array
(
array
’s
length can be determined using
yarray_len function).
Releases all of an
YArray
iterator resources created by calling
yarray_iter.
Moves current YArray
iterator over to a next element, returning a pointer to it. If an iterator
comes to an end of an array, a null pointer will be returned.
Returns a number of elements stored within current instance of YArray
.
Subscribes a given callback function cb
to changes made by this YArray
instance. Callbacks
are triggered whenever a ytransaction_commit
is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
yarray_unobserve
function.
Removes a len
of consecutive range of elements from current array
instance, starting at
a given index
. Range determined by index
and len
must fit into boundaries of an array,
otherwise it will panic at runtime.
Releases a callback subscribed via yarray_observe
function represented by passed
observer parameter.
Frees all memory-allocated resources bound to a given binary returned from Yrs document API.
Unlike strings binaries are not null-terminated and can contain null characters inside,
therefore a size of memory to be released must be explicitly provided.
Yrs binaries don’t use libc malloc, so calling free()
on them will fault.
Starts a new read-only transaction on a given branches document. All other operations happen in
context of a transaction. Yrs transactions do not follow ACID rules. Once a set of operations is
complete, a transaction can be finished using ytransaction_commit
function.
Starts a new read-write transaction on a given branches document. All other operations happen in
context of a transaction. Yrs transactions do not follow ACID rules. Once a set of operations is
complete, a transaction can be finished using ytransaction_commit
function.
Deallocates result of ytext_chunks
method.
Returns status of auto_load flag of this
Doc instance. Auto loaded sub-documents automatically
send a load request to their parent documents.
Destroys current document, sending a ‘destroy’ event and clearing up all the event callbacks
registered.
Creates a shallow clone of a provided doc
- it’s realized by increasing the ref-count
value of the document. In result both input and output documents point to the same instance.
Returns a collection identifier of this
Doc instance.
If none was defined, a
NULL
will be returned.
Releases all memory-allocated resources bound to given document.
Returns a unique document identifier of this
Doc instance.
Returns a unique client identifier of this
Doc instance.
Manually send a load request to a parent document of this subdoc.
Creates a new
Doc instance with a randomized unique client identifier.
Creates a new
Doc instance with a specified
options
.
Starts a new read-only transaction on a given document. All other operations happen in context
of a transaction. Yrs transactions do not follow ACID rules. Once a set of operations is
complete, a transaction can be finished using ytransaction_commit
function.
Returns status of should_load flag of this
Doc instance, informing parent
Doc if this
document instance requested a data load.
Starts a new read-write transaction on a given document. All other operations happen in context
of a transaction. Yrs transactions do not follow ACID rules. Once a set of operations is
complete, a transaction can be finished using ytransaction_commit
function.
Releases memory allocated by the object returned from yevent_delta
function.
Releases memory allocated by the object returned from yxml_event_keys
and ymap_event_keys
functions.
Function constructor used to create a binary YInput
cell of a specified length.
This function doesn’t allocate any heap resources and doesn’t release any on its own, therefore
its up to a caller to free resources once a structure is no longer needed.
Function constructor used to create JSON-like boolean YInput
cell.
This function doesn’t allocate any heap resources.
Function constructor used to create JSON-like 64-bit floating point number YInput
cell.
This function doesn’t allocate any heap resources.
Function constructor used to create a JSON-like array YInput
cell of other JSON-like values of
a given length. This function doesn’t allocate any heap resources and doesn’t release any on its
own, therefore its up to a caller to free resources once a structure is no longer needed.
Function constructor used to create a JSON-like map YInput
cell of other JSON-like key-value
pairs. These pairs are build from corresponding indexes of keys
and values
, which must have
the same specified length.
Function constructor used to create JSON-like 64-bit signed integer YInput
cell.
This function doesn’t allocate any heap resources.
Function constructor used to create JSON-like NULL YInput
cell.
This function doesn’t allocate any heap resources.
Function constructor used to create a string YInput
cell. Provided parameter must be
a null-terminated UTF-8 encoded string. This function doesn’t allocate any heap resources,
and doesn’t release any on its own, therefore its up to a caller to free resources once
a structure is no longer needed.
Function constructor used to create JSON-like undefined YInput
cell.
This function doesn’t allocate any heap resources.
Function constructor used to create a nested YArray
YInput
cell prefilled with other
values of a given length. This function doesn’t allocate any heap resources and doesn’t release
any on its own, therefore its up to a caller to free resources once a structure is no longer
needed.
Function constructor used to create a nested YDoc
YInput
cell.
Function constructor used to create a nested YMap
YInput
cell prefilled with other key-value
pairs. These pairs are build from corresponding indexes of keys
and values
, which must have
the same specified length.
Function constructor used to create a nested YText
YInput
cell prefilled with a specified
string, which must be a null-terminated UTF-8 character pointer.
Function constructor used to create a nested YXmlElement
YInput
cell with a specified
tag name, which must be a null-terminated UTF-8 character pointer.
Function constructor used to create a nested YXmlText
YInput
cell prefilled with a specified
string, which must be a null-terminated UTF-8 character pointer.
Gets or creates a new shared YMap
data type instance as a root-level type of a given document.
This structure can later be accessed using its name
, which must be a null-terminated UTF-8
compatible string.
Frees all memory-allocated resources bound to a given
YMapEntry.
Returns a sequence of changes produced by map component of shared collections (such as
YMap
and YXmlText
/YXmlElement
attribute changes). len
output parameter is used to
provide information about number of changes produced.
Returns a path from a root type down to a current shared collection (which can be obtained using
ymap_event_target
function). It can consist of either integer indexes (used by sequence
components) of *char keys (used by map components). len
output parameter is used to provide
information about length of the path.
Returns a pointer to a shared collection, which triggered passed event e
.
Returns a value stored under the provided
key
, or a null pointer if no entry with such
key
has been found in a current
map
. A returned value is allocated by this function and therefore
should be eventually released using
youtput_destroy function.
Inserts a new entry (specified as key
-value
pair) into a current map
. If entry under such
given key
already existed, its corresponding value will be replaced.
Returns an iterator, which can be used to traverse over all key-value pairs of a map
.
Releases all of an
YMap
iterator resources created by calling
ymap_iter.
Moves current YMap
iterator over to a next entry, returning a pointer to it. If an iterator
comes to an end of a map, a null pointer will be returned. Yrs maps are unordered and so are
their iterators.
Returns a number of entries stored within a map
.
Subscribes a given callback function cb
to changes made by this YMap
instance. Callbacks
are triggered whenever a ytransaction_commit
is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
ymap_unobserve
function.
Removes a map
entry, given its key
. Returns 1
if the corresponding entry was successfully
removed or 0
if no entry with a provided key
has been found inside of a map
.
Removes all entries from a current map
.
Releases a callback subscribed via ymap_observe
function represented by passed
observer parameter.
Subscribes a given callback function cb
to changes made by this shared type instance as well
as all nested shared types living within it. Callbacks are triggered whenever a
ytransaction_commit
is called.
Returns default ceonfiguration for YOptions
.
Releases all resources related to a corresponding YOutput
cell.
Attempts to read the value for a given YOutput
pointer as a binary payload (which length is
stored within len
filed of a cell itself).
Attempts to read the value for a given YOutput
pointer as a boolean flag, which can be either
1
for truthy case and 0
otherwise. Returns a null pointer in case when a value stored under
current YOutput
cell is not of a boolean type.
Attempts to read the value for a given YOutput
pointer as a 64-bit floating point number.
Attempts to read the value for a given YOutput
pointer as a JSON-like array of YOutput
values (which length is stored within len
filed of a cell itself).
Attempts to read the value for a given YOutput
pointer as a JSON-like map of key-value entries
(which length is stored within len
filed of a cell itself).
Attempts to read the value for a given YOutput
pointer as a 64-bit signed integer.
Attempts to read the value for a given YOutput
pointer as a null-terminated UTF-8 encoded
string.
Attempts to read the value for a given YOutput
pointer as an YArray
.
Attempts to read the value for a given YOutput
pointer as a YDocRef
reference to a nested
document.
Attempts to read the value for a given YOutput
pointer as an YMap
.
Attempts to read the value for a given YOutput
pointer as an YText
.
Attempts to read the value for a given YOutput
pointer as an YXmlElement
.
Attempts to read the value for a given YOutput
pointer as an YXmlText
.
Releases allocated memory used by objects returned from path accessor functions of shared type
events.
Returns association of current YStickyIndex
.
If association is after the referenced inserted character, returned number will be >= 0.
If association is before the referenced inserted character, returned number will be < 0.
Deserializes YStickyIndex
from the payload previously serialized using ysticky_index_encode
.
Releases resources allocated by YStickyIndex
pointers.
Serializes YStickyIndex
into binary representation. len
parameter is updated with byte
length of the generated binary. Returned binary can be free’d using ybinary_destroy
.
Retrieves a YStickyIndex
corresponding to a given human-readable index
pointing into
the shared y-type branch
. Unlike standard indexes sticky one enables to track
the location inside of a shared y-types, even in the face of concurrent updates.
Given YStickyIndex
and transaction reference, if computes a human-readable index in a
context of the referenced shared y-type.
Frees all memory-allocated resources bound to a given UTF-8 null-terminated string returned from
Yrs document API. Yrs strings don’t use libc malloc, so calling free()
on them will fault.
Gets or creates a new shared YText
data type instance as a root-level type of a given document.
This structure can later be accessed using its name
, which must be a null-terminated UTF-8
compatible string.
Returns a collection of chunks representing pieces of YText
rich text string grouped together
by the same formatting rules and type. chunks_len
is used to inform about a number of chunks
generated this way.
Releases memory allocated by the object returned from yevent_delta
function.
Returns a sequence of changes produced by sequence component of shared collections (such as
YText
, YXmlText
and XML nodes added to YXmlElement
). len
output parameter is used to
provide information about number of changes produced.
Returns a path from a root type down to a current shared collection (which can be obtained using
ytext_event_target
function). It can consist of either integer indexes (used by sequence
components) of *char keys (used by map components). len
output parameter is used to provide
information about length of the path.
Returns a pointer to a shared collection, which triggered passed event e
.
Wraps an existing piece of text within a range described by index
-len
parameters with
formatting blocks containing provided attrs
metadata. attrs
must be a map-like type.
Inserts a null-terminated UTF-8 encoded string a given
index
.
index
value must be between
0 and a length of a
YText
(inclusive, accordingly to
ytext_len return value), otherwise this
function will panic.
Inserts an embed content given
index
.
index
value must be between 0 and a length of a
YText
(inclusive, accordingly to
ytext_len return value), otherwise this
function will panic.
Returns the length of the YText
string content in bytes (without the null terminator character)
Subscribes a given callback function cb
to changes made by this YText
instance. Callbacks
are triggered whenever a ytransaction_commit
is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
ytext_unobserve
function.
Removes a range of characters, starting a a given index
. This range must fit within the bounds
of a current YText
, otherwise this function call will fail.
Returns a null-terminated UTF-8 encoded string content of a current YText
shared data type.
Releases a callback subscribed via ytext_observe
function represented by passed
observer parameter.
Applies an diff update (generated by ytransaction_state_diff_v1
) to a local transaction’s
document.
Commit and dispose provided read-write transaction. This operation releases allocated resources,
triggers update events and performs a storage compression over all operations executed in scope
of a current transaction.
Encodes a state of the document at a point in time specified by the provided snapshot
(generated by: ytransaction_snapshot
). This is useful to generate a past view of the document.
Encodes a state of the document at a point in time specified by the provided snapshot
(generated by: ytransaction_snapshot
). This is useful to generate a past view of the document.
Returns a snapshot descriptor of a current state of the document. This snapshot information
can be then used to encode document data at a particular point in time
(see: ytransaction_encode_state_from_snapshot
).
Returns a delta difference between current state of a transaction’s document and a state vector
sv
encoded as a binary payload using lib0 version 1 encoding (which could be generated using
ytransaction_state_vector_v1). Such delta can be send back to the state vector’s sender in
order to propagate and apply (using
ytransaction_apply) all updates known to a current
document, which remote peer was not aware of.
Returns a delta difference between current state of a transaction’s document and a state vector
sv
encoded as a binary payload using lib0 version 1 encoding (which could be generated using
ytransaction_state_vector_v1). Such delta can be send back to the state vector’s sender in
order to propagate and apply (using
ytransaction_apply_v2) all updates known to a current
document, which remote peer was not aware of.
Returns a state vector of a current transaction’s document, serialized using lib0 version 1
encoding. Payload created by this function can then be send over the network to a remote peer,
where it can be used as a parameter of
ytransaction_state_diff_v1 in order to produce a delta
update payload, that can be send back and applied locally in order to efficiently propagate
updates from one peer to another.
Returns a list of subdocs existing within current document.
Returns 1
if current transaction is of read-write type.
Returns 0
if transaction is read-only.
Gets a reference to shared data type instance at the document root-level,
identified by its name
, which must be a null-terminated UTF-8 compatible string.
Returns a value informing what kind of Yrs shared collection given branch
represents.
Returns either 0 when branch
is null or one of values: Y_ARRAY
, Y_TEXT
, Y_MAP
,
Y_XML_ELEM
, Y_XML_TEXT
.
Releases a callback subscribed via yobserve_deep
function represented by passed
observer parameter.
Returns a null-terminated UTF-8 encoded string representation of an update
binary payload,
encoded using lib0 v1 encoding.
Returns null if update couldn’t be parsed into a lib0 v1 formatting.
Returns a null-terminated UTF-8 encoded string representation of an update
binary payload,
encoded using lib0 v2 encoding.
Returns null if update couldn’t be parsed into a lib0 v2 formatting.
Returns a next sibling of a current XML node, which can be either another
YXmlElement
or a
YXmlText
. Together with
yxmlelem_first_child it may be used to iterate over the direct
children of an XML node (in order to iterate over the nested XML structure use
yxmlelem_tree_walker).
Returns a previous sibling of a current XML node, which can be either another YXmlElement
or a YXmlText
.
Frees all memory-allocated resources bound to a given
YXmlAttr.
Returns a next XML attribute from an iterator
. Attributes are returned in an unordered
manner. Once iterator
reaches the end of attributes collection, a null pointer will be
returned.
Gets or creates a new shared YXmlElement
data type instance as a root-level type of a given
document. This structure can later be accessed using its name
, which must be a null-terminated
UTF-8 compatible string.
Returns an iterator over the YXmlElement
attributes.
Returns a number of child nodes (both YXmlElement
and YXmlText
) living under a current XML
element. This function doesn’t count a recursive nodes, only direct children of a current node.
Returns a sequence of changes produced by sequence component of shared collections (such as
YText
, YXmlText
and XML nodes added to YXmlElement
). len
output parameter is used to
provide information about number of changes produced.
Returns a sequence of changes produced by map component of shared collections.
len
output parameter is used to provide information about number of changes produced.
Returns a path from a root type down to a current shared collection (which can be obtained using
yxmlelem_event_path
function). It can consist of either integer indexes (used by sequence
components) of *char keys (used by map components). len
output parameter is used to provide
information about length of the path.
Returns a pointer to a shared collection, which triggered passed event e
.
Returns a first child node of a current YXmlElement
, or null pointer if current XML node is
empty. Returned value could be either another YXmlElement
or YXmlText
.
Returns an XML child node (either a YXmlElement
or YXmlText
) stored at a given index
of
a current YXmlElement
. Returns null pointer if index
was outside of the bound of current XML
node children.
Returns the value of a current
YXmlElement
, given its name, or a null pointer if not attribute
with such name has been found. Returned pointer is a null-terminated UTF-8 encoded string, which
should be released using
ystring_destroy function.
Inserts an XML attribute described using attr_name
and attr_value
. If another attribute with
the same name already existed, its value will be replaced with a provided one.
Inserts an YXmlElement
as a child of a current node at the given index
and returns its
pointer. Node created this way will have a given name
as its tag (eg. p
for <p></p>
node).
Inserts an YXmlText
as a child of a current node at the given index
and returns its
pointer.
Subscribes a given callback function cb
to changes made by this YXmlElement
instance.
Callbacks are triggered whenever a ytransaction_commit
is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
yxmlelem_unobserve
function.
Returns a parent YXmlElement
of a current node, or null pointer when current YXmlElement
is
a root-level shared data type.
Removes an attribute from a current YXmlElement
, given its name.
Removes a consecutive range of child elements (of specified length) from the current
YXmlElement
, starting at the given index
. Specified range must fit into boundaries of current
XML node children, otherwise this function will panic at runtime.
Converts current YXmlElement
together with its children and attributes into a flat string
representation (no padding) eg. <UNDEFINED><title key="value">sample text</title></UNDEFINED>
.
Return a name (or an XML tag) of a current YXmlElement
. Root-level XML nodes use “UNDEFINED” as
their tag names.
Returns an iterator over a nested recursive structure of a current YXmlElement
, starting from
first of its children. Returned values can be either YXmlElement
or YXmlText
nodes.
Releases resources associated with a current XML tree walker iterator.
Moves current iterator
to a next value (either YXmlElement
or YXmlText
), returning its
pointer or a null, if an iterator
already reached the last successor node.
Releases a callback subscribed via yxmlelem_observe
function represented by passed
observer parameter.
Gets or creates a new shared YXmlElement
data type instance as a root-level type of a given
document. This structure can later be accessed using its name
, which must be a null-terminated
UTF-8 compatible string.
Gets or creates a new shared YXmlText
data type instance as a root-level type of a given
document. This structure can later be accessed using its name
, which must be a null-terminated
UTF-8 compatible string.
Returns an iterator over the YXmlText
attributes.
Returns a sequence of changes produced by sequence component of shared collections (such as
YText
, YXmlText
and XML nodes added to YXmlElement
). len
output parameter is used to
provide information about number of changes produced.
Returns a sequence of changes produced by map component of shared collections.
len
output parameter is used to provide information about number of changes produced.
Returns a path from a root type down to a current shared collection (which can be obtained using
yxmltext_event_path
function). It can consist of either integer indexes (used by sequence
components) of *char keys (used by map components). len
output parameter is used to provide
information about length of the path.
Returns a pointer to a shared collection, which triggered passed event e
.
Wraps an existing piece of text within a range described by index
-len
parameters with
formatting blocks containing provided attrs
metadata. attrs
must be a map-like type.
Returns the value of a current
YXmlText
, given its name, or a null pointer if not attribute
with such name has been found. Returned pointer is a null-terminated UTF-8 encoded string, which
should be released using
ystring_destroy function.
Inserts a null-terminated UTF-8 encoded string a a given
index
.
index
value must be between
0 and a length of a
YXmlText
(inclusive, accordingly to
yxmltext_len return value), otherwise
this function will panic.
Inserts an XML attribute described using attr_name
and attr_value
. If another attribute with
the same name already existed, its value will be replaced with a provided one.
Inserts an embed content given
index
.
index
value must be between 0 and a length of a
YXmlText
(inclusive, accordingly to
ytext_len return value), otherwise this
function will panic.
Returns the length of the YXmlText
string content in bytes (without the null terminator
character)
Subscribes a given callback function cb
to changes made by this YXmlText
instance. Callbacks
are triggered whenever a ytransaction_commit
is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
yxmltext_unobserve
function.
Removes an attribute from a current YXmlText
, given its name.
Removes a range of characters, starting a a given index
. This range must fit within the bounds
of a current YXmlText
, otherwise this function call will fail.
Returns a null-terminated UTF-8 encoded string content of a current YXmlText
shared data type.
Releases a callback subscribed via yxmltext_observe
function represented by passed
observer parameter.