MCPcopy Create free account
hub / github.com/blinker-iot/blinker-library / ArrayRef

Class ArrayRef

src/modules/ArduinoJson/ArduinoJson/Array/ArrayRef.hpp:94–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92};
93
94class ArrayRef : public ArrayRefBase<CollectionData>,
95 public ArrayShortcuts<ArrayRef>,
96 public Visitable {
97 typedef ArrayRefBase<CollectionData> base_type;
98
99 public:
100 typedef ArrayIterator iterator;
101
102 FORCE_INLINE ArrayRef() : base_type(0), _pool(0) {}
103 FORCE_INLINE ArrayRef(MemoryPool* pool, CollectionData* data)
104 : base_type(data), _pool(pool) {}
105
106 operator VariantRef() {
107 void* data = _data; // prevent warning cast-align
108 return VariantRef(_pool, reinterpret_cast<VariantData*>(data));
109 }
110
111 operator ArrayConstRef() const {
112 return ArrayConstRef(_data);
113 }
114
115 VariantRef addElement() const {
116 return VariantRef(_pool, arrayAdd(_data, _pool));
117 }
118
119 FORCE_INLINE iterator begin() const {
120 if (!_data)
121 return iterator();
122 return iterator(_pool, _data->head());
123 }
124
125 FORCE_INLINE iterator end() const {
126 return iterator();
127 }
128
129 // Copy a ArrayRef
130 FORCE_INLINE bool set(ArrayConstRef src) const {
131 if (!_data || !src._data)
132 return false;
133 return _data->copyFrom(*src._data, _pool);
134 }
135
136 FORCE_INLINE bool operator==(ArrayRef rhs) const {
137 return arrayEquals(_data, rhs._data);
138 }
139
140 // Internal use
141 FORCE_INLINE VariantRef getOrAddElement(size_t index) const {
142 return VariantRef(_pool, _data ? _data->getOrAddElement(index, _pool) : 0);
143 }
144
145 // Gets the value at the specified index.
146 FORCE_INLINE VariantRef getElement(size_t index) const {
147 return VariantRef(_pool, _data ? _data->getElement(index) : 0);
148 }
149
150 // Removes element at specified position.
151 FORCE_INLINE void remove(iterator it) const {

Callers 1

fromJsonMethod · 0.70

Calls 2

ArrayConstRefClass · 0.70
VariantRefClass · 0.50

Tested by

no test coverage detected