10#ifndef __UTILS_YAML_H__
11#define __UTILS_YAML_H__
13#include "zrythm-config.h"
19# include <cyaml/cyaml.h>
30# define YAML_FIELD_IGNORE_OPT(key) \
31 CYAML_FIELD_IGNORE (key, CYAML_FLAG_OPTIONAL)
36# define YAML_FIELD_MAPPING_EMBEDDED(owner, member, schema) \
37 CYAML_FIELD_MAPPING (#member, CYAML_FLAG_DEFAULT, owner, member, schema)
42# define YAML_FIELD_MAPPING_PTR(owner, member, schema) \
43 CYAML_FIELD_MAPPING_PTR (#member, CYAML_FLAG_POINTER, owner, member, schema)
48# define YAML_FIELD_MAPPING_PTR_OPTIONAL(owner, member, schema) \
49 CYAML_FIELD_MAPPING_PTR ( \
50 #member, CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, owner, member, schema)
60# define YAML_FIELD_FIXED_SIZE_PTR_ARRAY_VAR_COUNT(owner, member, schema) \
61 CYAML_FIELD_SEQUENCE_COUNT ( \
62 #member, CYAML_FLAG_DEFAULT, owner, member, num_##member, &schema, 0, \
72# define YAML_FIELD_FIXED_SIZE_PTR_ARRAY(owner, member, schema, size) \
73 CYAML_FIELD_SEQUENCE_FIXED ( \
74 #member, CYAML_FLAG_DEFAULT, owner, member, &schema, size)
86# define YAML_FIELD_DYN_PTR_ARRAY_VAR_COUNT(owner, member, schema) \
87 CYAML_FIELD_SEQUENCE_COUNT ( \
88 #member, CYAML_FLAG_POINTER, owner, member, num_##member, &schema, 0, \
99# define YAML_FIELD_DYN_FIXED_SIZE_PTR_ARRAY( \
100 owner, member, schema, fixed_size) \
101 CYAML_FIELD_SEQUENCE_FIXED ( \
102 #member, CYAML_FLAG_POINTER, owner, member, &schema, fixed_size)
118# define YAML_FIELD_DYN_ARRAY_VAR_COUNT(owner, member, schema) \
119 CYAML_FIELD_SEQUENCE_COUNT ( \
120 #member, CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, owner, member, \
121 num_##member, &schema, 0, CYAML_UNLIMITED)
133# define YAML_FIELD_DYN_PTR_ARRAY_VAR_COUNT_OPT(owner, member, schema) \
134 YAML_FIELD_DYN_ARRAY_VAR_COUNT (owner, member, schema)
144# define YAML_FIELD_DYN_FIXED_SIZE_PTR_ARRAY_OPT( \
145 owner, member, schema, fixed_size) \
146 CYAML_FIELD_SEQUENCE_FIXED ( \
147 #member, CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, owner, member, \
164# define YAML_FIELD_DYN_ARRAY_VAR_COUNT_PRIMITIVES(owner, member, schema) \
165 YAML_FIELD_DYN_ARRAY_VAR_COUNT (owner, member, schema)
170# define YAML_FIELD_SEQUENCE_FIXED(owner, member, schema, size) \
171 CYAML_FIELD_SEQUENCE_FIXED ( \
172 #member, CYAML_FLAG_DEFAULT, owner, member, &schema, size)
174# define YAML_FIELD_INT(owner, member) \
175 CYAML_FIELD_INT (#member, CYAML_FLAG_DEFAULT, owner, member)
177# define YAML_FIELD_INT_OPT(owner, member) \
178 CYAML_FIELD_INT (#member, CYAML_FLAG_OPTIONAL, owner, member)
180# define YAML_FIELD_UINT(owner, member) \
181 CYAML_FIELD_UINT (#member, CYAML_FLAG_DEFAULT, owner, member)
183# define YAML_FIELD_FLOAT(owner, member) \
184 CYAML_FIELD_FLOAT (#member, CYAML_FLAG_DEFAULT, owner, member)
186# define YAML_FIELD_STRING_PTR(owner, member) \
187 CYAML_FIELD_STRING_PTR ( \
188 #member, CYAML_FLAG_POINTER, owner, member, 0, CYAML_UNLIMITED)
190# define YAML_FIELD_STRING_PTR_OPTIONAL(owner, member) \
191 CYAML_FIELD_STRING_PTR ( \
192 #member, CYAML_FLAG_POINTER | CYAML_FLAG_OPTIONAL, owner, member, 0, \
195# define YAML_FIELD_ENUM(owner, member, strings) \
197 #member, CYAML_FLAG_DEFAULT, owner, member, strings, \
198 CYAML_ARRAY_LEN (strings))
200# define YAML_FIELD_BITFIELD(owner, member, bitvals) \
201 CYAML_FIELD_BITFIELD ( \
202 #member, CYAML_FLAG_DEFAULT, owner, member, bitvals, \
203 CYAML_ARRAY_LEN (bitvals))
208# define YAML_VALUE_PTR(cc, fields_schema) \
209 CYAML_VALUE_MAPPING (CYAML_FLAG_POINTER, cc, fields_schema)
215# define YAML_VALUE_PTR_NULLABLE(cc, fields_schema) \
216 CYAML_VALUE_MAPPING (CYAML_FLAG_POINTER_NULL_STR, cc, fields_schema)
224# define YAML_VALUE_DEFAULT(cc, fields_schema) \
225 CYAML_VALUE_MAPPING (CYAML_FLAG_DEFAULT, cc, fields_schema)
227# define YAML_BITVAL(_name, _offset) \
229 .name = _name, .offset = _offset, .bits = 1 \
239char * yaml_serialize (
241 const cyaml_schema_value_t * schema,
245void * yaml_deserialize (
247 const cyaml_schema_value_t * schema,
251yaml_print (
void * data, const cyaml_schema_value_t * schema);
264yaml_set_log_level (cyaml_log_t level);
267yaml_get_cyaml_config (cyaml_config_t * cyaml_config);
269static const cyaml_schema_value_t int_schema = {
270 CYAML_VALUE_INT (CYAML_FLAG_DEFAULT,
int),
273static const cyaml_schema_value_t unsigned_int_schema = {
274 CYAML_VALUE_UINT (CYAML_FLAG_DEFAULT,
unsigned int),
277static const cyaml_schema_value_t uint8_t_schema = {
278 CYAML_VALUE_UINT (CYAML_FLAG_DEFAULT, typeof (uint8_t)),
281static const cyaml_schema_value_t float_schema = {
282 CYAML_VALUE_FLOAT (CYAML_FLAG_DEFAULT, typeof (
float)),
285static const cyaml_schema_field_t gdk_rgba_fields_schema[] = {
286 CYAML_FIELD_FLOAT (
"red", CYAML_FLAG_DEFAULT, GdkRGBA, red),
287 CYAML_FIELD_FLOAT (
"green", CYAML_FLAG_DEFAULT, GdkRGBA, green),
288 CYAML_FIELD_FLOAT (
"blue", CYAML_FLAG_DEFAULT, GdkRGBA, blue),
289 CYAML_FIELD_FLOAT (
"alpha", CYAML_FLAG_DEFAULT, GdkRGBA, alpha),
294static const cyaml_schema_value_t gdk_rgba_schema_default = {
295 YAML_VALUE_DEFAULT (GdkRGBA, gdk_rgba_fields_schema),
298static const cyaml_schema_value_t gdk_rgba_schema = {
299 YAML_VALUE_PTR (GdkRGBA, gdk_rgba_fields_schema),
302typedef enum YamlDummyEnum
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.