From e99a307bf76689e4e86f8ac1a4c545bcebbdb7ab Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Thu, 15 Jan 2015 00:29:11 +0100 Subject: Using Arguments class in ParserStack for validation --- src/core/parser/ParserStack.hpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/core/parser/ParserStack.hpp') diff --git a/src/core/parser/ParserStack.hpp b/src/core/parser/ParserStack.hpp index 93180b4..7602139 100644 --- a/src/core/parser/ParserStack.hpp +++ b/src/core/parser/ParserStack.hpp @@ -39,7 +39,7 @@ #include #include -#include +#include #include "Parser.hpp" @@ -128,7 +128,7 @@ public: * * @param args is a map from strings to variants (argument name and value). */ - virtual void start(const Variant &args) = 0; + virtual void start(const Variant::mapType &args) = 0; /** * Called whenever the command for which this handler is defined ends. @@ -212,10 +212,10 @@ struct HandlerDescriptor { const bool arbitraryChildren; /** - * Pointer pointing at a StructType describing the layout of the given when - * a new Handler instance is instantiated. + * Reference at an argument descriptor that should be used for validating + * the incomming arguments. */ - const Rooted argsType; + const Arguments arguments; /** * Constructor of the HandlerDescriptor class. @@ -228,17 +228,17 @@ struct HandlerDescriptor { * instantiating an in instance of the described Handler instances. * @param arbitraryChildren allows the Handler instance to handle any child * node. - * @param argsType is a struct type describing the arguments that can be - * passed to the Handler or nullptr if no check should be performed. + * @param arguments is an optional argument descriptor used for validating + * the arguments that are passed to the instantiation of a handler function. */ HandlerDescriptor(std::set parentStates, HandlerConstructor ctor, State targetState, bool arbitraryChildren = false, - Handle argsType = nullptr) + Arguments arguments = Arguments::None) : parentStates(std::move(parentStates)), ctor(ctor), targetState(targetState), arbitraryChildren(arbitraryChildren), - argsType(argsType) + arguments(std::move(arguments)) { } @@ -248,7 +248,7 @@ struct HandlerDescriptor { */ HandlerInstance create(const ParserContext &ctx, std::string name, State parentState, bool isChild, - const Variant &args) const; + Variant::mapType &args) const; }; /** @@ -338,7 +338,15 @@ public: * @param name is the name of the command. * @param args is a map from strings to variants (argument name and value). */ - void start(std::string name, const Variant &args); + void start(std::string name, Variant::mapType &args); + + /** + * Function that should be called whenever a new command starts. + * + * @param name is the name of the command. + * @param args is a map from strings to variants (argument name and value). + */ + void start(std::string name, const Variant::mapType &args); /** * Function called whenever a command ends. -- cgit v1.2.3