diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-23 15:31:06 +0100 |
---|---|---|
committer | Andreas Stöckel <andreas@somweyr.de> | 2015-01-23 15:31:06 +0100 |
commit | a5e14d8304716289f7ede9834d063bb212f76e83 (patch) | |
tree | c3359aaae98f94e3a5a2df50f33430b72d13d971 /src/core/parser | |
parent | 4aee189703a9305206094858165c67043c2e1953 (diff) |
Ability to add user data to ParserStack (this is just a hack, there should be a better solution, e.g. to derive from ParserStack)
Diffstat (limited to 'src/core/parser')
-rw-r--r-- | src/core/parser/ParserStack.hpp | 17 |
1 files changed, 15 insertions, 2 deletions
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 @@ -322,6 +322,11 @@ private: std::stack<HandlerInstance> 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 * children). This function is used to build error messages. @@ -340,8 +345,9 @@ public: * corresponding HandlerDescriptor instances. */ ParserStack(ParserContext &ctx, - const std::multimap<std::string, HandlerDescriptor> &handlers) - : ctx(ctx), handlers(handlers){}; + const std::multimap<std::string, HandlerDescriptor> &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; } }; } |