|
SPSP
Simple publish-subscribe protocol. Connects low power IoT clients to MQTT.
|
String-based trie with wildcard support. More...
#include <wildcard_trie.hpp>
Public Types | |
| using | FindReturnT = std::unordered_map< std::string, const TValue & > |
Public Member Functions | |
| WildcardTrie (const std::string &levelSeparator="/", const std::string &singleLevelWildcard="+", const std::string &multiLevelWildcard="#") noexcept | |
| Constructs a new object. More... | |
| TValue & | operator[] (const std::string &key) |
Gets/inserts current value of key More... | |
| void | insert (const std::string &key, const TValue &value) |
Inserts (or updates) key-value pair. More... | |
| bool | remove (const std::string &key) |
Removes key from trie. More... | |
| const FindReturnT | find (const std::string &key) const |
Finds key in trie. More... | |
| void | forEach (std::function< void(const std::string &key, const TValue &value)> f) |
| Iterates through each item in trie and calls callback on each one. More... | |
| bool | empty () const |
| Empty predicate. More... | |
Protected Member Functions | |
| const std::vector< std::string > | splitToLevels (const std::string &key) const |
Splits key to levels. More... | |
String-based trie with wildcard support.
Made specifically for MQTT-like topics, but it's reusable.
Uses separators to distinguis "levels". Multi-level wildcard must be the last character in the key. There are no exceptions and no key validation. If key is semantically invalid, the item will just become inaccessible.
| TValue | Type of value |
Definition at line 34 of file wildcard_trie.hpp.
|
inlinenoexcept |
Constructs a new object.
| levelSeparator | Level separator |
| singleLevelWildcard | Single-level wildcard token |
| multiLevelWildcard | Multi-level wildcard token |
Definition at line 64 of file wildcard_trie.hpp.
|
inline |
Empty predicate.
Definition at line 250 of file wildcard_trie.hpp.
|
inline |
Finds key in trie.
| key | Key |
Definition at line 169 of file wildcard_trie.hpp.
|
inline |
Iterates through each item in trie and calls callback on each one.
| f | Function to call |
Definition at line 218 of file wildcard_trie.hpp.
|
inline |
Inserts (or updates) key-value pair.
| key | Key |
| value | Value |
Definition at line 107 of file wildcard_trie.hpp.
|
inline |
Gets/inserts current value of key
| key | Key |
Definition at line 77 of file wildcard_trie.hpp.
|
inline |
Removes key from trie.
| key | Key |
Definition at line 119 of file wildcard_trie.hpp.
|
inlineprotected |
Splits key to levels.
There's no validation of key.
| key | Key |
Definition at line 264 of file wildcard_trie.hpp.
1.8.17