CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
BackupImport.h
Go to the documentation of this file.
1#pragma once
2
3#include "cdc_core/IModule.h"
4#include "cJSON.h"
5
6namespace cdc::ui {
7
18using BackupEntryHandler = bool (*)(const cJSON* entry, void* user);
19
34 BackupEntryHandler handler,
35 void* user) {
37 if (!array || !handler || !cJSON_IsArray(array)) return result;
38
39 const cJSON* entry = nullptr;
40 cJSON_ArrayForEach(entry, array) {
41 if (handler(entry, user)) {
42 result.imported++;
43 } else {
44 result.failed++;
45 }
46 }
47 return result;
48}
49
50} // namespace cdc::ui
Centralized key-code constants for cdc_views.
Definition IModule.h:8
cdc::core::IModule::BackupResult importJsonArray(const cJSON *array, BackupEntryHandler handler, void *user)
Iterates a JSON backup array best-effort and tallies the outcome.
bool(*)(const cJSON *entry, void *user) BackupEntryHandler
Per-entry restore callback for importJsonArray().
Per-module restore outcome reported by importBackup().
Definition IModule.h:85
uint16_t failed
Records skipped due to errors.
Definition IModule.h:87
uint16_t imported
Records restored successfully.
Definition IModule.h:86