From a5e14d8304716289f7ede9834d063bb212f76e83 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Fri, 23 Jan 2015 15:31:06 +0100 Subject: Ability to add user data to ParserStack (this is just a hack, there should be a better solution, e.g. to derive from ParserStack) --- src/core/parser/ParserStack.hpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/core/parser/ParserStack.hpp') diff --git a/src/core/parser/ParserStack.hpp b/src/core/parser/ParserStack.hpp index 4af88f9..6296dff 100644 --- a/src/core/parser/ParserStack.hpp +++ b/src/core/parser/ParserStack.hpp @@ -321,6 +321,11 @@ private: */ std::stack stack; + /** + * Reference at some user defined data. + */ + void *userData; + /** * Used internally to get all expected command names for the given state * (does not work if the current Handler instance allows arbitrary @@ -340,8 +345,9 @@ public: * corresponding HandlerDescriptor instances. */ ParserStack(ParserContext &ctx, - const std::multimap &handlers) - : ctx(ctx), handlers(handlers){}; + const std::multimap &handlers, + void *userData = nullptr) + : ctx(ctx), handlers(handlers), userData(userData){}; /** * Returns the state the ParserStack instance currently is in. @@ -419,6 +425,13 @@ public: * @return a reference to the parser context. */ ParserContext &getContext() { return ctx; } + + /** + * Returns the user defined data. + * + * @return the userData pointer that was given in the constructor. + */ + void *getUserData() { return userData; } }; } -- cgit v1.2.3