From c78490eab3b1ea61ff27419286d1fa679903f7a9 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Fri, 13 Apr 2018 17:53:14 +0200 Subject: [PATCH] reverse cast direction tree -> string --- alib2data/src/string/LinearString.cpp | 11 -- alib2data/src/string/LinearString.h | 137 ------------------ .../src/tree/ranked/PostfixRankedTree.cpp | 2 + alib2data/src/tree/ranked/PostfixRankedTree.h | 11 ++ .../PrefixRankedBarNonlinearPattern.cpp | 2 + .../ranked/PrefixRankedBarNonlinearPattern.h | 11 ++ .../tree/ranked/PrefixRankedBarPattern.cpp | 2 + .../src/tree/ranked/PrefixRankedBarPattern.h | 11 ++ .../src/tree/ranked/PrefixRankedBarTree.cpp | 2 + .../src/tree/ranked/PrefixRankedBarTree.h | 11 ++ .../ranked/PrefixRankedNonlinearPattern.cpp | 2 + .../ranked/PrefixRankedNonlinearPattern.h | 11 ++ .../src/tree/ranked/PrefixRankedPattern.cpp | 2 + .../src/tree/ranked/PrefixRankedPattern.h | 11 ++ .../src/tree/ranked/PrefixRankedTree.cpp | 2 + alib2data/src/tree/ranked/PrefixRankedTree.h | 11 ++ alib2data/src/tree/unranked/PrefixBarTree.cpp | 2 + alib2data/src/tree/unranked/PrefixBarTree.h | 11 ++ alib2raw/src/string/raw/LinearString.h | 2 + 19 files changed, 106 insertions(+), 148 deletions(-) diff --git a/alib2data/src/string/LinearString.cpp b/alib2data/src/string/LinearString.cpp index c9230625ea..86f1ecdd86 100644 --- a/alib2data/src/string/LinearString.cpp +++ b/alib2data/src/string/LinearString.cpp @@ -22,17 +22,6 @@ static auto LinearStringFromString = registration::CastRegister < string::Linear static auto LinearStringFromEpsilon = registration::CastRegister < string::LinearString < >, string::Epsilon < > > ( ); -static auto LinearStringFromPostfixRankedTree = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PostfixRankedTree < > > ( ); - -static auto LinearStringFromPrefixBarTree = registration::CastRegister < string::LinearString < >, tree::PrefixBarTree < > > ( ); - -static auto LinearStringFromPrefixRankedTree = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedTree < > > ( ); -static auto LinearStringFromPrefixRankedPattern = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedPattern < > > ( ); -static auto LinearStringFromPrefixRankedNonlinearPattern = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedNonlinearPattern < > > ( ); -static auto LinearStringFromPrefixRankedBarTree = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedBarTree < > > ( ); -static auto LinearStringFromPrefixRankedBarPattern = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedBarPattern < > > ( ); -static auto LinearStringFromPrefixRankedBarNonlinearPattern = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedBarNonlinearPattern < > > ( ); - static auto LinearStringSet = registration::SetRegister < string::LinearString < > > ( ); static auto valuePrinter = registration::ValuePrinterRegister < string::LinearString < > > ( ); diff --git a/alib2data/src/string/LinearString.h b/alib2data/src/string/LinearString.h index 0802f1e5a1..5f570ada38 100644 --- a/alib2data/src/string/LinearString.h +++ b/alib2data/src/string/LinearString.h @@ -37,8 +37,6 @@ #include <exception/CommonException.h> #include <alphabet/common/SymbolNormalize.h> -#include <tree/TreeFeatures.h> - #include <core/normalize.hpp> namespace string { @@ -69,90 +67,6 @@ public: */ explicit LinearString ( ); - /** - * \brief Creates a new instance of the string from a linear representation of a tree - * - * \tparam TreeSymbolType the symbol type of the tree - * \tparam TreeRankType the rank type of the tree - * - * \param tree the content of the string from tree in linear representation - */ - template < class TreeSymbolType, class TreeRankType > - explicit LinearString ( const tree::PrefixRankedTree < TreeSymbolType, TreeRankType > & tree ); - - /** - * \brief Creates a new instance of the string from a linear representation of a tree - * - * \tparam TreeSymbolType the symbol type of the tree - * \tparam TreeRankType the rank type of the tree - * - * \param tree the content of the string from tree in linear representation - */ - template < class TreeSymbolType, class TreeRankType > - explicit LinearString ( const tree::PrefixRankedPattern < TreeSymbolType, TreeRankType > & tree ); - - /** - * \brief Creates a new instance of the string from a linear representation of a tree - * - * \tparam TreeSymbolType the symbol type of the tree - * \tparam TreeRankType the rank type of the tree - * - * \param tree the content of the string from tree in linear representation - */ - template < class TreeSymbolType, class TreeRankType > - explicit LinearString ( const tree::PrefixRankedNonlinearPattern < TreeSymbolType, TreeRankType > & tree ); - - /** - * \brief Creates a new instance of the string from a linear representation of a tree - * - * \tparam TreeSymbolType the symbol type of the tree - * \tparam TreeRankType the rank type of the tree - * - * \param tree the content of the string from tree in linear representation - */ - template < class TreeSymbolType, class TreeRankType > - explicit LinearString ( const tree::PrefixRankedBarTree < TreeSymbolType, TreeRankType > & tree ); - - /** - * \brief Creates a new instance of the string from a linear representation of a tree - * - * \tparam TreeSymbolType the symbol type of the tree - * \tparam TreeRankType the rank type of the tree - * - * \param tree the content of the string from tree in linear representation - */ - template < class TreeSymbolType, class TreeRankType > - explicit LinearString ( const tree::PrefixRankedBarPattern < TreeSymbolType, TreeRankType > & tree ); - - /** - * \brief Creates a new instance of the string from a linear representation of a tree - * - * \tparam TreeSymbolType the symbol type of the tree - * \tparam TreeRankType the rank type of the tree - * - * \param tree the content of the string from tree in linear representation - */ - template < class TreeSymbolType, class TreeRankType > - explicit LinearString ( const tree::PrefixRankedBarNonlinearPattern < TreeSymbolType, TreeRankType > & tree ); - - /** - * \brief Creates a new instance of the string from a linear representation of a tree - * - * \param tree the content of the string from tree in linear representation - */ - explicit LinearString ( const tree::PrefixBarTree < SymbolType > & tree ); - - /** - * \brief Creates a new instance of the string from a linear representation of a tree - * - * \tparam TreeSymbolType the symbol type of the tree - * \tparam TreeRankType the rank type of the tree - * - * \param tree the content of the string from tree in linear representation - */ - template < class TreeSymbolType, class TreeRankType > - explicit LinearString ( const tree::PostfixRankedTree < TreeSymbolType, TreeRankType > & tree ); - /** * \brief Creates a new instance of the string with a concrete alphabet and content. * @@ -305,18 +219,6 @@ public: } /* namespace string */ #include "Epsilon.h" -#include "../tree/ranked/PrefixRankedTree.h" -#include "../tree/ranked/PrefixRankedPattern.h" -#include "../tree/ranked/PrefixRankedNonlinearPattern.h" -#include "../tree/ranked/PrefixRankedBarTree.h" -#include "../tree/ranked/PrefixRankedBarPattern.h" -#include "../tree/ranked/PrefixRankedBarNonlinearPattern.h" - -#include "../tree/unranked/PrefixBarTree.h" - -#include "../tree/ranked/PostfixRankedTree.h" - -#include "../tree/common/TreeAuxiliary.h" namespace string { @@ -345,45 +247,6 @@ template < class SymbolType > LinearString < SymbolType >::LinearString(const Epsilon < SymbolType > & epsilon) : LinearString ( epsilon.getAlphabet( ), ext::vector < SymbolType > ( ) ) { } -template < class SymbolType > -template < class TreeSymbolType, class TreeRankType > -LinearString < SymbolType >::LinearString ( const tree::PrefixRankedTree < TreeSymbolType, TreeRankType > & tree ) : LinearString ( tree.getAlphabet ( ), tree.getContent ( ) ) { -} - -template < class SymbolType > -template < class TreeSymbolType, class TreeRankType > -LinearString < SymbolType >::LinearString ( const tree::PrefixRankedPattern < TreeSymbolType, TreeRankType > & tree ) : LinearString ( tree.getAlphabet ( ), tree.getContent ( ) ) { -} - -template < class SymbolType > -template < class TreeSymbolType, class TreeRankType > -LinearString < SymbolType >::LinearString ( const tree::PrefixRankedNonlinearPattern < TreeSymbolType, TreeRankType > & tree ) : LinearString ( tree.getAlphabet ( ), tree.getContent ( ) ) { -} - -template < class SymbolType > -template < class TreeSymbolType, class TreeRankType > -LinearString < SymbolType >::LinearString ( const tree::PrefixRankedBarTree < TreeSymbolType, TreeRankType > & tree ) : LinearString ( tree.getAlphabet ( ), tree.getContent ( ) ) { -} - -template < class SymbolType > -template < class TreeSymbolType, class TreeRankType > -LinearString < SymbolType >::LinearString ( const tree::PrefixRankedBarPattern < TreeSymbolType, TreeRankType > & tree ) : LinearString ( tree.getAlphabet ( ), tree.getContent ( ) ) { -} - -template < class SymbolType > -template < class TreeSymbolType, class TreeRankType > -LinearString < SymbolType >::LinearString ( const tree::PrefixRankedBarNonlinearPattern < TreeSymbolType, TreeRankType > & tree ) : LinearString ( tree.getAlphabet ( ), tree.getContent ( ) ) { -} - -template < class SymbolType > -LinearString < SymbolType >::LinearString ( const tree::PrefixBarTree < SymbolType > & tree ) : LinearString ( tree.getAlphabet ( ), tree.getContent ( ) ) { -} - -template < class SymbolType > -template < class TreeSymbolType, class TreeRankType > -LinearString < SymbolType >::LinearString ( const tree::PostfixRankedTree < TreeSymbolType, TreeRankType > & tree ) : LinearString ( tree.getAlphabet ( ), tree.getContent ( ) ) { -} - template < class SymbolType > StringBase * LinearString < SymbolType >::clone ( ) const { return new LinearString ( * this ); diff --git a/alib2data/src/tree/ranked/PostfixRankedTree.cpp b/alib2data/src/tree/ranked/PostfixRankedTree.cpp index b542c06eeb..5b5ee74ffe 100644 --- a/alib2data/src/tree/ranked/PostfixRankedTree.cpp +++ b/alib2data/src/tree/ranked/PostfixRankedTree.cpp @@ -28,4 +28,6 @@ static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, t static auto PostfixRankedTreeFromRankedTree = registration::CastRegister < tree::PostfixRankedTree < >, tree::RankedTree < > > ( ); +static auto LinearStringFromPostfixRankedTree = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PostfixRankedTree < > > ( ); + } /* namespace */ diff --git a/alib2data/src/tree/ranked/PostfixRankedTree.h b/alib2data/src/tree/ranked/PostfixRankedTree.h index 0b7fc0b9af..f4c5baa863 100644 --- a/alib2data/src/tree/ranked/PostfixRankedTree.h +++ b/alib2data/src/tree/ranked/PostfixRankedTree.h @@ -47,6 +47,8 @@ #include <core/normalize.hpp> +#include <string/LinearString.h> + namespace tree { class GeneralAlphabet; @@ -232,6 +234,15 @@ public: * Type of normalized tree. */ typedef PostfixRankedTree < > normalized_type; + + /** + * \brief Creates a new instance of the string from a linear representation of a tree + * + * \returns tree casted to string + */ + explicit operator string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( ) const { + return string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( getAlphabet ( ), getContent ( ) ); + } }; } /* namespace tree */ diff --git a/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.cpp b/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.cpp index f1dc973857..6103320e72 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.cpp +++ b/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.cpp @@ -32,4 +32,6 @@ static auto PrefixRankedBarNonlinearPatternFromRankedNonlinearPattern = registra static auto PrefixRankedBarNonlinearPatternFromPrefixRankedBarTree = registration::CastRegister < tree::PrefixRankedBarNonlinearPattern < >, tree::PrefixRankedBarTree < > > ( ); static auto PrefixRankedBarNonlinearPatternFromPrefixRankedBarPattern = registration::CastRegister < tree::PrefixRankedBarNonlinearPattern < >, tree::PrefixRankedBarPattern < > > ( ); +static auto LinearStringFromPrefixRankedBarNonlinearPattern = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedBarNonlinearPattern < > > ( ); + } /* namespace */ diff --git a/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h b/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h index a342420eec..b2cc50e939 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedBarNonlinearPattern.h @@ -51,6 +51,8 @@ #include <core/normalize.hpp> +#include <string/LinearString.h> + namespace tree { class GeneralAlphabet; @@ -400,6 +402,15 @@ public: * Type of normalized pattern. */ typedef PrefixRankedBarNonlinearPattern < > normalized_type; + + /** + * \brief Creates a new instance of the string from a linear representation of a tree + * + * \returns tree casted to string + */ + explicit operator string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( ) const { + return string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( getAlphabet ( ), getContent ( ) ); + } }; } /* namespace tree */ diff --git a/alib2data/src/tree/ranked/PrefixRankedBarPattern.cpp b/alib2data/src/tree/ranked/PrefixRankedBarPattern.cpp index 7ef91c4abc..fe72f8c473 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarPattern.cpp +++ b/alib2data/src/tree/ranked/PrefixRankedBarPattern.cpp @@ -29,4 +29,6 @@ static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, t static auto PrefixRankedBarPatternFromRankedPattern = registration::CastRegister < tree::PrefixRankedBarPattern < >, tree::RankedPattern < > > ( ); static auto PrefixRankedBarPatternFromPrefixRankedBarTree = registration::CastRegister < tree::PrefixRankedBarPattern < >, tree::PrefixRankedBarTree < > > ( ); +static auto LinearStringFromPrefixRankedBarPattern = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedBarPattern < > > ( ); + } /* namespace */ diff --git a/alib2data/src/tree/ranked/PrefixRankedBarPattern.h b/alib2data/src/tree/ranked/PrefixRankedBarPattern.h index cb9fde40f5..c4b820a7b5 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedBarPattern.h @@ -51,6 +51,8 @@ #include <core/normalize.hpp> +#include <string/LinearString.h> + namespace tree { class GeneralAlphabet; @@ -329,6 +331,15 @@ public: * Type of normalized pattern. */ typedef PrefixRankedBarPattern < > normalized_type; + + /** + * \brief Creates a new instance of the string from a linear representation of a tree + * + * \returns tree casted to string + */ + explicit operator string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( ) const { + return string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( getAlphabet ( ), getContent ( ) ); + } }; } /* namespace tree */ diff --git a/alib2data/src/tree/ranked/PrefixRankedBarTree.cpp b/alib2data/src/tree/ranked/PrefixRankedBarTree.cpp index 4384f21679..9d416167ab 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarTree.cpp +++ b/alib2data/src/tree/ranked/PrefixRankedBarTree.cpp @@ -28,4 +28,6 @@ static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, t static auto PrefixRankedBarTreeFromRankedTree = registration::CastRegister < tree::PrefixRankedBarTree < >, tree::RankedTree < > > ( ); +static auto LinearStringFromPrefixRankedBarTree = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedBarTree < > > ( ); + } /* namespace */ diff --git a/alib2data/src/tree/ranked/PrefixRankedBarTree.h b/alib2data/src/tree/ranked/PrefixRankedBarTree.h index bc93fd2a3d..b40b2b0d01 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarTree.h +++ b/alib2data/src/tree/ranked/PrefixRankedBarTree.h @@ -49,6 +49,8 @@ #include <core/normalize.hpp> +#include <string/LinearString.h> + namespace tree { class GeneralAlphabet; @@ -275,6 +277,15 @@ public: * Type of normalized tree. */ typedef PrefixRankedBarTree < > normalized_type; + + /** + * \brief Creates a new instance of the string from a linear representation of a tree + * + * \returns tree casted to string + */ + explicit operator string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( ) const { + return string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( getAlphabet ( ), getContent ( ) ); + } }; } /* namespace tree */ diff --git a/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.cpp b/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.cpp index a8d52048c8..4d0edd86a6 100644 --- a/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.cpp +++ b/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.cpp @@ -32,4 +32,6 @@ static auto PrefixRankedNonlinearPatternFromRankedNonlinearPattern = registratio static auto PrefixRankedNonlinearPatternFromPrefixRankedTree = registration::CastRegister < tree::PrefixRankedNonlinearPattern < >, tree::PrefixRankedTree < > > ( ); static auto PrefixRankedNonlinearPatternFromPrefixRankedPattern = registration::CastRegister < tree::PrefixRankedNonlinearPattern < >, tree::PrefixRankedPattern < > > ( ); +static auto LinearStringFromPrefixRankedNonlinearPattern = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedNonlinearPattern < > > ( ); + } /* namespace */ diff --git a/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h b/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h index b9fc4f20aa..c376b4d650 100644 --- a/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedNonlinearPattern.h @@ -49,6 +49,8 @@ #include <core/normalize.hpp> +#include <string/LinearString.h> + namespace tree { class GeneralAlphabet; @@ -314,6 +316,15 @@ public: * Type of normalized pattern. */ typedef PrefixRankedNonlinearPattern < > normalized_type; + + /** + * \brief Creates a new instance of the string from a linear representation of a tree + * + * \returns tree casted to string + */ + explicit operator string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( ) const { + return string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( getAlphabet ( ), getContent ( ) ); + } }; } /* namespace tree */ diff --git a/alib2data/src/tree/ranked/PrefixRankedPattern.cpp b/alib2data/src/tree/ranked/PrefixRankedPattern.cpp index 965a4da08d..fc190f77e1 100644 --- a/alib2data/src/tree/ranked/PrefixRankedPattern.cpp +++ b/alib2data/src/tree/ranked/PrefixRankedPattern.cpp @@ -29,4 +29,6 @@ static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, t static auto PrefixRankedPatternFromRankedPattern = registration::CastRegister < tree::PrefixRankedPattern < >, tree::RankedPattern < > > ( ); static auto PrefixRankedPatternFromPrefixRankedTree = registration::CastRegister < tree::PrefixRankedPattern < >, tree::PrefixRankedTree < > > ( ); +static auto LinearStringFromPrefixRankedPattern = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedPattern < > > ( ); + } /* namespace */ diff --git a/alib2data/src/tree/ranked/PrefixRankedPattern.h b/alib2data/src/tree/ranked/PrefixRankedPattern.h index 9365cddebe..9d7a893d9d 100644 --- a/alib2data/src/tree/ranked/PrefixRankedPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedPattern.h @@ -49,6 +49,8 @@ #include <core/normalize.hpp> +#include <string/LinearString.h> + namespace tree { class GeneralAlphabet; @@ -263,6 +265,15 @@ public: * Type of normalized pattern. */ typedef PrefixRankedPattern < > normalized_type; + + /** + * \brief Creates a new instance of the string from a linear representation of a tree + * + * \returns tree casted to string + */ + explicit operator string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( ) const { + return string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( getAlphabet ( ), getContent ( ) ); + } }; } /* namespace tree */ diff --git a/alib2data/src/tree/ranked/PrefixRankedTree.cpp b/alib2data/src/tree/ranked/PrefixRankedTree.cpp index f90b1a1c66..c4e805b4be 100644 --- a/alib2data/src/tree/ranked/PrefixRankedTree.cpp +++ b/alib2data/src/tree/ranked/PrefixRankedTree.cpp @@ -29,4 +29,6 @@ static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, t static auto PrefixRankedTreeFromRankedTree = registration::CastRegister < tree::PrefixRankedTree < >, tree::RankedTree < > > ( ); static auto PrefixRankedTreeFromPostfixRankedTree = registration::CastRegister < tree::PrefixRankedTree < >, tree::PostfixRankedTree < > > ( ); +static auto LinearStringFromPrefixRankedTree = registration::CastRegister < string::LinearString < common::ranked_symbol < > >, tree::PrefixRankedTree < > > ( ); + } /* namespace */ diff --git a/alib2data/src/tree/ranked/PrefixRankedTree.h b/alib2data/src/tree/ranked/PrefixRankedTree.h index fecc3c8247..a6036182e5 100644 --- a/alib2data/src/tree/ranked/PrefixRankedTree.h +++ b/alib2data/src/tree/ranked/PrefixRankedTree.h @@ -46,6 +46,8 @@ #include <core/normalize.hpp> +#include <string/LinearString.h> + namespace tree { class GeneralAlphabet; @@ -238,6 +240,15 @@ public: * Type of normalized tree. */ typedef PrefixRankedTree < > normalized_type; + + /** + * \brief Creates a new instance of the string from a linear representation of a tree + * + * \returns tree casted to string + */ + explicit operator string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( ) const { + return string::LinearString < common::ranked_symbol < SymbolType, RankType > > ( getAlphabet ( ), getContent ( ) ); + } }; } /* namespace tree */ diff --git a/alib2data/src/tree/unranked/PrefixBarTree.cpp b/alib2data/src/tree/unranked/PrefixBarTree.cpp index 0b5bc9eb2d..19b1c14024 100644 --- a/alib2data/src/tree/unranked/PrefixBarTree.cpp +++ b/alib2data/src/tree/unranked/PrefixBarTree.cpp @@ -28,4 +28,6 @@ static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, t static auto PrefixBarTreeFromUnrankedTree = registration::CastRegister < tree::PrefixBarTree < >, tree::UnrankedTree < > > ( ); +static auto LinearStringFromPrefixBarTree = registration::CastRegister < string::LinearString < >, tree::PrefixBarTree < > > ( ); + } /* namespace */ diff --git a/alib2data/src/tree/unranked/PrefixBarTree.h b/alib2data/src/tree/unranked/PrefixBarTree.h index 67eab3f383..44d285ad43 100644 --- a/alib2data/src/tree/unranked/PrefixBarTree.h +++ b/alib2data/src/tree/unranked/PrefixBarTree.h @@ -47,6 +47,8 @@ #include <core/normalize.hpp> +#include <string/LinearString.h> + namespace tree { class GeneralAlphabet; @@ -263,6 +265,15 @@ public: * Type of normalized tree. */ typedef PrefixBarTree < > normalized_type; + + /** + * \brief Creates a new instance of the string from a linear representation of a tree + * + * \returns tree casted to string + */ + explicit operator string::LinearString < SymbolType > ( ) const { + return string::LinearString < SymbolType > ( getAlphabet ( ), getContent ( ) ); + } }; } /* namespace tree */ diff --git a/alib2raw/src/string/raw/LinearString.h b/alib2raw/src/string/raw/LinearString.h index 1a2bafff06..b572a2b3ad 100644 --- a/alib2raw/src/string/raw/LinearString.h +++ b/alib2raw/src/string/raw/LinearString.h @@ -11,6 +11,8 @@ #include <string/LinearString.h> #include <core/rawApi.hpp> +#include <iterator> + namespace core { template < class SymbolType > -- GitLab