Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SlotFunctions.hpp
00001 // ArduinoJson - arduinojson.org 00002 // Copyright Benoit Blanchon 2014-2021 00003 // MIT License 00004 00005 #pragma once 00006 00007 #include <ArduinoJson/Polyfills/assert.hpp> 00008 #include <ArduinoJson/Variant/VariantData.hpp> 00009 00010 namespace ARDUINOJSON_NAMESPACE { 00011 00012 template <typename TAdaptedString> 00013 inline bool slotSetKey(VariantSlot* var, TAdaptedString key, MemoryPool* pool) { 00014 if (!var) 00015 return false; 00016 return slotSetKey(var, key, pool, typename TAdaptedString::storage_policy()); 00017 } 00018 00019 template <typename TAdaptedString> 00020 inline bool slotSetKey(VariantSlot* var, TAdaptedString key, MemoryPool* pool, 00021 storage_policies::decide_at_runtime) { 00022 if (key.isStatic()) { 00023 return slotSetKey(var, key, pool, storage_policies::store_by_address()); 00024 } else { 00025 return slotSetKey(var, key, pool, storage_policies::store_by_copy()); 00026 } 00027 } 00028 00029 template <typename TAdaptedString> 00030 inline bool slotSetKey(VariantSlot* var, TAdaptedString key, MemoryPool*, 00031 storage_policies::store_by_address) { 00032 ARDUINOJSON_ASSERT(var); 00033 var->setKey(key.data(), storage_policies::store_by_address()); 00034 return true; 00035 } 00036 00037 template <typename TAdaptedString> 00038 inline bool slotSetKey(VariantSlot* var, TAdaptedString key, MemoryPool* pool, 00039 storage_policies::store_by_copy) { 00040 const char* dup = pool->saveString(key); 00041 if (!dup) 00042 return false; 00043 ARDUINOJSON_ASSERT(var); 00044 var->setKey(dup, storage_policies::store_by_copy()); 00045 return true; 00046 } 00047 00048 inline size_t slotSize(const VariantSlot* var) { 00049 size_t n = 0; 00050 while (var) { 00051 n++; 00052 var = var->next(); 00053 } 00054 return n; 00055 } 00056 00057 inline VariantData* slotData(VariantSlot* slot) { 00058 return reinterpret_cast<VariantData*>(slot); 00059 } 00060 } // namespace ARDUINOJSON_NAMESPACE
Generated on Wed Jul 13 2022 01:10:36 by
1.7.2