A parser for dictionaries generated by the KV_Builder.
More...
#include <KVComm/KV_Parser.hpp>
|
| KV_Parser (const uint8_t *buffer, size_t length) |
| Parse a raw buffer into a new KV_Parser. More...
|
|
bool | contains (const char *key) const |
| Check if the dictionary contains an element with the given key. More...
|
|
KV | getElement (const char *key) const |
| Get the element with the given key. More...
|
|
KV | operator[] (const char *key) const |
| Get the element with the given key. More...
|
|
map_t::iterator | begin () |
| Begin iterator over all entries in the dictionary. More...
|
|
map_t::const_iterator | begin () const |
| Begin iterator over all entries in the dictionary. More...
|
|
map_t::iterator | end () |
| End iterator over all entries in the dictionary. More...
|
|
map_t::const_iterator | end () const |
| End iterator over all entries in the dictionary. More...
|
|
|
map_t | parse (const uint8_t *buffer, size_t length) |
| Parse the buffer for key-value pairs, save their keys, type, and size in an std::map, together with a pointer to the actual value. More...
|
|
A parser for dictionaries generated by the KV_Builder.
Intended to run on your computer, not on the Arduino, because it uses std::map
, dynamic memory allocation and exceptions.
Definition at line 30 of file KV_Parser.hpp.
◆ KV
◆ map_t
◆ KV_Parser()
KV_Parser |
( |
const uint8_t * |
buffer, |
|
|
size_t |
length |
|
) |
| |
|
inline |
Parse a raw buffer into a new KV_Parser.
- Parameters
-
buffer | A pointer to the raw buffer containing the dictionary, as generated by a KV_Builder.
Only the pointer is saved, no copy is made of the actual buffer, so the lifetime of the buffer must be longer than the parser and the accessors. |
length | The length of the dictionary in the buffer (in bytes). |
Definition at line 54 of file KV_Parser.hpp.
◆ contains()
bool contains |
( |
const char * |
key | ) |
const |
|
inline |
Check if the dictionary contains an element with the given key.
- Parameters
-
key | The key of the element to check. |
- Return values
-
true | The dictionary contains an element with the given key. |
false | Otherwise. |
Definition at line 67 of file KV_Parser.hpp.
◆ getElement()
KV getElement |
( |
const char * |
key | ) |
const |
|
inline |
Get the element with the given key.
- Parameters
-
key | The key of the element to retreive. |
- Returns
- The element with the given key.
- Exceptions
-
std::out_of_range | There is no element with the given key. |
Definition at line 80 of file KV_Parser.hpp.
◆ operator[]()
KV operator[] |
( |
const char * |
key | ) |
const |
|
inline |
Get the element with the given key.
- Parameters
-
key | The key of the element to retreive. |
- Returns
- The element with the given key.
- Exceptions
-
std::out_of_range | There is no element with the given key. |
Definition at line 82 of file KV_Parser.hpp.
◆ begin() [1/2]
map_t::iterator begin |
( |
| ) |
|
|
inline |
Begin iterator over all entries in the dictionary.
Definition at line 84 of file KV_Parser.hpp.
◆ begin() [2/2]
map_t::const_iterator begin |
( |
| ) |
const |
|
inline |
Begin iterator over all entries in the dictionary.
Definition at line 86 of file KV_Parser.hpp.
◆ end() [1/2]
End iterator over all entries in the dictionary.
Definition at line 88 of file KV_Parser.hpp.
◆ end() [2/2]
map_t::const_iterator end |
( |
| ) |
const |
|
inline |
End iterator over all entries in the dictionary.
Definition at line 90 of file KV_Parser.hpp.
◆ parse()
Parse the buffer for key-value pairs, save their keys, type, and size in an std::map, together with a pointer to the actual value.
- Parameters
-
buffer | A pointer to the raw buffer containing the dictionary. |
length | The length of the dictionary in the buffer (in bytes). |
- Returns
- A map mapping the keys to the key-value dictionary entries.
Definition at line 9 of file KV_Parser.cpp.
◆ parseResult
The documentation for this class was generated from the following files: