![]() |
PIP 6.1.0
Platform-Independent Primitives
|
Maps packet keys to handlers and deserializes payloads before invocation. More...
#include <piparsehelper.h>
Public Member Functions | |
| PIParseHelper () | |
| Constructs empty parser helper. | |
| void | assign (Key key, std::function< void()> func) |
| Assigns key "key" to callback "func" without payload arguments. | |
| template<typename T> | |
| void | assign (Key key, std::function< void(const T &)> func) |
| Assigns key "key" to callback "func" with one deserialized argument. | |
| template<typename O> | |
| void | assign (Key key, O *obj, void(O::*member_func)()) |
| Assigns key "key" to zero-argument member function of object "obj". | |
| template<typename T, typename O> | |
| void | assign (Key key, O *obj, void(O::*member_func)(const T &)) |
| Assigns key "key" to member function of object "obj" with one deserialized argument. | |
| template<typename L> | |
| void | assign (Key key, L func) |
| Assigns key "key" to functor or lambda with zero or one argument. | |
| void | parse (Key key, PIByteArray ba) |
| Deserializes payload "ba" and invokes handlers assigned to "key". | |
Maps packet keys to handlers and deserializes payloads before invocation.
PIParseHelper helps replace manual switch-based packet dispatch with a set of assign() calls. Handlers may be plain callbacks, functors or object member functions. Payload types are restored from PIByteArray by the selected handler signature.
Example: