mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 15:28:11 -05:00
Move MenuMatcherFactory to Matcher folder
This commit is contained in:
48
src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherFactory.cpp
Normal file
48
src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherFactory.cpp
Normal 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();
|
||||
}
|
19
src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherFactory.h
Normal file
19
src/ObjLoading/Parsing/Menu/Matcher/MenuMatcherFactory.h
Normal 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);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user