RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
style_json.h File Reference

Allocation-free schema-3 JSON style and Base16 palette codecs. More...

#include "style.h"
#include "style_palette.h"
#include "style_ext.h"

Functions

int rmgui_style_decode_json (const char *text, size_t length, size_t max_bytes, rmgui_style_snapshot_t *out, char *error, size_t error_cap)
 Strict RFC 8259 input, with schema:3 required.
size_t rmgui_style_encode_json (const rmgui_style_snapshot_t *snapshot, char *out, size_t capacity)
 Canonical complete schema, including authored token references.
int rmgui_style_palette_decode_json (const char *text, size_t length, size_t max_bytes, rmgui_style_palette_t *out, char *error, size_t error_cap)
 Palette input requires all sixteen base00..base0f RGBA arrays in "palette"; optional "roles" and "syntax" objects contain literal RGBA overlays.
size_t rmgui_style_palette_encode_json (const rmgui_style_palette_t *palette, char *out, size_t capacity)
int rmgui_style_decode_with_palette_json (const char *text, size_t length, size_t max_bytes, const rmgui_style_palette_t *palette, rmgui_style_snapshot_t *out, rmgui_style_palette_refs_t *refs_out, char *error, size_t error_cap)
 "scheme":"user" selects effective palette roles.
size_t rmgui_style_encode_with_palette_json (const rmgui_style_snapshot_t *snapshot, const rmgui_style_palette_refs_t *refs, char *out, size_t capacity)
int rmgui_style_decode_with_ext_json (const char *text, size_t length, size_t max_bytes, rmgui_style_snapshot_t *out, rmgui_style_ext_t *ext, rmgui_style_ext_t *scratch, char *error, size_t error_cap)
 Extension declarations are pre-registered in ext.
size_t rmgui_style_encode_with_ext_json (const rmgui_style_snapshot_t *snapshot, const rmgui_style_ext_t *ext, char *out, size_t capacity)

Detailed Description

Allocation-free schema-3 JSON style and Base16 palette codecs.

Function Documentation

◆ rmgui_style_decode_json()

int rmgui_style_decode_json ( const char * text,
size_t length,
size_t max_bytes,
rmgui_style_snapshot_t * out,
char * error,
size_t error_cap )

Strict RFC 8259 input, with schema:3 required.

Omitted declarations use the builtin. max_bytes=0 selects RMGUI_STYLE_DEFAULT_MAX_BYTES. Errors include one-based line/byte-column and are NUL-terminated when error_cap permits. Failure returns -1 without changing out; success returns 0. Input is borrowed and must remain immutable and disjoint from outputs throughout the call.

◆ rmgui_style_encode_json()

size_t rmgui_style_encode_json ( const rmgui_style_snapshot_t * snapshot,
char * out,
size_t capacity )

Canonical complete schema, including authored token references.

snprintf length excluding NUL; a nonzero capacity always receives a terminated prefix. Invalid arguments/snapshot return 0 and an empty output.

◆ rmgui_style_palette_decode_json()

int rmgui_style_palette_decode_json ( const char * text,
size_t length,
size_t max_bytes,
rmgui_style_palette_t * out,
char * error,
size_t error_cap )

Palette input requires all sixteen base00..base0f RGBA arrays in "palette"; optional "roles" and "syntax" objects contain literal RGBA overlays.

The schema member is required. No KDL implementation is linked by this API.

◆ rmgui_style_palette_encode_json()

size_t rmgui_style_palette_encode_json ( const rmgui_style_palette_t * palette,
char * out,
size_t capacity )

◆ rmgui_style_decode_with_palette_json()

int rmgui_style_decode_with_palette_json ( const char * text,
size_t length,
size_t max_bytes,
const rmgui_style_palette_t * palette,
rmgui_style_snapshot_t * out,
rmgui_style_palette_refs_t * refs_out,
char * error,
size_t error_cap )

"scheme":"user" selects effective palette roles.

Color tokens may name "$base00".."$base0f" or their matching "$role.background", etc. refs_out is optional and preserves those identities; palette is borrowed. Failure changes neither output. Other schema references retain the usual "$spacing.md" / "$colors.accent" spelling.

◆ rmgui_style_encode_with_palette_json()

size_t rmgui_style_encode_with_palette_json ( const rmgui_style_snapshot_t * snapshot,
const rmgui_style_palette_refs_t * refs,
char * out,
size_t capacity )

◆ rmgui_style_decode_with_ext_json()

int rmgui_style_decode_with_ext_json ( const char * text,
size_t length,
size_t max_bytes,
rmgui_style_snapshot_t * out,
rmgui_style_ext_t * ext,
rmgui_style_ext_t * scratch,
char * error,
size_t error_cap )

Extension declarations are pre-registered in ext.

The optional "classes" object maps class names to {"values":{base properties},"states":{...}}. State keys are single names (hover, pressed, disabled, focused, selected, default, inactive); each state object maps property names to values. Enums use descriptor names; lengths/integers use integral numbers. Both out and ext are transactional. scratch is initialized, disjoint caller storage with sufficient capacities; it may be modified on failure. All descriptor strings are borrowed from ext, never from input.

◆ rmgui_style_encode_with_ext_json()

size_t rmgui_style_encode_with_ext_json ( const rmgui_style_snapshot_t * snapshot,
const rmgui_style_ext_t * ext,
char * out,
size_t capacity )