From 950f52db41c3c2dfeae24045c0a41c2a6c968af7 Mon Sep 17 00:00:00 2001 From: Jochen Vothknecht <jochen3120@gmail.com> Date: Wed, 15 Jun 2022 08:13:32 +0200 Subject: [PATCH] Adding copy and move API --- CLC-qthing/SiliconTorch/NVSExplorer.cpp | 47 +++++++++++++++++++++++++ CLC-qthing/SiliconTorch/NVSExplorer.hpp | 7 ++++ 2 files changed, 54 insertions(+) diff --git a/CLC-qthing/SiliconTorch/NVSExplorer.cpp b/CLC-qthing/SiliconTorch/NVSExplorer.cpp index dfaf3df..cac14fb 100644 --- a/CLC-qthing/SiliconTorch/NVSExplorer.cpp +++ b/CLC-qthing/SiliconTorch/NVSExplorer.cpp @@ -1183,6 +1183,53 @@ namespace SiliconTorch { } + + bool NVSExplorer::copyKey(const str& nameSpace, const str& keyFrom, const str& keyTo) { + + return false; // TODO: implementation! + + } + + bool NVSExplorer::copyKey(const str& nsFrom, const str& keyFrom, const str& nsTo, const str& keyTo) { + + nvs_type_t entryType = getType(nsFrom, keyFrom); + + if (entryType == NVS_TYPE_ANY) // key not found + return false; + + if (entryType == NVS_TYPE_BLOB) // BLOBs are currently unsupported + return false; + + + u64 intStorage = 0; + str strStorage = ""; + + + return false; + + } + + + bool NVSExplorer::moveKey(const str& nameSpace, const str& keyFrom, const str& keyTo) { + + if ( ! copyKey(nameSpace, keyFrom, keyTo) ) + return false; + + return removeKey(nameSpace, keyFrom); + } + + bool NVSExplorer::moveKey(const str& nsFrom, const str& keyFrom, const str& nsTo, const str& keyTo) { + + if ( ! copyKey(nsFrom, keyFrom, nsTo, keyTo) ) + return false; + + return removeKey(nsFrom, keyFrom); + } + + + + + str NVSExplorer::deviceTopic(const str& suffix) { return str(DEVICE_NAMESPACE + "NVS/") + suffix; } diff --git a/CLC-qthing/SiliconTorch/NVSExplorer.hpp b/CLC-qthing/SiliconTorch/NVSExplorer.hpp index 593801b..c163447 100644 --- a/CLC-qthing/SiliconTorch/NVSExplorer.hpp +++ b/CLC-qthing/SiliconTorch/NVSExplorer.hpp @@ -87,6 +87,13 @@ namespace SiliconTorch { bool setString(const str& nameSpace, const str& key, const str& value); + /* TODO: implement! */ bool copyKey(const str& nameSpace, const str& keyFrom, const str& keyTo); // copies key inside namespace + /* TODO: implement! */ bool copyKey(const str& nsFrom, const str& keyFrom, const str& nsTo, const str& keyTo); // copies key to another namespace + + /* TODO: test thoroughly! */ bool moveKey(const str& nameSpace, const str& keyFrom, const str& keyTo); // moves key inside namespace + /* TODO: test thoroughly! */ bool moveKey(const str& nsFrom, const str& keyFrom, const str& nsTo, const str& keyTo); // moves key to another namespace + + str type2str(nvs_type_t typ); nvs_type_t getType(const str& nameSpace, const str& key); str getTypeStr(const str& nameSpace, const str& key); -- GitLab