Loading...
Searching...
No Matches
settings_chain.h
Go to the documentation of this file.
1
11#pragma once
13
18
26static inline const SettingsSchema *settings_chain_first(const SettingsSchema *head, const SettingsSchema *tail)
27{
28 return head ? head : tail;
29}
30
41static inline const SettingsSchema *settings_chain_next(const SettingsSchema *schema, const SettingsSchema *tail)
42{
43 if (schema == tail)
44 {
45 return NULL;
46 }
47
48 return schema->companion ? schema->companion : tail;
49}
50
58#define SETTINGS_CHAIN_EACH(schema, head, tail) \
59 for (const SettingsSchema *schema = settings_chain_first((head), (tail)); schema; \
60 schema = settings_chain_next(schema, (tail)))
61
71static inline bool settings_chain_has_field(const SettingsSchema *head, const uint32_t *message_key)
72{
73 for (const SettingsSchema *schema = head; schema; schema = schema->companion)
74 {
75 for (uint8_t i = 0; i < schema->field_count; i++)
76 {
77 if (schema->fields[i].message_key == message_key)
78 {
79 return true;
80 }
81 }
82 }
83
84 return false;
85}
86
96static inline bool settings_chain_has_key(const SettingsSchema *head, uint32_t key)
97{
98 for (const SettingsSchema *schema = head; schema; schema = schema->companion)
99 {
100 if (schema->key == key)
101 {
102 return true;
103 }
104 }
105
106 return false;
107}
108
static bool settings_chain_has_field(const SettingsSchema *head, const uint32_t *message_key)
Whether a schema in the face's own chain has a field on a message key.
Definition settings_chain.h:71
static bool settings_chain_has_key(const SettingsSchema *head, uint32_t key)
Whether a schema in the face's own chain is saved under a persist key.
Definition settings_chain.h:96
static const SettingsSchema * settings_chain_first(const SettingsSchema *head, const SettingsSchema *tail)
Where the walk starts.
Definition settings_chain.h:26
static const SettingsSchema * settings_chain_next(const SettingsSchema *schema, const SettingsSchema *tail)
The schema after this one in the walk.
Definition settings_chain.h:41
The persist API. A per-face SettingField table drives versioned load and save, sanitizing,...
A face's persistence identity.
Definition settings.h:97
const struct SettingsSchema * companion
Next schema in the chain, or NULL.
Definition settings.h:106