HASerializerArray class¶
-
class HASerializerArray¶
HASerializerArray represents array of items that can be used as a HASerializer property.
Public Types
-
typedef const char *ItemType¶
Public Functions
-
HASerializerArray(const uint8_t size, const bool progmemItems = true)¶
Constructs HASerializerArray with the static size (number of elements). The array is allocated dynamically in the memory based on the given size.
- Parameters
size – The desired number of elements that will be stored in the array.
progmemItems – Specifies whether items are going to be stored in the flash memory.
-
~HASerializerArray()¶
-
inline uint8_t getItemsNb() const¶
Returns the number of elements that were added to the array. It can be lower than size of the array.
-
bool add(ItemType item)¶
Adds a new element to the array.
- Parameters
itemP – Item to add (string).
- Returns
Returns
true
if item has been added to the array successfully.
-
const char *getItem(const uint8_t index) const¶
Returns a pointer to the item at the given index. If the element doesn’t exist, null is returned.
-
uint16_t calculateSize() const¶
Calculates the size of the serialized array (JSON representation).
-
bool serialize(char *output) const¶
Serializes array as JSON to the given output.
-
void clear()¶
Clears the array.
-
typedef const char *ItemType¶