CToon C 0.6.1
A C99 TOON/JSON serialization library
Loading...
Searching...
No Matches
ctoon_ptr_ctx Struct Reference

#include <ctoon.h>

Collaboration diagram for ctoon_ptr_ctx:

Data Fields

ctoon_mut_valctn
 
ctoon_mut_valpre
 
ctoon_mut_valold
 

Detailed Description

A context for TOON pointer operation.

This struct stores the context of TOON Pointer operation result. The struct can be used with three helper functions: ctx_append(), ctx_replace(), and ctx_remove(), which perform the corresponding operations on the container without re-parsing the TOON Pointer.

For example:

// doc before: {"a":[0,1,null]}
// ptr: "/a/2"
val = ctoon_mut_doc_ptr_getx(doc, ptr, strlen(ptr), &ctx, &err);
if (ctoon_is_null(val)) {
}
// doc after: {"a":[0,1]}
static unsigned char ctoon_ptr_ctx_remove(ctoon_ptr_ctx *ctx)
Definition ctoon.h:7762
static unsigned char ctoon_is_null(ctoon_val *val)
Definition ctoon.h:4920
static ctoon_mut_val * ctoon_mut_doc_ptr_getx(ctoon_mut_doc *doc, const char *ptr, size_t len, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err)
Definition ctoon.h:7256

Definition at line 3891 of file ctoon.h.

Field Documentation

◆ ctn

ctoon_mut_val* ctoon_ptr_ctx::ctn

The container (parent) of the target value. It can be either an array or an object. If the target location has no value, but all its parent containers exist, and the target location can be used to insert a new value, then ctn is the parent container of the target location. Otherwise, ctn is NULL.

Definition at line 3899 of file ctoon.h.

◆ old

ctoon_mut_val* ctoon_ptr_ctx::old

The removed value if the operation is set, replace or remove. It can be used to restore the original state of the document if needed.

Definition at line 3913 of file ctoon.h.

◆ pre

ctoon_mut_val* ctoon_ptr_ctx::pre

The previous sibling of the target value. It can be either a value in an array or a key in an object. As the container is a circular linked list of elements, pre is the previous node of the target value. If the operation is add or set, then pre is the previous node of the new value, not the original target value. If the target value does not exist, pre is NULL.

Definition at line 3908 of file ctoon.h.


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