Lite³
A JSON-Compatible Zero-Copy Serialization Format
Loading...
Searching...
No Matches
Object Get

Get value from object by key. More...

Macros

#define lite3_ctx_get(ctx, ofs, key, out)
 Get value from object.
 
#define lite3_ctx_get_bool(ctx, ofs, key, out)
 Get boolean value by key.
 
#define lite3_ctx_get_i64(ctx, ofs, key, out)
 Get integer value by key.
 
#define lite3_ctx_get_f64(ctx, ofs, key, out)
 Get floating point value by key.
 
#define lite3_ctx_get_bytes(ctx, ofs, key, out)
 Get bytes value by key.
 
#define lite3_ctx_get_str(ctx, ofs, key, out)
 Get string value by key.
 
#define lite3_ctx_get_obj(ctx, ofs, key, out)
 Get object by key.
 
#define lite3_ctx_get_arr(ctx, ofs, key, out)
 Get array by key.
 

Detailed Description

Get value from object by key.

The ofs (offset) field is used to target an object or array inside the Lite³ buffer. To target the root-level object/array, use ofs == 0.

Returns
  • Returns 0 on success
  • Returns < 0 on error
Warning
Read-only operations are thread-safe. This includes all lite3_get_xxx() funtions. Mixing reads and writes however is not thread-safe.

Macro Definition Documentation

◆ lite3_ctx_get

#define lite3_ctx_get (   ctx,
  ofs,
  key,
  out 
)

Get value from object.

Unlike other lite3_ctx_get_xxx() functions, this function does not get a specific type. Instead, it produces a generic lite3_val pointer, which points to a value inside the Lite³ buffer. This can be useful in cases where you don't know the exact type of a value beforehand. See lite3_val functions.

Parameters
[in]ctx(lite3_ctx *) context pointer
[in]ofs(size_t) start offset (0 == root)
[in]key(const char *) key
[out]out(lite3_val *) opaque value pointer
Returns
0 on success
< 0 on error

Definition at line 1563 of file lite3_context_api.h.

◆ lite3_ctx_get_arr

#define lite3_ctx_get_arr (   ctx,
  ofs,
  key,
  out 
)

Get array by key.

Parameters
[in]ctx(lite3_ctx *) context pointer
[in]ofs(size_t) start offset (0 == root)
[in]key(const char *) key
[out]out(size_t *) array offset
Returns
0 on success
< 0 on error

Definition at line 1799 of file lite3_context_api.h.

◆ lite3_ctx_get_bool

#define lite3_ctx_get_bool (   ctx,
  ofs,
  key,
  out 
)

Get boolean value by key.

Parameters
[in]ctx(lite3_ctx *) context pointer
[in]ofs(size_t) start offset (0 == root)
[in]key(const char *) key
[out]out(bool *) boolean value
Returns
0 on success
< 0 on error

Definition at line 1584 of file lite3_context_api.h.

◆ lite3_ctx_get_bytes

#define lite3_ctx_get_bytes (   ctx,
  ofs,
  key,
  out 
)

Get bytes value by key.

Parameters
[in]ctx(lite3_ctx *) context pointer
[in]ofs(size_t) start offset (0 == root)
[in]key(const char *) key
[out]out(lite3_bytes *) bytes value
Returns
0 on success
< 0 on error

Definition at line 1686 of file lite3_context_api.h.

◆ lite3_ctx_get_f64

#define lite3_ctx_get_f64 (   ctx,
  ofs,
  key,
  out 
)

Get floating point value by key.

Parameters
[in]ctx(lite3_ctx *) context pointer
[in]ofs(size_t) start offset (0 == root)
[in]key(const char *) key
[out]out(double *) floating point value
Returns
0 on success
< 0 on error

Definition at line 1652 of file lite3_context_api.h.

◆ lite3_ctx_get_i64

#define lite3_ctx_get_i64 (   ctx,
  ofs,
  key,
  out 
)

Get integer value by key.

Parameters
[in]ctx(lite3_ctx *) context pointer
[in]ofs(size_t) start offset (0 == root)
[in]key(const char *) key
[out]out(int64_t *) integer value
Returns
0 on success
< 0 on error

Definition at line 1618 of file lite3_context_api.h.

◆ lite3_ctx_get_obj

#define lite3_ctx_get_obj (   ctx,
  ofs,
  key,
  out 
)

Get object by key.

Parameters
[in]ctx(lite3_ctx *) context pointer
[in]ofs(size_t) start offset (0 == root)
[in]key(const char *) key
[out]out(size_t *) object offset
Returns
0 on success
< 0 on error

Definition at line 1765 of file lite3_context_api.h.

◆ lite3_ctx_get_str

#define lite3_ctx_get_str (   ctx,
  ofs,
  key,
  out 
)

Get string value by key.

Parameters
[in]ctx(lite3_ctx *) context pointer
[in]ofs(size_t) start offset (0 == root)
[in]key(const char *) key
[out]out(lite3_str *) string value
Returns
0 on success
< 0 on error

Definition at line 1725 of file lite3_context_api.h.