Utility types: Optional polyfill, JSON Schema normalization, Ticker.
More...
|
| class | Ticker |
| | Unified timing class for periodic, one-shot, and calendar-aligned scheduling. More...
|
|
| json | NormalizeSchema (json schema) |
| | Wraps a minimal properties-only JSON object into a full JSON Schema.
|
| std::string | StrPrintf (const char *fmt,...) |
| | Builds a std::string using printf-style formatting.
|
Utility types: Optional polyfill, JSON Schema normalization, Ticker.
◆ NormalizeSchema()
| json foresthub::util::NormalizeSchema |
( |
json | schema | ) |
|
Wraps a minimal properties-only JSON object into a full JSON Schema.
Handles four input formats:
- Empty/null → returns empty object.
- Already has "type" → returned unchanged.
- Has "properties" but no "type" → adds "type": "object".
- Otherwise → treated as a bare property map, wrapped into {"type":"object","properties":...}.
- Parameters
-
| schema | Raw JSON schema in any of the supported formats. |
- Returns
- Normalized JSON Schema object.
◆ StrPrintf()
| std::string foresthub::util::StrPrintf |
( |
const char * | fmt, |
|
|
| ... ) |
|
inline |
Builds a std::string using printf-style formatting.
Uses a two-pass vsnprintf approach: first measures the exact output size, then allocates once and writes. This avoids heap fragmentation from repeated std::string concatenation on memory-constrained embedded devices.
- Warning
- The format string must not contain untrusted user input. Pass user data as arguments, never as the format string.
- Parameters
-
| fmt | printf-style format string |
| ... | arguments matching the format specifiers |
- Returns
- formatted std::string (empty on encoding error)