Add CopiedString and LinkedString

This commit is contained in:
Benoit Blanchon
2021-11-22 09:40:20 +01:00
parent b06bbd9d2a
commit 62f9b94ab1
13 changed files with 83 additions and 50 deletions

View File

@@ -8,6 +8,7 @@
#include <ArduinoJson/Polyfills/limits.hpp>
#include <ArduinoJson/Polyfills/type_traits.hpp>
#include <ArduinoJson/Strings/StoragePolicy.hpp>
#include <ArduinoJson/Strings/StoredString.hpp>
#include <ArduinoJson/Variant/VariantContent.hpp>
namespace ARDUINOJSON_NAMESPACE {
@@ -77,16 +78,16 @@ class VariantSlot {
_next = VariantSlotDiff(slot - this);
}
void setKey(const char* k, storage_policies::store_by_copy) {
ARDUINOJSON_ASSERT(k != NULL);
void setKey(CopiedString k) {
ARDUINOJSON_ASSERT(k);
_flags |= OWNED_KEY_BIT;
_key = k;
_key = k.c_str();
}
void setKey(const char* k, storage_policies::store_by_address) {
ARDUINOJSON_ASSERT(k != NULL);
void setKey(LinkedString k) {
ARDUINOJSON_ASSERT(k);
_flags &= VALUE_MASK;
_key = k;
_key = k.c_str();
}
const char* key() const {