Move MenuMatcherFactory to Matcher folder

This commit is contained in:
Jan
2021-11-03 17:17:23 +01:00
parent 0f017749c8
commit ab7b516918
17 changed files with 15 additions and 15 deletions

View File

@ -0,0 +1,48 @@
#include "MenuMatcherFactory.h"
using namespace menu;
MenuMatcherFactory::MenuMatcherFactory(const IMatcherForLabelSupplier<SimpleParserValue>* labelSupplier)
: SimpleMatcherFactory(labelSupplier)
{
}
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::Text() const
{
return MatcherFactoryWrapper<SimpleParserValue>(Or({String(), Identifier()}));
}
MatcherFactoryWrapper<SimpleParserValue> MenuMatcherFactory::Numeric() const
{
return MatcherFactoryWrapper<SimpleParserValue>(Or({FloatingPoint(), Integer()}));
}
int MenuMatcherFactory::TokenNumericIntValue(const SimpleParserValue& value)
{
if(value.m_type == SimpleParserValueType::FLOATING_POINT)
{
return static_cast<int>(value.FloatingPointValue());
}
return value.IntegerValue();
}
double MenuMatcherFactory::TokenNumericFloatingPointValue(const SimpleParserValue& value)
{
if (value.m_type == SimpleParserValueType::INTEGER)
{
return static_cast<double>(value.IntegerValue());
}
return value.FloatingPointValue();
}
std::string& MenuMatcherFactory::TokenTextValue(const SimpleParserValue& value)
{
if(value.m_type == SimpleParserValueType::IDENTIFIER)
{
return value.IdentifierValue();
}
return value.StringValue();
}

View File

@ -0,0 +1,19 @@
#pragma once
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
namespace menu
{
class MenuMatcherFactory : public SimpleMatcherFactory
{
public:
explicit MenuMatcherFactory(const IMatcherForLabelSupplier<SimpleParserValue>* labelSupplier);
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Text() const;
_NODISCARD MatcherFactoryWrapper<SimpleParserValue> Numeric() const;
_NODISCARD static int TokenNumericIntValue(const SimpleParserValue& value);
_NODISCARD static double TokenNumericFloatingPointValue(const SimpleParserValue& value);
_NODISCARD static std::string& TokenTextValue(const SimpleParserValue& value);
};
}