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.
ObjectIterator.hpp
00001 // ArduinoJson - arduinojson.org 00002 // Copyright Benoit Blanchon 2014-2021 00003 // MIT License 00004 00005 #pragma once 00006 00007 #include <ArduinoJson/Object/Pair.hpp> 00008 #include <ArduinoJson/Variant/SlotFunctions.hpp> 00009 00010 namespace ARDUINOJSON_NAMESPACE { 00011 00012 class PairPtr { 00013 public: 00014 PairPtr(MemoryPool *pool, VariantSlot *slot) : _pair(pool, slot) {} 00015 00016 const Pair *operator->() const { 00017 return &_pair; 00018 } 00019 00020 const Pair &operator*() const { 00021 return _pair; 00022 } 00023 00024 private: 00025 Pair _pair; 00026 }; 00027 00028 class ObjectIterator { 00029 public: 00030 ObjectIterator() : _slot(0) {} 00031 00032 explicit ObjectIterator(MemoryPool *pool, VariantSlot *slot) 00033 : _pool(pool), _slot(slot) {} 00034 00035 Pair operator*() const { 00036 return Pair(_pool, _slot); 00037 } 00038 PairPtr operator->() { 00039 return PairPtr(_pool, _slot); 00040 } 00041 00042 bool operator==(const ObjectIterator &other) const { 00043 return _slot == other._slot; 00044 } 00045 00046 bool operator!=(const ObjectIterator &other) const { 00047 return _slot != other._slot; 00048 } 00049 00050 ObjectIterator &operator++() { 00051 _slot = _slot->next(); 00052 return *this; 00053 } 00054 00055 ObjectIterator &operator+=(size_t distance) { 00056 _slot = _slot->next(distance); 00057 return *this; 00058 } 00059 00060 VariantSlot *internal() { 00061 return _slot; 00062 } 00063 00064 private: 00065 MemoryPool *_pool; 00066 VariantSlot *_slot; 00067 }; 00068 00069 class PairConstPtr { 00070 public: 00071 PairConstPtr(const VariantSlot *slot) : _pair(slot) {} 00072 00073 const PairConst *operator->() const { 00074 return &_pair; 00075 } 00076 00077 const PairConst &operator*() const { 00078 return _pair; 00079 } 00080 00081 private: 00082 PairConst _pair; 00083 }; 00084 00085 class ObjectConstIterator { 00086 public: 00087 ObjectConstIterator() : _slot(0) {} 00088 00089 explicit ObjectConstIterator(const VariantSlot *slot) : _slot(slot) {} 00090 00091 PairConst operator*() const { 00092 return PairConst(_slot); 00093 } 00094 PairConstPtr operator->() { 00095 return PairConstPtr(_slot); 00096 } 00097 00098 bool operator==(const ObjectConstIterator &other) const { 00099 return _slot == other._slot; 00100 } 00101 00102 bool operator!=(const ObjectConstIterator &other) const { 00103 return _slot != other._slot; 00104 } 00105 00106 ObjectConstIterator &operator++() { 00107 _slot = _slot->next(); 00108 return *this; 00109 } 00110 00111 ObjectConstIterator &operator+=(size_t distance) { 00112 _slot = _slot->next(distance); 00113 return *this; 00114 } 00115 00116 const VariantSlot *internal() { 00117 return _slot; 00118 } 00119 00120 private: 00121 const VariantSlot *_slot; 00122 }; 00123 } // namespace ARDUINOJSON_NAMESPACE
Generated on Wed Jul 13 2022 01:10:36 by
1.7.2