diff --git a/alib2data/src/regexp/RegExp.cpp b/alib2data/src/regexp/RegExp.cpp index db4c7300f087750520ae9c1913f08ba2909fa67e..54524b9e2c574afe85ba234bbf4917b64c55b4ac 100644 --- a/alib2data/src/regexp/RegExp.cpp +++ b/alib2data/src/regexp/RegExp.cpp @@ -9,16 +9,17 @@ namespace regexp { -regexp::RegExp regexpFrom ( const std::string & string ) { +regexp::UnboundedRegExp < char > regexpFrom ( const std::string & string ) { return regexpFrom ( string::LinearString < char > ( string ) ); } -regexp::RegExp regexpFrom ( const char * string ) { +regexp::UnboundedRegExp < char > regexpFrom ( const char * string ) { return regexpFrom ( std::string ( string ) ); } -regexp::RegExp regexpFrom ( ) { - return regexp::RegExp { regexp::UnboundedRegExp < > ( regexp::UnboundedRegExpStructure < DefaultSymbolType > ( regexp::UnboundedRegExpEmpty < DefaultSymbolType > { } ) ) }; +template < class SymbolType > +regexp::UnboundedRegExp < SymbolType > regexpFrom ( ) { + return regexp::UnboundedRegExp < SymbolType > ( regexp::UnboundedRegExpStructure < SymbolType > ( regexp::UnboundedRegExpEmpty < SymbolType > { } ) ); } } /* namespace regexp */ diff --git a/alib2data/src/regexp/RegExp.h b/alib2data/src/regexp/RegExp.h index fc79cb44120904592b7e76679daa3cd6e4a89bdd..a5658d8e701e262c2a3999b9c13f033280ff4b0f 100644 --- a/alib2data/src/regexp/RegExp.h +++ b/alib2data/src/regexp/RegExp.h @@ -8,13 +8,11 @@ #ifndef REG_EXP_H_ #define REG_EXP_H_ -#include <base/WrapperBase.hpp> -#include "RegExpBase.h" - -#include <common/DefaultSymbolType.h> #include <alib/string> #include <alib/vector> -#include <object/ObjectFactory.h> +#include <alib/type_traits> + +#include <common/DefaultSymbolType.h> #include "unbounded/UnboundedRegExpSymbol.h" #include "unbounded/UnboundedRegExpEmpty.h" @@ -30,40 +28,37 @@ namespace regexp { /** * Wrapper around automata. */ -class RegExp : public base::WrapperBase < RegExpBase > { - using base::WrapperBase < RegExpBase >::WrapperBase; - -}; +class RegExp; template < class T > using SymbolTypeOfRegexp = typename std::decay < decltype (std::declval<T>().getAlphabet()) >::type::value_type; -regexp::RegExp regexpFrom ( const std::string & string ); +regexp::UnboundedRegExp < char > regexpFrom ( const std::string & string ); -regexp::RegExp regexpFrom ( const char * string ); +regexp::UnboundedRegExp < char > regexpFrom ( const char * string ); template < class SymbolType > -regexp::RegExp regexpFrom ( ext::vector < SymbolType > string ) { - regexp::UnboundedRegExpConcatenation < DefaultSymbolType > con; +regexp::UnboundedRegExp < SymbolType > regexpFrom ( ext::vector < SymbolType > string ) { + regexp::UnboundedRegExpConcatenation < SymbolType > con; for ( auto & symbol : string ) - con.appendElement ( regexp::UnboundedRegExpSymbol < DefaultSymbolType > ( object::ObjectFactory::make ( symbol ) ) ); + con.appendElement ( regexp::UnboundedRegExpSymbol < SymbolType > ( symbol ) ); - return regexp::RegExp { regexp::UnboundedRegExp < > ( regexp::UnboundedRegExpStructure < DefaultSymbolType > ( std::move ( con ) ) ) }; + return regexp::UnboundedRegExp < SymbolType > ( regexp::UnboundedRegExpStructure < SymbolType > ( std::move ( con ) ) ); } template < class SymbolType > -regexp::RegExp regexpFrom ( string::LinearString < SymbolType > string ) { +regexp::UnboundedRegExp < SymbolType > regexpFrom ( string::LinearString < SymbolType > string ) { return regexpFrom ( string.getContent ( ) ); } template < class SymbolType > -regexp::RegExp regexpFrom ( const SymbolType & symbol ) { - return regexp::RegExp { regexp::UnboundedRegExp < > ( regexp::UnboundedRegExpStructure < DefaultSymbolType > ( regexp::UnboundedRegExpSymbol < DefaultSymbolType > ( object::ObjectFactory::make ( symbol ) ) ) ) }; +regexp::UnboundedRegExp < SymbolType > regexpFrom ( const SymbolType & symbol ) { + return regexp::UnboundedRegExp < SymbolType > ( regexp::UnboundedRegExpStructure < SymbolType > ( regexp::UnboundedRegExpSymbol < SymbolType > ( symbol ) ) ); } - -regexp::RegExp regexpFrom ( ); +template < class SymbolType = DefaultSymbolType > +regexp::UnboundedRegExp < SymbolType > regexpFrom ( ); } /* namespace regexp */ diff --git a/alib2data/src/regexp/xml/FormalRegExp.cpp b/alib2data/src/regexp/xml/FormalRegExp.cpp index 6ec29d674bcbe7740261487e085b277631af48a6..64ae8bc36f1c1554648a1f1b018e61f13ee36d9e 100644 --- a/alib2data/src/regexp/xml/FormalRegExp.cpp +++ b/alib2data/src/regexp/xml/FormalRegExp.cpp @@ -7,7 +7,6 @@ #include <regexp/xml/FormalRegExp.h> -#include <regexp/RegExp.h> #include <object/Object.h> #include <registration/XmlRegistration.hpp> @@ -17,7 +16,6 @@ namespace { static auto xmlWrite = registration::XmlWriterRegister < regexp::FormalRegExp < > > ( ); static auto xmlRead = registration::XmlReaderRegister < regexp::FormalRegExp < > > ( ); -static auto xmlGroup1 = registration::XmlRegisterTypeInGroup < regexp::RegExp, regexp::FormalRegExp < > > ( ); -static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, regexp::FormalRegExp < > > ( ); +static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, regexp::FormalRegExp < > > ( ); } /* namespace */ diff --git a/alib2data/src/regexp/xml/UnboundedRegExp.cpp b/alib2data/src/regexp/xml/UnboundedRegExp.cpp index 015feae5f0ed9c114b3d9728b23ca2f67ebd5976..4d8cc85696b99f2ce9297ef478e9ded23f5f40f6 100644 --- a/alib2data/src/regexp/xml/UnboundedRegExp.cpp +++ b/alib2data/src/regexp/xml/UnboundedRegExp.cpp @@ -7,7 +7,6 @@ #include <regexp/xml/UnboundedRegExp.h> -#include <regexp/RegExp.h> #include <object/Object.h> #include <registration/XmlRegistration.hpp> @@ -17,7 +16,6 @@ namespace { static auto xmlWrite = registration::XmlWriterRegister < regexp::UnboundedRegExp < > > ( ); static auto xmlRead = registration::XmlReaderRegister < regexp::UnboundedRegExp < > > ( ); -static auto xmlGroup1 = registration::XmlRegisterTypeInGroup < regexp::RegExp, regexp::UnboundedRegExp < > > ( ); -static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, regexp::UnboundedRegExp < > > ( ); +static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, regexp::UnboundedRegExp < > > ( ); } /* namespace */ diff --git a/alib2data/src/rte/RTE.h b/alib2data/src/rte/RTE.h index c49a3b6b817e44ed9b45918d448661b2328bd936..7d105be63e5ea21abb17ea031b549c4a25f37350 100644 --- a/alib2data/src/rte/RTE.h +++ b/alib2data/src/rte/RTE.h @@ -8,18 +8,9 @@ #ifndef RTE_H_ #define RTE_H_ -#include "RTEBase.h" -#include <base/WrapperBase.hpp> - namespace rte { -/** - * Wrapper around automata. - */ -class RTE : public base::WrapperBase < RTEBase > { - using base::WrapperBase < RTEBase >::WrapperBase; - -}; +class RTE; } /* namespace rte */ diff --git a/alib2data/src/rte/xml/FormalRTE.cpp b/alib2data/src/rte/xml/FormalRTE.cpp index 3ce956fe43a578eebb2ccddb60a23c73fb141502..68cadfd8d397dd82783326ddb9b18d46f71a0949 100644 --- a/alib2data/src/rte/xml/FormalRTE.cpp +++ b/alib2data/src/rte/xml/FormalRTE.cpp @@ -7,7 +7,6 @@ #include <rte/xml/FormalRTE.h> -#include <rte/RTE.h> #include <object/Object.h> #include <registration/XmlRegistration.hpp> @@ -17,7 +16,6 @@ namespace { static auto xmlWrite = registration::XmlWriterRegister < rte::FormalRTE < > > ( ); static auto xmlRead = registration::XmlReaderRegister < rte::FormalRTE < > > ( ); -static auto xmlGroup1 = registration::XmlRegisterTypeInGroup < rte::RTE, rte::FormalRTE < > > ( ); -static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, rte::FormalRTE < > > ( ); +static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, rte::FormalRTE < > > ( ); } /* namespace */ diff --git a/alib2data/test-src/regexp/RegExpTest.cpp b/alib2data/test-src/regexp/RegExpTest.cpp index b1ebe4e92b473b1aba948a8803b40461c58214a7..8712ab60d1e96d9224f49918d09680f9b13ea623 100644 --- a/alib2data/test-src/regexp/RegExpTest.cpp +++ b/alib2data/test-src/regexp/RegExpTest.cpp @@ -9,7 +9,7 @@ #include "regexp/formal/FormalRegExp.h" #include "regexp/formal/FormalRegExpElements.h" -#include "regexp/RegExp.h" +#include "regexp/xml/UnboundedRegExp.h" #include "factory/XmlDataFactory.hpp" @@ -103,20 +103,20 @@ void RegExpTest::testXMLParser() { regexp::UnboundedRegExp < int > unboundedRegexp({1, 2, 3}, regexp::UnboundedRegExpStructure < int >(alt)); - regexp::RegExp regexp ( core::normalize < regexp::UnboundedRegExp < int > >::eval ( std::move ( unboundedRegexp ) ) ); + regexp::UnboundedRegExp < > regexp = core::normalize < regexp::UnboundedRegExp < int > >::eval ( std::move ( unboundedRegexp ) ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(regexp); std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - regexp::RegExp regexp2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + regexp::UnboundedRegExp < > regexp2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( regexp == regexp2 ); } { std::string tmp = factory::XmlDataFactory::toString(regexp); - regexp::RegExp regexp2 = factory::XmlDataFactory::fromString (tmp); + regexp::UnboundedRegExp < > regexp2 = factory::XmlDataFactory::fromString (tmp); CPPUNIT_ASSERT( regexp == regexp2 ); } diff --git a/alib2data/test-src/rte/RTETest.cpp b/alib2data/test-src/rte/RTETest.cpp index adb51870b0f7a7f12e61dbaa0a31505981e03019..3f9920f9ff5e321ae8748342fba91e01ebab33e4 100644 --- a/alib2data/test-src/rte/RTETest.cpp +++ b/alib2data/test-src/rte/RTETest.cpp @@ -9,6 +9,8 @@ #include "rte/formal/FormalRTE.h" #include "rte/formal/FormalRTEElements.h" +#include <rte/xml/FormalRTE.h> + #include "rte/RTE.h" #include "factory/XmlDataFactory.hpp" @@ -58,9 +60,9 @@ void RTETest::testCopyConstruct ( ) { const common::ranked_symbol < > symb_y0 ( DefaultSymbolType ( 'y' ), DefaultRankType ( 0 ) ); const common::ranked_symbol < > symb_z0 ( DefaultSymbolType ( 'z' ), DefaultRankType ( 0 ) ); - rte::FormalRTE < > frte; - frte.setAlphabetSymbols ( { symb_a2, symb_b0, symb_c0 } ); - frte.setConstantSymbols ( { symb_y0, symb_z0 } ); + rte::FormalRTE < > rte; + rte.setAlphabetSymbols ( { symb_a2, symb_b0, symb_c0 } ); + rte.setConstantSymbols ( { symb_y0, symb_z0 } ); rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > b = rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > ( symb_b0, { } ); rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > c = rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > ( symb_c0, { } ); @@ -76,12 +78,12 @@ void RTETest::testCopyConstruct ( ) { rte::FormalRTEIteration < DefaultSymbolType, primitive::Unsigned > iter = rte::FormalRTEIteration < DefaultSymbolType, primitive::Unsigned > ( a, rte::FormalRTESymbolSubst < DefaultSymbolType, primitive::Unsigned > ( symb_y0 ) ); rte::FormalRTESubstitution < DefaultSymbolType, primitive::Unsigned > subst = rte::FormalRTESubstitution < DefaultSymbolType, primitive::Unsigned > ( iter, alt, rte::FormalRTESymbolSubst < DefaultSymbolType, primitive::Unsigned > ( symb_z0 ) ); - frte.setRTE ( rte::FormalRTEStructure < DefaultSymbolType, primitive::Unsigned > ( subst ) ); + rte.setRTE ( rte::FormalRTEStructure < DefaultSymbolType, primitive::Unsigned > ( subst ) ); - rte::FormalRTE < > frte2 ( frte ); - CPPUNIT_ASSERT ( frte == frte2 ); + rte::FormalRTE < > frte2 ( rte ); + CPPUNIT_ASSERT ( rte == frte2 ); - rte::FormalRTE < > frte3 ( std::move ( frte ) ); + rte::FormalRTE < > frte3 ( std::move ( rte ) ); CPPUNIT_ASSERT ( frte2 == frte3 ); } } @@ -94,10 +96,10 @@ void RTETest::testXMLParser ( ) { const common::ranked_symbol < > symb_y0 ( DefaultSymbolType ( 'y' ), DefaultRankType ( 0 ) ); const common::ranked_symbol < > symb_z0 ( DefaultSymbolType ( 'z' ), DefaultRankType ( 0 ) ); - rte::FormalRTE < > frte; + rte::FormalRTE < > rte; - frte.setAlphabetSymbols ( { symb_a2, symb_b0, symb_c0, symb_d1 } ); - frte.setConstantSymbols ( { symb_y0, symb_z0 } ); + rte.setAlphabetSymbols ( { symb_a2, symb_b0, symb_c0, symb_d1 } ); + rte.setConstantSymbols ( { symb_y0, symb_z0 } ); rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > b = rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > ( symb_b0, { } ); rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > c = rte::FormalRTESymbolAlphabet < DefaultSymbolType, primitive::Unsigned > ( symb_c0, { } ); @@ -117,22 +119,21 @@ void RTETest::testXMLParser ( ) { rte::FormalRTEIteration < DefaultSymbolType, primitive::Unsigned > iter = rte::FormalRTEIteration < DefaultSymbolType, primitive::Unsigned > ( d, rte::FormalRTESymbolSubst < DefaultSymbolType, primitive::Unsigned > ( symb_y0 ) ); rte::FormalRTESubstitution < DefaultSymbolType, primitive::Unsigned > subst = rte::FormalRTESubstitution < DefaultSymbolType, primitive::Unsigned > ( iter, alt, rte::FormalRTESymbolSubst < DefaultSymbolType, primitive::Unsigned > ( symb_z0 ) ); - frte.setRTE ( rte::FormalRTEStructure < DefaultSymbolType, primitive::Unsigned > ( subst ) ); + rte.setRTE ( rte::FormalRTEStructure < DefaultSymbolType, primitive::Unsigned > ( subst ) ); - rte::RTE rte ( frte ); factory::XmlDataFactory::toStdout ( rte ); { ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( rte ); std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); ext::deque < sax::Token > tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - rte::RTE rte2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); + rte::FormalRTE < > rte2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); CPPUNIT_ASSERT ( rte == rte2 ); } { std::string tmp = factory::XmlDataFactory::toString ( rte ); - rte::RTE rte2 = factory::XmlDataFactory::fromString ( tmp ); + rte::FormalRTE < > rte2 = factory::XmlDataFactory::fromString ( tmp ); CPPUNIT_ASSERT ( rte == rte2 ); }