Arduino KVComm
master
Key-Value pair communication library for Arduino
|
Go to the documentation of this file.
6 #include <AH/STL/algorithm>
22 : kv(
buffer), remainingBufferLength(length) {
27 size_t totalLength = 4 +
nextWord(kv.getIDLength()) +
29 remainingBufferLength -= totalLength;
30 kv = kv.getBuffer() + totalLength;
37 return this->kv.getBuffer() != other.
kv.
getBuffer();
43 return this->kv.getBuffer() == other.
kv.
getBuffer();
48 if (remainingBufferLength == 0) {
50 }
else if (!kv || kv.getIDLength() == 0) {
51 remainingBufferLength = 0;
56 #if !defined(ARDUINO) || defined(DOXYGEN)
58 if (!checkType<char>())
60 return std::string(getData(), getData() + getDataLength() - 1);
65 if (!checkType<char>())
66 return static_cast<const char *>(
nullptr);
67 struct S :
public String {
70 s.copy(reinterpret_cast<const char *>(getData()), getDataLength() - 1);
77 return strcmp(kv.
getID(), key) == 0;
iterator find(const char *key) const
Find the entry with the given key (iterates over entire dictionary).
std::string getString() const
Get the character array as an std::string.
size_t nextWord(size_t i)
Get the offset of the next 4-byte word.
Iterating over a dictionary generated by the KV_Builder, used for parsing and for checking if a key i...
iterator & operator++()
Advance the iterator.
const uint8_t * getBuffer() const
Get a pointer to the beginning of the current element.
static iterator end()
End/sentinel iterator.
size_t roundUpToWordSizeMultiple(size_t i)
Round up a size to a multiple of 4-byte words.
iterator()
Default constructor. Used as "end" iterator (sentinel).
const char * getID() const
Get the identifier / key of the current element.
bool operator!=(const iterator &other) const
Compare the iterator to the "end" iterator.
Helpers for address manipulation used to layout dictionary entries in memory.
bool operator==(ArraySlice< T1, N1, Reverse1, Const1 > a, ArraySlice< T2, N2, Reverse2, Const2 > b)
Slice == Slice.
iterator begin() const
Iterator to the first key-value entry of the dictionary.