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.
CollectionData.hpp
00001 // ArduinoJson - arduinojson.org 00002 // Copyright Benoit Blanchon 2014-2021 00003 // MIT License 00004 00005 #pragma once 00006 00007 #include <ArduinoJson/Namespace.hpp> 00008 #include <ArduinoJson/Polyfills/assert.hpp> 00009 00010 #include <stddef.h> // size_t 00011 00012 namespace ARDUINOJSON_NAMESPACE { 00013 00014 class MemoryPool; 00015 class VariantData; 00016 class VariantSlot; 00017 00018 class CollectionData { 00019 VariantSlot *_head; 00020 VariantSlot *_tail; 00021 00022 public: 00023 // Must be a POD! 00024 // - no constructor 00025 // - no destructor 00026 // - no virtual 00027 // - no inheritance 00028 00029 // Array only 00030 00031 VariantData *addElement(MemoryPool *pool); 00032 00033 VariantData *getElement(size_t index) const; 00034 00035 VariantData *getOrAddElement(size_t index, MemoryPool *pool); 00036 00037 void removeElement(size_t index); 00038 00039 bool equalsArray(const CollectionData &other) const; 00040 00041 // Object only 00042 00043 template <typename TAdaptedString> 00044 VariantData *addMember(TAdaptedString key, MemoryPool *pool); 00045 00046 template <typename TAdaptedString> 00047 VariantData *getMember(TAdaptedString key) const; 00048 00049 template <typename TAdaptedString> 00050 VariantData *getOrAddMember(TAdaptedString key, MemoryPool *pool); 00051 00052 template <typename TAdaptedString> 00053 void removeMember(TAdaptedString key) { 00054 removeSlot(getSlot(key)); 00055 } 00056 00057 template <typename TAdaptedString> 00058 bool containsKey(const TAdaptedString &key) const; 00059 00060 bool equalsObject(const CollectionData &other) const; 00061 00062 // Generic 00063 00064 void clear(); 00065 size_t memoryUsage() const; 00066 size_t nesting() const; 00067 size_t size() const; 00068 00069 VariantSlot *addSlot(MemoryPool *); 00070 void removeSlot(VariantSlot *slot); 00071 00072 bool copyFrom(const CollectionData &src, MemoryPool *pool); 00073 00074 VariantSlot *head() const { 00075 return _head; 00076 } 00077 00078 void movePointers(ptrdiff_t stringDistance, ptrdiff_t variantDistance); 00079 00080 private: 00081 VariantSlot *getSlot(size_t index) const; 00082 00083 template <typename TAdaptedString> 00084 VariantSlot *getSlot(TAdaptedString key) const; 00085 00086 VariantSlot *getPreviousSlot(VariantSlot *) const; 00087 }; 00088 } // namespace ARDUINOJSON_NAMESPACE
Generated on Wed Jul 13 2022 01:10:36 by
1.7.2