Arduino KVComm
master
Key-Value pair communication library for Arduino
src
KVComm
src
KV_Parser.cpp
Go to the documentation of this file.
1
#if !defined(ARDUINO) || defined(DOXYGEN)
2
3
#include <
KVComm/KV_Iterator.hpp
>
// KV_Iterator
4
#include <
KVComm/KV_Parser.hpp
>
// KV_Parser
5
6
#include <cstring>
// strcmp
7
#include <iostream>
// cout
8
9
KV_Parser::map_t
KV_Parser::parse
(
const
uint8_t *buffer,
size_t
length) {
10
map_t
parseResult
{};
11
for
(
auto
&entry :
KV_Iterator
(buffer, length)) {
12
const
char
*identifier = entry.getID();
13
parseResult
.emplace(std::make_pair(identifier, entry));
14
}
15
return
parseResult
;
16
}
17
18
bool
KV_Parser::strcmp::operator()
(
const
char
*a,
const
char
*b)
const
{
19
return
std::strcmp(a, b) < 0;
20
}
21
22
#endif // ARDUINO
KV_Iterator
Class for iterating over a dictionary generated by the KV_Builder, used for parsing and for checking ...
Definition:
KV_Iterator.hpp:42
KV_Parser::parseResult
map_t parseResult
Definition:
KV_Parser.hpp:39
KV_Parser::parse
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,...
Definition:
KV_Parser.cpp:9
KV_Parser::map_t
std::map< const char *, KV, strcmp > map_t
Definition:
KV_Parser.hpp:37
KV_Parser::strcmp::operator()
bool operator()(const char *a, const char *b) const
Definition:
KV_Parser.cpp:18
KV_Parser.hpp
A parser for dictionaries generated by the KV_Builder.
KV_Iterator.hpp
Iterating over a dictionary generated by the KV_Builder, used for parsing and for checking if a key i...
Generated by
1.8.16