diff --git a/alib2data/src/string/CyclicString.h b/alib2data/src/string/CyclicString.h index b73a41a81c6ca8a7d69192dcdc1736c0141aaad0..8386a234770672e368e9f61417665d44a1652019 100644 --- a/alib2data/src/string/CyclicString.h +++ b/alib2data/src/string/CyclicString.h @@ -24,6 +24,8 @@ #include "common/StringAuxiliary.h" #include <exception/CommonException.h> +#include <object/AnyObject.h> + namespace string { class GeneralAlphabet; @@ -90,6 +92,18 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual alib::ObjectBase * inc ( ) &&; + + virtual StringBase * normalize ( ) && { + std::set < DefaultSymbolType > alphabet; + for ( SymbolType && symbol : std::make_moveable_set ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) ) ) { + alphabet.insert ( DefaultSymbolType ( alib::AnyObject < SymbolType > ( std::move ( symbol ) ) ) ); + } + std::vector < DefaultSymbolType > content; + for ( SymbolType & symbol : m_Data ) { + content.push_back ( DefaultSymbolType ( alib::AnyObject < SymbolType > ( std::move ( symbol ) ) ) ); + } + return new CyclicString < > ( std::move ( alphabet ), std::move ( content ) ); + } }; } /* namespace string */ diff --git a/alib2data/src/string/Epsilon.h b/alib2data/src/string/Epsilon.h index 58b8eff98609313a6ef6e6c6ae24614171050ad9..743b149c77a5f3db268a73c52d8b355d1ee31e51 100644 --- a/alib2data/src/string/Epsilon.h +++ b/alib2data/src/string/Epsilon.h @@ -20,6 +20,8 @@ #include "common/StringFromXMLParser.h" #include "common/StringToXMLComposer.h" +#include <object/AnyObject.h> + namespace string { class GeneralAlphabet; @@ -83,6 +85,14 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual alib::ObjectBase * inc ( ) &&; + + virtual StringBase * normalize ( ) && { + std::set < DefaultSymbolType > alphabet; + for ( SymbolType && symbol : std::make_moveable_set ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) ) ) { + alphabet.insert ( DefaultSymbolType ( alib::AnyObject < SymbolType > ( std::move ( symbol ) ) ) ); + } + return new Epsilon < > ( std::move ( alphabet ) ); + } }; template < class SymbolType > diff --git a/alib2data/src/string/LinearString.h b/alib2data/src/string/LinearString.h index 40f48337c295bc440f58b4ed1837fb01cc584b04..44ef8f2af664bace2f072047a3e63f8e4e2d3859 100644 --- a/alib2data/src/string/LinearString.h +++ b/alib2data/src/string/LinearString.h @@ -26,6 +26,8 @@ #include "../tree/TreeFeatures.h" +#include <object/AnyObject.h> + namespace string { class GeneralAlphabet; @@ -110,6 +112,18 @@ public: void compose ( std::deque < sax::Token > & out ) const; virtual alib::ObjectBase * inc ( ) &&; + + virtual StringBase * normalize ( ) && { + std::set < DefaultSymbolType > alphabet; + for ( SymbolType && symbol : std::make_moveable_set ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) ) ) { + alphabet.insert ( DefaultSymbolType ( alib::AnyObject < SymbolType > ( std::move ( symbol ) ) ) ); + } + std::vector < DefaultSymbolType > content; + for ( SymbolType & symbol : m_Data ) { + content.push_back ( DefaultSymbolType ( alib::AnyObject < SymbolType > ( std::move ( symbol ) ) ) ); + } + return new LinearString < > ( std::move ( alphabet ), std::move ( content ) ); + } }; } /* namespace string */