From 037e5192331fb44ecd7183bb12a6dbd66c445507 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Mon, 1 Aug 2016 20:50:41 +0200 Subject: [PATCH] update regexps to components2 --- alib2data/src/regexp/formal/FormalRegExp.cpp | 20 +--------------- alib2data/src/regexp/formal/FormalRegExp.h | 23 +++++++++++++++++-- .../src/regexp/unbounded/UnboundedRegExp.cpp | 20 +--------------- .../src/regexp/unbounded/UnboundedRegExp.h | 23 +++++++++++++++++-- 4 files changed, 44 insertions(+), 42 deletions(-) diff --git a/alib2data/src/regexp/formal/FormalRegExp.cpp b/alib2data/src/regexp/formal/FormalRegExp.cpp index 5e89e7de56..812d5a592f 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.cpp +++ b/alib2data/src/regexp/formal/FormalRegExp.cpp @@ -25,7 +25,7 @@ namespace regexp { -FormalRegExp::FormalRegExp ( std::set < alphabet::Symbol > alphabet, FormalRegExpElement && regExp ) : std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( NULL ) { +FormalRegExp::FormalRegExp ( std::set < alphabet::Symbol > alphabet, FormalRegExpElement && regExp ) : std::Components2 < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( NULL ) { setRegExp ( std::move ( regExp ) ); } @@ -112,24 +112,6 @@ void FormalRegExp::compose ( std::deque < sax::Token > & out ) const { } /* namespace regexp */ -namespace std { - -template < > -bool regexp::FormalRegExp::Component < regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::used ( const alphabet::Symbol & symbol ) const { - return static_cast < const regexp::FormalRegExp * > ( this )->getRegExp ( ).testSymbol ( symbol ); -} - -template < > -bool regexp::FormalRegExp::Component < regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::available ( const alphabet::Symbol & ) const { - return true; -} - -template < > -void regexp::FormalRegExp::Component < regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::valid ( const alphabet::Symbol & ) const { -} - -} /* namespace std */ - namespace alib { auto formalRegExpParserRegister = xmlApi < regexp::RegExp >::ParserRegister < regexp::FormalRegExp > ( ); diff --git a/alib2data/src/regexp/formal/FormalRegExp.h b/alib2data/src/regexp/formal/FormalRegExp.h index ce5edd54b8..038dc6db5f 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.h +++ b/alib2data/src/regexp/formal/FormalRegExp.h @@ -10,7 +10,7 @@ #include <string> #include <set> -#include <core/components.hpp> +#include <core/components2.hpp> #include "../RegExpBase.h" #include "FormalRegExpElement.h" @@ -25,7 +25,7 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -class FormalRegExp : public RegExpBase, public std::Components < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { +class FormalRegExp : public RegExpBase, public std::Components2 < FormalRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { protected: std::smart_ptr < FormalRegExpElement > regExp; @@ -99,4 +99,23 @@ public: } /* namespace regexp */ +namespace std { + +template < > +class ComponentConstraint2< regexp::FormalRegExp, alphabet::Symbol, regexp::GeneralAlphabet > { +public: + static bool used ( const regexp::FormalRegExp & regexp, const alphabet::Symbol & symbol ) { + return regexp.getRegExp ( ).testSymbol ( symbol ); + } + + static bool available ( const regexp::FormalRegExp &, const alphabet::Symbol & ) { + return true; + } + + static void valid ( const regexp::FormalRegExp &, const alphabet::Symbol & ) { + } +}; + +} /* namespace std */ + #endif /* FORMAL_REG_EXP_H_ */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp b/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp index 8763674538..f8053212a0 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp @@ -25,7 +25,7 @@ namespace regexp { -UnboundedRegExp::UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, UnboundedRegExpElement && regExp ) : std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( NULL ) { +UnboundedRegExp::UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, UnboundedRegExpElement && regExp ) : std::Components2 < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), regExp ( NULL ) { setRegExp ( std::move ( regExp ) ); } @@ -112,24 +112,6 @@ void UnboundedRegExp::compose ( std::deque < sax::Token > & out ) const { } /* namespace regexp */ -namespace std { - -template < > -bool regexp::UnboundedRegExp::Component < regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::used ( const alphabet::Symbol & symbol ) const { - return static_cast < const regexp::UnboundedRegExp * > ( this )->getRegExp ( ).testSymbol ( symbol ); -} - -template < > -bool regexp::UnboundedRegExp::Component < regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::available ( const alphabet::Symbol & ) const { - return true; -} - -template < > -void regexp::UnboundedRegExp::Component < regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet >::valid ( const alphabet::Symbol & ) const { -} - -} /* namespace std */ - namespace alib { auto unboundedRegExpParserRegister = xmlApi < regexp::RegExp >::ParserRegister < regexp::UnboundedRegExp > ( ); diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.h b/alib2data/src/regexp/unbounded/UnboundedRegExp.h index 983b8eae92..a8fd792931 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.h @@ -10,7 +10,7 @@ #include <string> #include <set> -#include <core/components.hpp> +#include <core/components2.hpp> #include "../RegExpBase.h" #include "UnboundedRegExpElement.h" @@ -25,7 +25,7 @@ class GeneralAlphabet; * Represents regular expression parsed from the XML. Regular expression is stored * as a tree of RegExpElement. */ -class UnboundedRegExp : public RegExpBase, public std::Components < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { +class UnboundedRegExp : public RegExpBase, public std::Components2 < UnboundedRegExp, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { protected: std::smart_ptr < UnboundedRegExpElement > regExp; @@ -99,4 +99,23 @@ public: } /* namespace regexp */ +namespace std { + +template < > +class ComponentConstraint2< regexp::UnboundedRegExp, alphabet::Symbol, regexp::GeneralAlphabet > { +public: + static bool used ( const regexp::UnboundedRegExp & regexp, const alphabet::Symbol & symbol ) { + return regexp.getRegExp ( ).testSymbol ( symbol ); + } + + static bool available ( const regexp::UnboundedRegExp &, const alphabet::Symbol & ) { + return true; + } + + static void valid ( const regexp::UnboundedRegExp &, const alphabet::Symbol & ) { + } +}; + +} /* namespace std */ + #endif /* UNBOUNDED_REG_EXP_H_ */ -- GitLab