#include <KVComm/KV_Iterator.hpp>
|
| | KV (const uint8_t *buffer) |
| | Constructor. More...
|
| |
| uint8_t | getTypeID () const |
| | Get the type ID of the current element. More...
|
| |
| uint16_t | getIDLength () const |
| | Get the length of the identifier / key of the current element. More...
|
| |
| uint16_t | getDataLength () const |
| | Get the length of the data of the current element. More...
|
| |
| const uint8_t * | getBuffer () const |
| | Get a pointer to the beginning of the current element. More...
|
| |
| const char * | getID () const |
| | Get the identifier / key of the current element. More...
|
| |
| const uint8_t * | getData () const |
| | Get a pointer to the data of the current element. More...
|
| |
| | operator bool () const |
| | Check if the key-value pair is valid. More...
|
| |
| template<class T > |
| uint16_t | getArraySize () const |
| | Get the number of elements in the array of data. More...
|
| |
| template<class T > |
| void | get (T &t, size_t index=0) const |
| | Get the data as the given type. More...
|
| |
| template<class T > |
| T | getAs (size_t index=0) const |
| | Get the data as the given type. More...
|
| |
| template<class T > |
| std::vector< T > | getVector () const |
| | Get the data of the element as a vector of the given type. More...
|
| |
| template<class T , size_t N> |
| std::array< T, N > | getArray () const |
| | Get the data of the element as an array of the given type. More...
|
| |
| std::string | getString () const |
| | Get the character array as an std::string. More...
|
| |
| template<class T > |
| bool | hasType () const |
| | Check if the type of this element is the same as the given type. More...
|
| |
|
| template<class T > |
| bool | checkType () const |
| | Assert that the type of this entry matches the given type T. More...
|
| |
- Examples
- KVComm-Receive.ino.
Definition at line 47 of file KV_Iterator.hpp.
◆ KV()
| KV |
( |
const uint8_t * |
buffer | ) |
|
|
inline |
◆ getTypeID()
| uint8_t getTypeID |
( |
| ) |
const |
|
inline |
◆ getIDLength()
| uint16_t getIDLength |
( |
| ) |
const |
|
inline |
Get the length of the identifier / key of the current element.
Definition at line 54 of file KV_Iterator.hpp.
◆ getDataLength()
| uint16_t getDataLength |
( |
| ) |
const |
|
inline |
Get the length of the data of the current element.
Definition at line 56 of file KV_Iterator.hpp.
◆ getBuffer()
| const uint8_t* getBuffer |
( |
| ) |
const |
|
inline |
Get a pointer to the beginning of the current element.
Definition at line 60 of file KV_Iterator.hpp.
◆ getID()
| const char* getID |
( |
| ) |
const |
|
inline |
◆ getData()
| const uint8_t* getData |
( |
| ) |
const |
|
inline |
Get a pointer to the data of the current element.
Definition at line 64 of file KV_Iterator.hpp.
◆ operator bool()
◆ getArraySize()
| uint16_t getArraySize |
( |
| ) |
const |
|
inline |
◆ get()
| void get |
( |
T & |
t, |
|
|
size_t |
index = 0 |
|
) |
| const |
|
inline |
Get the data as the given type.
- Template Parameters
-
| T | The type of value to read. |
- Parameters
-
| [out] | t | The value is read from the dictionary into this variable. |
| [in] | index | The index of the element of the array to read (if the value is an array). |
- Exceptions
-
| 0x7566 | Trying to extract data from non-existent entry. |
| 0x7563 | Type mismatch: The dynamic type ID doesn't match the type ID of T. |
| 0x7564 | Index out of range. |
Definition at line 96 of file KV_Iterator.hpp.
◆ getAs()
| T getAs |
( |
size_t |
index = 0 | ) |
const |
|
inline |
Get the data as the given type.
- Template Parameters
-
| T | The type of value to read. |
- Parameters
-
| index | The index of the element of the array to read (if the value is an array). |
- Returns
- The requested element of the value from this key-value pair, casted to the given type
T.
- Exceptions
-
| 0x7566 | Trying to extract data from non-existent entry. |
| 0x7563 | Type mismatch: The dynamic type ID doesn't match the type ID of T. |
| 0x7564 | Index out of range. |
- Examples
- KVComm-Receive.ino.
Definition at line 132 of file KV_Iterator.hpp.
◆ getVector()
| std::vector<T> getVector |
( |
| ) |
const |
|
inline |
Get the data of the element as a vector of the given type.
- Template Parameters
-
| T | The type of the data. This must be the same as the dynamic type of the data. |
- Returns
- A vector containing the data of the element, converted to the correct type.
- Exceptions
-
| 0x7566 | Trying to extract data from non-existent entry. |
| 0x7563 | Type mismatch: The dynamic type ID doesn't match the type ID of T. |
Definition at line 154 of file KV_Iterator.hpp.
◆ getArray()
| std::array<T, N> getArray |
( |
| ) |
const |
|
inline |
Get the data of the element as an array of the given type.
- Template Parameters
-
| T | The type of the data. This must be the same as the dynamic type of the data. |
| N | The number of elements in the array. This must be the same as the length of the data. |
- Returns
- An array containing the data of the element, converted to the correct type.
- Exceptions
-
| 0x7566 | Trying to extract data from non-existent entry. |
| 0x7563 | Type mismatch: The dynamic type ID doesn't match the type ID of T. |
| 0x7565 | Incorrect length: The specified array size N doesn't match the actual dynamic size of the element. |
Definition at line 193 of file KV_Iterator.hpp.
◆ getString()
| std::string getString |
( |
| ) |
const |
Get the character array as an std::string.
- Returns
- The character array as a string.
- Note
- Returns an Arduino
String instead of an std::string on Arduino.
- Exceptions
-
| 0x7566 | Trying to extract data from non-existent entry. |
| 0x7563 | Type mismatch: The dynamic type ID doesn't match the type ID of char. |
- Examples
- KVComm-Receive.ino.
Definition at line 57 of file KV_Iterator.cpp.
◆ hasType()
Check if the type of this element is the same as the given type.
- Template Parameters
-
| T | The type to compare to the type of this element. |
- Return values
-
| true | The types are the same. |
| false | Otherwise. |
Definition at line 246 of file KV_Iterator.hpp.
◆ checkType()
Assert that the type of this entry matches the given type T.
Definition at line 253 of file KV_Iterator.hpp.
◆ buffer
The documentation for this class was generated from the following files: