Add base for menu eventhandlerset parsing

This commit is contained in:
Jan
2021-11-06 16:28:24 +01:00
parent b15efd4a4c
commit bf19208351
19 changed files with 334 additions and 46 deletions

View File

@ -0,0 +1,24 @@
#include "GenericMenuEventHandlerSetPropertySequence.h"
#include <utility>
#include "Parsing/Menu/Matcher/MenuMatcherFactory.h"
using namespace menu;
GenericMenuEventHandlerSetPropertySequence::GenericMenuEventHandlerSetPropertySequence(std::string keywordName, callback_t setCallback)
: m_set_callback(std::move(setCallback))
{
const MenuMatcherFactory create(this);
AddMatchers({
create.KeywordIgnoreCase(std::move(keywordName)),
create.Char('{')
});
}
void GenericMenuEventHandlerSetPropertySequence::ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const
{
state->m_current_event_handler_set = std::make_unique<CommonEventHandlerSet>();
state->m_event_handler_set_callback = m_set_callback;
}

View File

@ -0,0 +1,27 @@
#pragma once
#include <string>
#include <functional>
#include "Parsing/Menu/MenuFileParser.h"
#include "Parsing/Menu/Domain/EventHandler/CommonEventHandlerSet.h"
namespace menu
{
class GenericMenuEventHandlerSetPropertySequence final : public MenuFileParser::sequence_t
{
public:
using callback_t = std::function<void(MenuFileParserState* state, std::unique_ptr<CommonEventHandlerSet> value)>;
private:
static constexpr auto CAPTURE_VALUE = 1;
const callback_t m_set_callback;
protected:
void ProcessMatch(MenuFileParserState* state, SequenceResult<SimpleParserValue>& result) const override;
public:
GenericMenuEventHandlerSetPropertySequence(std::string keywordName, callback_t setCallback);
};
}