CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
settings_private.h
1#pragma once
2
3#include "cx/settings/settingshashnode.h"
4#include "cx/settings/settingstree.h"
5#include "settings.h"
6
7#include <cx/container.h>
10#include <cx/time.h>
11
12#define SETTINGS_DEFAULT_FLUSH_INTERVAL (timeS(30))
13
14void _setsThreadCheck(void);
15void _setsThreadWatch(SSDNode* sets);
16void _setsThreadForget(SSDNode* sets);
17bool _setsWriteTree(SSDNode* root, SettingsTree* tree, SSDLockState* lstate);
18
19_meta_inline bool _setsWriteBoundVar(SettingsBind* bind, stype styp, stgeneric val)
20{
21 // for strings, destroy destination first to prevent leaks
22 if (stEq(styp, stType(string)))
23 strDestroy(&bind->var->st_string);
24 return _stConvert(bind->type, bind->var, styp, NULL, val, 0);
25}
26
27#define _setsBCacheSize(btype) (stHasFlag(btype, PassPtr) ? sizeof(void*) : stGetSize(btype))
28_meta_inline void _setsUpdateBindCache(SettingsBind* bind)
29{
30 // binding cache is a snapshot of the bound variable, but NOT the data or anything that needs
31 // a heavyweight copy. I.e. for strings it's just the pointer. This means we won't detect
32 // if a string is changed in-memory without reallocating it, but avoids an extra string
33 // copy/compare every time setsGet is called.
34
35 memcpy(&bind->cache, bind->var, _setsBCacheSize(bind->type));
36}
Generic type-safe containers with runtime type system integration.
void strDestroy(strhandle ps)
#define stType(name)
Definition stype.h:822
bool stEq(stype sta, stype stb)
Definition stype.h:537
Time and clock functions.
Settings management with SSD trees.
Semi-Structured Data (SSD) tree public API.
Core stream buffer implementation for efficient data streaming.