From 1a7b9dd387f20640ce293897cb52cbe92513a375 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 5 Sep 2017 22:10:51 +0200 Subject: [PATCH] use cli in astringology binary --- .../properties/BadCharacterShiftTable.cpp | 6 +- .../properties/BadCharacterShiftTable.h | 8 +- .../src/string/properties/BorderArray.cpp | 6 +- alib2algo/src/string/properties/BorderArray.h | 8 +- .../properties/GoodSuffixShiftTable.cpp | 6 +- .../string/properties/GoodSuffixShiftTable.h | 8 +- .../ReversedBadCharacterShiftTable.cpp | 6 +- .../ReversedBadCharacterShiftTable.h | 8 +- .../src/stringology/exact/BoyerMoore.cpp | 6 +- alib2algo/src/stringology/exact/BoyerMoore.h | 8 +- .../stringology/exact/BoyerMooreHorspool.cpp | 6 +- .../stringology/exact/BoyerMooreHorspool.h | 8 +- .../exact/DeadZoneUsingBadCharacterShift.cpp | 6 +- .../exact/DeadZoneUsingBadCharacterShift.h | 7 +- .../stringology/exact/ExactFactorMatch.cpp | 6 +- .../src/stringology/exact/ExactFactorMatch.h | 8 +- .../exact/ReversedBoyerMooreHorspool.cpp | 6 +- .../exact/ReversedBoyerMooreHorspool.h | 8 +- .../indexing/BitParallelIndexConstruction.cpp | 8 +- .../indexing/BitParallelIndexConstruction.h | 6 +- ...CompressedBitParallelIndexConstruction.cpp | 8 +- .../CompressedBitParallelIndexConstruction.h | 6 +- .../indexing/ExactFactorOracleAutomaton.cpp | 6 +- .../indexing/ExactFactorOracleAutomaton.h | 7 +- ...tiNondeterministicSubsequenceAutomaton.cpp | 4 - ...ultiNondeterministicSubsequenceAutomaton.h | 2 - ...ctNondeterministicSubsequenceAutomaton.cpp | 6 +- ...xactNondeterministicSubsequenceAutomaton.h | 7 +- .../indexing/ExactSubsequenceAutomaton.cpp | 6 +- .../indexing/ExactSubsequenceAutomaton.h | 7 +- .../NondeterministicExactFactorAutomaton.cpp | 6 +- .../NondeterministicExactFactorAutomaton.h | 7 +- .../NondeterministicExactSuffixAutomaton.cpp | 6 +- .../NondeterministicExactSuffixAutomaton.h | 7 +- .../indexing/PositionHeapNaive.cpp | 8 +- .../stringology/indexing/PositionHeapNaive.h | 6 +- .../stringology/indexing/SuffixArrayNaive.cpp | 8 +- .../stringology/indexing/SuffixArrayNaive.h | 6 +- .../stringology/indexing/SuffixTrieNaive.cpp | 6 +- .../stringology/indexing/SuffixTrieNaive.h | 6 +- .../matching/BNDMMatcherConstruction.cpp | 8 +- .../matching/BNDMMatcherConstruction.h | 6 +- .../matching/ExactMatchingAutomaton.cpp | 10 +- .../matching/ExactMatchingAutomaton.h | 7 +- .../src/stringology/query/BNDMOccurrences.cpp | 6 +- .../src/stringology/query/BNDMOccurrences.h | 6 +- .../query/BackwardDAWGMatching.cpp | 6 +- .../stringology/query/BackwardDAWGMatching.h | 3 +- .../query/BackwardOracleMatching.cpp | 6 +- .../query/BackwardOracleMatching.h | 10 +- .../string/properties/borderArrayTest.cpp | 3 +- .../stringology/query/DAWGMatcherTest.cpp | 6 +- .../stringology/query/OracleMatcherTest.cpp | 6 +- alib2cli/test-src/cli/CliTest.cpp | 1 - .../src/abstraction/PrimitiveRegistrator.cpp | 32 +- .../src/common/PrimitiveRegistrator2.cpp | 39 ++ astringology2/makefile.conf | 6 +- astringology2/src/astringology.cpp | 427 +++++------------- 58 files changed, 240 insertions(+), 612 deletions(-) create mode 100644 alib2data/src/common/PrimitiveRegistrator2.cpp diff --git a/alib2algo/src/string/properties/BadCharacterShiftTable.cpp b/alib2algo/src/string/properties/BadCharacterShiftTable.cpp index 99a3fdff80..023babfcdc 100644 --- a/alib2algo/src/string/properties/BadCharacterShiftTable.cpp +++ b/alib2algo/src/string/properties/BadCharacterShiftTable.cpp @@ -12,11 +12,7 @@ namespace string { namespace properties { -ext::map<DefaultSymbolType, size_t> BadCharacterShiftTable::bcs(const string::String& pattern) { - return dispatch(pattern.getData()); -} - -auto BadCharacterShiftTableLinearString = registration::OverloadRegister < BadCharacterShiftTable, ext::map < DefaultSymbolType, size_t >, string::LinearString < > > ( BadCharacterShiftTable::bcs ); +auto BadCharacterShiftTableLinearString = registration::AbstractRegister < BadCharacterShiftTable, ext::map < DefaultSymbolType, size_t >, const string::LinearString < > & > ( BadCharacterShiftTable::bcs ); } /* namespace properties */ diff --git a/alib2algo/src/string/properties/BadCharacterShiftTable.h b/alib2algo/src/string/properties/BadCharacterShiftTable.h index 710333e73d..2683572f1d 100644 --- a/alib2algo/src/string/properties/BadCharacterShiftTable.h +++ b/alib2algo/src/string/properties/BadCharacterShiftTable.h @@ -8,10 +8,6 @@ #ifndef _STRINGOLOGY_BAD_CHARACTER_SHIFT_TABLE_H_ #define _STRINGOLOGY_BAD_CHARACTER_SHIFT_TABLE_H_ -#include <string/String.h> -#include <string/StringFeatures.h> -#include <core/multipleDispatch.hpp> - #include <set> #include <map> @@ -25,14 +21,12 @@ namespace properties { * Computation of BCS table for BMH from MI(E+\eps)-EVY course 2014 * To get rid of zeros in BCS table we ignore last haystack character */ -class BadCharacterShiftTable : public alib::SingleDispatch < BadCharacterShiftTable, ext::map < DefaultSymbolType, size_t >, const string::StringBase & > { +class BadCharacterShiftTable { public: /** * Search for pattern in linear string. * @return set set of occurences */ - static ext::map < DefaultSymbolType, size_t > bcs ( const string::String & pattern ); - template < class SymbolType > static ext::map < SymbolType, size_t > bcs ( const string::LinearString < SymbolType > & pattern ); diff --git a/alib2algo/src/string/properties/BorderArray.cpp b/alib2algo/src/string/properties/BorderArray.cpp index d18920ef05..c514814d87 100644 --- a/alib2algo/src/string/properties/BorderArray.cpp +++ b/alib2algo/src/string/properties/BorderArray.cpp @@ -12,11 +12,7 @@ namespace string { namespace properties { -ext::vector<unsigned> BorderArray::construct(const string::String& string) { - return dispatch(string.getData()); -} - -auto BorderArrayLinearString = registration::OverloadRegister < BorderArray, ext::vector < unsigned >, string::LinearString < > > ( BorderArray::construct ); +auto BorderArrayLinearString = registration::AbstractRegister < BorderArray, ext::vector < unsigned >, const string::LinearString < > & > ( BorderArray::construct ); } /* namespace properties */ diff --git a/alib2algo/src/string/properties/BorderArray.h b/alib2algo/src/string/properties/BorderArray.h index 444346ccf8..2c6fc3d218 100644 --- a/alib2algo/src/string/properties/BorderArray.h +++ b/alib2algo/src/string/properties/BorderArray.h @@ -9,25 +9,19 @@ #define _BORDER_ARRAY_H_ #include <vector> -#include <core/multipleDispatch.hpp> -#include <string/StringFeatures.h> - -#include <string/String.h> #include <string/LinearString.h> namespace string { namespace properties { -class BorderArray : public alib::SingleDispatch<BorderArray, ext::vector<unsigned>, const string::StringBase &> { +class BorderArray { public: /** * Computes border array of string * @param string string to compute border array for * @return Vector of length same as string, where i-th index corresponds to i-th element of string */ - static ext::vector<unsigned> construct(const string::String& string); - template < class SymbolType > static ext::vector<unsigned> construct(const string::LinearString < SymbolType >& string); }; diff --git a/alib2algo/src/string/properties/GoodSuffixShiftTable.cpp b/alib2algo/src/string/properties/GoodSuffixShiftTable.cpp index ab667c938c..9a167fdbd0 100644 --- a/alib2algo/src/string/properties/GoodSuffixShiftTable.cpp +++ b/alib2algo/src/string/properties/GoodSuffixShiftTable.cpp @@ -12,11 +12,7 @@ namespace string { namespace properties { -ext::vector < size_t > GoodSuffixShiftTable::gss ( const string::String & pattern ) { - return dispatch ( pattern.getData ( ) ); -} - -auto GoodSuffixShiftTableLinearString = registration::OverloadRegister < GoodSuffixShiftTable, ext::vector < size_t >, string::LinearString < > > ( GoodSuffixShiftTable::gss ); +auto GoodSuffixShiftTableLinearString = registration::AbstractRegister < GoodSuffixShiftTable, ext::vector < size_t >, const string::LinearString < > & > ( GoodSuffixShiftTable::gss ); } /* namespace properties */ diff --git a/alib2algo/src/string/properties/GoodSuffixShiftTable.h b/alib2algo/src/string/properties/GoodSuffixShiftTable.h index 1e961018b6..22277a83de 100644 --- a/alib2algo/src/string/properties/GoodSuffixShiftTable.h +++ b/alib2algo/src/string/properties/GoodSuffixShiftTable.h @@ -8,10 +8,6 @@ #ifndef _STRINGOLOGY_GOOD_SUFFIX_SHIFT_TABLE_H_ #define _STRINGOLOGY_GOOD_SUFFIX_SHIFT_TABLE_H_ -#include <string/String.h> -#include <string/StringFeatures.h> -#include <core/multipleDispatch.hpp> - #include <vector> #include <string/LinearString.h> @@ -28,14 +24,12 @@ namespace properties { /** * Computation of GSS table for BM from MI(E+\eps)-EVY course 2014 */ -class GoodSuffixShiftTable : public alib::SingleDispatch < GoodSuffixShiftTable, ext::vector < size_t >, const string::StringBase & > { +class GoodSuffixShiftTable { public: /** * Search for pattern in linear string. * @return set set of occurences */ - static ext::vector < size_t > gss ( const string::String & pattern ); - template < class SymbolType > static ext::vector < size_t > gss ( const string::LinearString < SymbolType > & pattern ); diff --git a/alib2algo/src/string/properties/ReversedBadCharacterShiftTable.cpp b/alib2algo/src/string/properties/ReversedBadCharacterShiftTable.cpp index b7f63c3fb0..b428e45c63 100644 --- a/alib2algo/src/string/properties/ReversedBadCharacterShiftTable.cpp +++ b/alib2algo/src/string/properties/ReversedBadCharacterShiftTable.cpp @@ -12,11 +12,7 @@ namespace string { namespace properties { -ext::map < DefaultSymbolType, size_t > ReversedBadCharacterShiftTable::bcs ( const string::String & pattern ) { - return dispatch ( pattern.getData ( ) ); -} - -auto ReversedBadCharacterShiftTableLinearString = registration::OverloadRegister < ReversedBadCharacterShiftTable, ext::map < DefaultSymbolType, size_t >, string::LinearString < > > ( ReversedBadCharacterShiftTable::bcs ); +auto ReversedBadCharacterShiftTableLinearString = registration::AbstractRegister < ReversedBadCharacterShiftTable, ext::map < DefaultSymbolType, size_t >, const string::LinearString < > & > ( ReversedBadCharacterShiftTable::bcs ); } /* namespace properties */ diff --git a/alib2algo/src/string/properties/ReversedBadCharacterShiftTable.h b/alib2algo/src/string/properties/ReversedBadCharacterShiftTable.h index 9577100ee5..ab6889f5d1 100644 --- a/alib2algo/src/string/properties/ReversedBadCharacterShiftTable.h +++ b/alib2algo/src/string/properties/ReversedBadCharacterShiftTable.h @@ -8,10 +8,6 @@ #ifndef _STRINGOLOGY_REVERSED_BAD_CHARACTER_SHIFT_TABLE_H_ #define _STRINGOLOGY_REVERSED_BAD_CHARACTER_SHIFT_TABLE_H_ -#include <string/String.h> -#include <string/StringFeatures.h> -#include <core/multipleDispatch.hpp> - #include <set> #include <map> @@ -25,14 +21,12 @@ namespace properties { * Computation of BCS table for BMH from MI(E+\eps)-EVY course 2014 * To get rid of zeros in BCS table we ignore last haystack character */ -class ReversedBadCharacterShiftTable : public alib::SingleDispatch < ReversedBadCharacterShiftTable, ext::map < DefaultSymbolType, size_t >, const string::StringBase & > { +class ReversedBadCharacterShiftTable { public: /** * Search for pattern in linear string. * @return set set of occurences */ - static ext::map < DefaultSymbolType, size_t > bcs ( const string::String & pattern ); - template < class SymbolType > static ext::map < SymbolType, size_t > bcs ( const string::LinearString < SymbolType > & pattern ); diff --git a/alib2algo/src/stringology/exact/BoyerMoore.cpp b/alib2algo/src/stringology/exact/BoyerMoore.cpp index 01d818c72e..90acb0c7b4 100644 --- a/alib2algo/src/stringology/exact/BoyerMoore.cpp +++ b/alib2algo/src/stringology/exact/BoyerMoore.cpp @@ -12,11 +12,7 @@ namespace stringology { namespace exact { -ext::set<unsigned> BoyerMoore::match(const string::String& subject, const string::String& pattern) { - return dispatch(subject.getData(), pattern.getData()); -} - -auto BoyerMooreLinearStringLinearString = registration::OverloadRegister < BoyerMoore, ext::set < unsigned >, string::LinearString < >, string::LinearString < > > ( BoyerMoore::match ); +auto BoyerMooreLinearStringLinearString = registration::AbstractRegister < BoyerMoore, ext::set < unsigned >, const string::LinearString < > &, const string::LinearString < > & > ( BoyerMoore::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BoyerMoore.h b/alib2algo/src/stringology/exact/BoyerMoore.h index eca142fa61..86d699bc3c 100644 --- a/alib2algo/src/stringology/exact/BoyerMoore.h +++ b/alib2algo/src/stringology/exact/BoyerMoore.h @@ -12,10 +12,6 @@ #include <map> #include <measure> -#include <core/multipleDispatch.hpp> - -#include <string/String.h> -#include <string/StringFeatures.h> #include <string/LinearString.h> #include <string/properties/BadCharacterShiftTable.h> @@ -29,14 +25,12 @@ namespace exact { * Implementation of BM for MI(E+\eps)-EVY course 2014 * To get rid of zeros in BCS table we ignore last haystack character */ -class BoyerMoore : public alib::DoubleDispatch < BoyerMoore, ext::set < unsigned >, const string::StringBase &, const string::StringBase & > { +class BoyerMoore { public: /** * Search for pattern in linear string. * @return set set of occurences */ - static ext::set < unsigned > match ( const string::String & subject, const string::String & pattern ); - template < class SymbolType > static ext::set < unsigned > match ( const string::LinearString < SymbolType > & subject, const string::LinearString < SymbolType > & pattern ); diff --git a/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp b/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp index d5c835a3eb..c4197b5ff9 100644 --- a/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp +++ b/alib2algo/src/stringology/exact/BoyerMooreHorspool.cpp @@ -12,11 +12,7 @@ namespace stringology { namespace exact { -ext::set<unsigned> BoyerMooreHorspool::match(const string::String& subject, const string::String& pattern) { - return dispatch(subject.getData(), pattern.getData()); -} - -auto BoyerMooreHorspoolLinearStringLinearString = registration::OverloadRegister < BoyerMooreHorspool, ext::set < unsigned >, string::LinearString < >, string::LinearString < > > ( BoyerMooreHorspool::match ); +auto BoyerMooreHorspoolLinearStringLinearString = registration::AbstractRegister < BoyerMooreHorspool, ext::set < unsigned >, const string::LinearString < > &, const string::LinearString < > & > ( BoyerMooreHorspool::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BoyerMooreHorspool.h b/alib2algo/src/stringology/exact/BoyerMooreHorspool.h index 698b42d89e..e0eb289532 100644 --- a/alib2algo/src/stringology/exact/BoyerMooreHorspool.h +++ b/alib2algo/src/stringology/exact/BoyerMooreHorspool.h @@ -12,10 +12,6 @@ #include <map> #include <measure> -#include <core/multipleDispatch.hpp> - -#include <string/String.h> -#include <string/StringFeatures.h> #include <string/LinearString.h> #include <string/properties/BadCharacterShiftTable.h> @@ -28,14 +24,12 @@ namespace exact { * Implementation of BMH for MI(E+\eps)-EVY course 2014 * To get rid of zeros in BCS table we ignore last haystack character */ -class BoyerMooreHorspool : public alib::DoubleDispatch < BoyerMooreHorspool, ext::set < unsigned >, const string::StringBase &, const string::StringBase & > { +class BoyerMooreHorspool { public: /** * Search for pattern in linear string. * @return set set of occurences */ - static ext::set < unsigned > match ( const string::String & subject, const string::String & pattern ); - template < class SymbolType > static ext::set < unsigned > match ( const string::LinearString < SymbolType > & subject, const string::LinearString < SymbolType > & pattern ); diff --git a/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.cpp b/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.cpp index 043738cf4f..bd13c89740 100644 --- a/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.cpp +++ b/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.cpp @@ -12,11 +12,7 @@ namespace stringology { namespace exact { -ext::set < unsigned > DeadZoneUsingBadCharacterShift::match ( const string::String & subject, const string::String & pattern ) { - return dispatch ( subject.getData ( ), pattern.getData ( ) ); -} - -auto DeadZoneUsingBadCharacterShiftLinearStringLinearString = registration::OverloadRegister < DeadZoneUsingBadCharacterShift, ext::set < unsigned >, string::LinearString < >, string::LinearString < > > ( DeadZoneUsingBadCharacterShift::match ); +auto DeadZoneUsingBadCharacterShiftLinearStringLinearString = registration::AbstractRegister < DeadZoneUsingBadCharacterShift, ext::set < unsigned >, const string::LinearString < > &, const string::LinearString < > & > ( DeadZoneUsingBadCharacterShift::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.h b/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.h index dfbce317ed..6027934fac 100644 --- a/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.h +++ b/alib2algo/src/stringology/exact/DeadZoneUsingBadCharacterShift.h @@ -11,9 +11,6 @@ #include <set> #include <map> -#include <core/multipleDispatch.hpp> -#include <string/String.h> -#include <string/StringFeatures.h> #include <string/LinearString.h> #include <string/properties/BadCharacterShiftTable.h> @@ -26,7 +23,7 @@ namespace exact { /** * Implementation of DeadZone matching using bcs as shifting method to both directions */ -class DeadZoneUsingBadCharacterShift : public alib::DoubleDispatch < DeadZoneUsingBadCharacterShift, ext::set < unsigned >, const string::StringBase &, const string::StringBase & > { +class DeadZoneUsingBadCharacterShift { template < class SymbolType > static void match_rec ( ext::set < unsigned > & occ, const string::LinearString < SymbolType > & string, const string::LinearString < SymbolType > & pattern, ext::map < SymbolType, size_t > & fbcs, ext::map < SymbolType, size_t > & bbcs, int low, int high ); @@ -35,8 +32,6 @@ public: * Search for pattern in linear string. * @return set set of occurences */ - static ext::set < unsigned > match ( const string::String & subject, const string::String & pattern ); - template < class SymbolType > static ext::set < unsigned > match ( const string::LinearString < SymbolType > & subject, const string::LinearString < SymbolType > & pattern ); }; diff --git a/alib2algo/src/stringology/exact/ExactFactorMatch.cpp b/alib2algo/src/stringology/exact/ExactFactorMatch.cpp index 6712bf0bc2..fce3c6c43c 100644 --- a/alib2algo/src/stringology/exact/ExactFactorMatch.cpp +++ b/alib2algo/src/stringology/exact/ExactFactorMatch.cpp @@ -12,11 +12,7 @@ namespace stringology { namespace exact { -ext::set < unsigned > ExactFactorMatch::match ( const string::String & subject, const string::String & pattern ) { - return dispatch ( subject.getData ( ), pattern.getData ( ) ); -} - -auto ExactFactorMatchLinearString = registration::OverloadRegister < ExactFactorMatch, ext::set < unsigned >, string::LinearString < > > ( ExactFactorMatch::match ); +auto ExactFactorMatchLinearString = registration::AbstractRegister < ExactFactorMatch, ext::set < unsigned >, const string::LinearString < > &, const string::LinearString < > & > ( ExactFactorMatch::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactFactorMatch.h b/alib2algo/src/stringology/exact/ExactFactorMatch.h index 54df2a524c..08321f3f53 100644 --- a/alib2algo/src/stringology/exact/ExactFactorMatch.h +++ b/alib2algo/src/stringology/exact/ExactFactorMatch.h @@ -11,24 +11,18 @@ #include <set> #include <deque> -#include <core/multipleDispatch.hpp> - -#include <string/String.h> -#include <string/StringFeatures.h> #include <string/LinearString.h> namespace stringology { namespace exact { -class ExactFactorMatch : public alib::PromotingDoubleDispatch<ExactFactorMatch, ext::set<unsigned>, const string::StringBase & > { +class ExactFactorMatch { public: /** * Performs conversion. * @return left regular grammar equivalent to source automaton. */ - static ext::set<unsigned> match(const string::String& subject, const string::String& pattern); - template < class SymbolType > static ext::set<unsigned> match(const string::LinearString < SymbolType >& subject, const string::LinearString < SymbolType >& pattern); }; diff --git a/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.cpp b/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.cpp index 205ce30b7b..95201143e4 100644 --- a/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.cpp +++ b/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.cpp @@ -12,11 +12,7 @@ namespace stringology { namespace exact { -ext::set < unsigned > ReversedBoyerMooreHorspool::match ( const string::String & subject, const string::String & pattern ) { - return dispatch ( subject.getData ( ), pattern.getData ( ) ); -} - -auto ReversedBoyerMooreHorpoolLinearStringLinearString = registration::OverloadRegister < ReversedBoyerMooreHorspool, ext::set < unsigned >, string::LinearString < >, string::LinearString < > > ( ReversedBoyerMooreHorspool::match ); +auto ReversedBoyerMooreHorpoolLinearStringLinearString = registration::AbstractRegister < ReversedBoyerMooreHorspool, ext::set < unsigned >, const string::LinearString < > &, const string::LinearString < > & > ( ReversedBoyerMooreHorspool::match ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.h b/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.h index b2fbd1884b..9d74fe054a 100644 --- a/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.h +++ b/alib2algo/src/stringology/exact/ReversedBoyerMooreHorspool.h @@ -11,10 +11,6 @@ #include <set> #include <map> -#include <core/multipleDispatch.hpp> - -#include <string/String.h> -#include <string/StringFeatures.h> #include <string/LinearString.h> #include <string/properties/ReversedBadCharacterShiftTable.h> @@ -27,14 +23,12 @@ namespace exact { * Implementation of BMH for MI(E+\eps)-EVY course 2014 (Reversed) * To get rid of zeros in BCS table we ignore last haystack character */ -class ReversedBoyerMooreHorspool : public alib::DoubleDispatch < ReversedBoyerMooreHorspool, ext::set < unsigned >, const string::StringBase &, const string::StringBase & > { +class ReversedBoyerMooreHorspool { public: /** * Search for pattern in linear string. * @return set set of occurences */ - static ext::set < unsigned > match ( const string::String & subject, const string::String & pattern ); - template < class SymbolType > static ext::set < unsigned > match ( const string::LinearString < SymbolType > & subject, const string::LinearString < SymbolType > & pattern ); diff --git a/alib2algo/src/stringology/indexing/BitParallelIndexConstruction.cpp b/alib2algo/src/stringology/indexing/BitParallelIndexConstruction.cpp index 0ff8dbd626..8e5b919aed 100644 --- a/alib2algo/src/stringology/indexing/BitParallelIndexConstruction.cpp +++ b/alib2algo/src/stringology/indexing/BitParallelIndexConstruction.cpp @@ -6,19 +6,13 @@ */ #include "BitParallelIndexConstruction.h" - -#include <string/LinearString.h> #include <registration/AlgoRegistration.hpp> namespace stringology { namespace indexing { -indexes::stringology::BitParallelIndex < DefaultSymbolType > BitParallelIndexConstruction::construct ( const string::String & string ) { - return dispatch ( string.getData ( ) ); -} - -auto bitParallelIndexConstructionLinearString = registration::OverloadRegister < BitParallelIndexConstruction, indexes::stringology::BitParallelIndex < DefaultSymbolType >, string::LinearString < > > ( BitParallelIndexConstruction::construct ); +auto bitParallelIndexConstructionLinearString = registration::AbstractRegister < BitParallelIndexConstruction, indexes::stringology::BitParallelIndex < DefaultSymbolType >, const string::LinearString < > & > ( BitParallelIndexConstruction::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/BitParallelIndexConstruction.h b/alib2algo/src/stringology/indexing/BitParallelIndexConstruction.h index 80fb7c4e65..99c69bcacd 100644 --- a/alib2algo/src/stringology/indexing/BitParallelIndexConstruction.h +++ b/alib2algo/src/stringology/indexing/BitParallelIndexConstruction.h @@ -9,9 +9,7 @@ #define BIT_PARALLEL_INDEX_CONSTRUCTION_H_ #include <indexes/stringology/BitParallelIndex.h> -#include <string/String.h> #include <string/LinearString.h> -#include <core/multipleDispatch.hpp> #include <exception/CommonException.h> namespace stringology { @@ -23,15 +21,13 @@ namespace indexing { * */ -class BitParallelIndexConstruction : public alib::SingleDispatch < BitParallelIndexConstruction, indexes::stringology::BitParallelIndex < DefaultSymbolType >, const string::StringBase & > { +class BitParallelIndexConstruction { public: /** * Creates suffix trie * @param string string to construct suffix trie for * @return automaton */ - static indexes::stringology::BitParallelIndex < DefaultSymbolType > construct ( const string::String & string ); - template < class SymbolType > static indexes::stringology::BitParallelIndex < SymbolType > construct ( const string::LinearString < SymbolType > & string ); diff --git a/alib2algo/src/stringology/indexing/CompressedBitParallelIndexConstruction.cpp b/alib2algo/src/stringology/indexing/CompressedBitParallelIndexConstruction.cpp index 1621e935b0..fbbdc355c2 100644 --- a/alib2algo/src/stringology/indexing/CompressedBitParallelIndexConstruction.cpp +++ b/alib2algo/src/stringology/indexing/CompressedBitParallelIndexConstruction.cpp @@ -6,19 +6,13 @@ */ #include "CompressedBitParallelIndexConstruction.h" - -#include <string/LinearString.h> #include <registration/AlgoRegistration.hpp> namespace stringology { namespace indexing { -indexes::stringology::CompressedBitParallelIndex < DefaultSymbolType > CompressedBitParallelIndexConstruction::construct ( const string::String & string ) { - return dispatch ( string.getData ( ) ); -} - -auto compressedCompressedBitParallelIndexConstructionLinearString = registration::OverloadRegister < CompressedBitParallelIndexConstruction, indexes::stringology::CompressedBitParallelIndex < DefaultSymbolType >, string::LinearString < > > ( CompressedBitParallelIndexConstruction::construct ); +auto compressedCompressedBitParallelIndexConstructionLinearString = registration::AbstractRegister < CompressedBitParallelIndexConstruction, indexes::stringology::CompressedBitParallelIndex < DefaultSymbolType >, const string::LinearString < > & > ( CompressedBitParallelIndexConstruction::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/CompressedBitParallelIndexConstruction.h b/alib2algo/src/stringology/indexing/CompressedBitParallelIndexConstruction.h index a68439ffe6..3ee436e590 100644 --- a/alib2algo/src/stringology/indexing/CompressedBitParallelIndexConstruction.h +++ b/alib2algo/src/stringology/indexing/CompressedBitParallelIndexConstruction.h @@ -9,9 +9,7 @@ #define COMPRESSED_BIT_PARALLEL_INDEX_CONSTRUCTION_H_ #include <indexes/stringology/CompressedBitParallelIndex.h> -#include <string/String.h> #include <string/LinearString.h> -#include <core/multipleDispatch.hpp> #include <exception/CommonException.h> namespace stringology { @@ -23,15 +21,13 @@ namespace indexing { * */ -class CompressedBitParallelIndexConstruction : public alib::SingleDispatch < CompressedBitParallelIndexConstruction, indexes::stringology::CompressedBitParallelIndex < DefaultSymbolType >, const string::StringBase & > { +class CompressedBitParallelIndexConstruction { public: /** * Creates suffix trie * @param string string to construct suffix trie for * @return automaton */ - static indexes::stringology::CompressedBitParallelIndex < DefaultSymbolType > construct ( const string::String & string ); - template < class SymbolType > static indexes::stringology::CompressedBitParallelIndex < SymbolType > construct ( const string::LinearString < SymbolType > & string ); diff --git a/alib2algo/src/stringology/indexing/ExactFactorOracleAutomaton.cpp b/alib2algo/src/stringology/indexing/ExactFactorOracleAutomaton.cpp index cfdbbe32e0..0ae9e9a3c9 100644 --- a/alib2algo/src/stringology/indexing/ExactFactorOracleAutomaton.cpp +++ b/alib2algo/src/stringology/indexing/ExactFactorOracleAutomaton.cpp @@ -10,10 +10,6 @@ namespace stringology { namespace indexing { -automaton::Automaton ExactFactorOracleAutomaton::construct ( const string::String & pattern ) { - return dispatch ( pattern.getData ( ) ); -} - automaton::DFA < > ExactFactorOracleAutomaton::construct ( const string::LinearString < > & pattern ) { automaton::DFA < > oracle ( DefaultStateType ( 0 ) ); @@ -54,7 +50,7 @@ void ExactFactorOracleAutomaton::oracleAddLetter ( automaton::DFA < > & oracle, supplyFunction.insert( { newState, supplyState } ); } -auto FactorOracleAutomatonLinearString = registration::OverloadRegister < ExactFactorOracleAutomaton, automaton::DFA < >, string::LinearString < > > ( ExactFactorOracleAutomaton::construct ); +auto FactorOracleAutomatonLinearString = registration::AbstractRegister < ExactFactorOracleAutomaton, automaton::DFA < >, const string::LinearString < > & > ( ExactFactorOracleAutomaton::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/ExactFactorOracleAutomaton.h b/alib2algo/src/stringology/indexing/ExactFactorOracleAutomaton.h index c5b9572acd..b8e120198b 100644 --- a/alib2algo/src/stringology/indexing/ExactFactorOracleAutomaton.h +++ b/alib2algo/src/stringology/indexing/ExactFactorOracleAutomaton.h @@ -5,17 +5,14 @@ #ifndef EXACT_FACTOR_ORACLE_AUTOMATON_H_ #define EXACT_FACTOR_ORACLE_AUTOMATON_H_ -#include <automaton/Automaton.h> #include <automaton/FSM/DFA.h> #include <string/LinearString.h> -#include <string/String.h> -#include <core/multipleDispatch.hpp> namespace stringology { namespace indexing { -class ExactFactorOracleAutomaton : public alib::SingleDispatch < ExactFactorOracleAutomaton, automaton::Automaton, const string::StringBase & > { +class ExactFactorOracleAutomaton { private: static void oracleAddLetter ( automaton::DFA < > & oracle, const DefaultSymbolType & symbol, ext::map < DefaultStateType, DefaultStateType > & supplyFunction ); @@ -24,8 +21,6 @@ public: * Constructs factor oracle automaton for given pattern. * @return factor oracle automaton for given pattern */ - static automaton::Automaton construct ( const string::String & pattern ); - static automaton::DFA < > construct ( const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/indexing/ExactMultiNondeterministicSubsequenceAutomaton.cpp b/alib2algo/src/stringology/indexing/ExactMultiNondeterministicSubsequenceAutomaton.cpp index 0d4c98e777..dbe73e20eb 100644 --- a/alib2algo/src/stringology/indexing/ExactMultiNondeterministicSubsequenceAutomaton.cpp +++ b/alib2algo/src/stringology/indexing/ExactMultiNondeterministicSubsequenceAutomaton.cpp @@ -13,10 +13,6 @@ namespace stringology { namespace indexing { -automaton::Automaton ExactMultiNondeterministicSubsequenceAutomaton::construct ( const ext::set < string::String > & texts ) { - return automaton::Automaton ( ExactMultiNondeterministicSubsequenceAutomaton::construct ( common::ContainerConverter < ext::set < string::LinearString < > >, ext::set < string::String >, string::LinearString < > >::convert ( texts ) ) ); -} - auto ExactMultiNondeterministicSubsequenceAutomatonLinearString = registration::AbstractRegister < ExactMultiNondeterministicSubsequenceAutomaton, automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, ext::pair < unsigned, unsigned > >, const ext::set < string::LinearString < > > & > ( ExactMultiNondeterministicSubsequenceAutomaton::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/ExactMultiNondeterministicSubsequenceAutomaton.h b/alib2algo/src/stringology/indexing/ExactMultiNondeterministicSubsequenceAutomaton.h index e03306473f..65fb7609a8 100644 --- a/alib2algo/src/stringology/indexing/ExactMultiNondeterministicSubsequenceAutomaton.h +++ b/alib2algo/src/stringology/indexing/ExactMultiNondeterministicSubsequenceAutomaton.h @@ -25,8 +25,6 @@ public: * Performs conversion. * @return left regular grammar equivalent to source automaton. */ - static automaton::Automaton construct ( const ext::set < string::String > & text ); - template < class SymbolType > static automaton::EpsilonNFA < SymbolType, DefaultEpsilonType, ext::pair < unsigned, unsigned > > construct ( const ext::set < string::LinearString < SymbolType > > & text); }; diff --git a/alib2algo/src/stringology/indexing/ExactNondeterministicSubsequenceAutomaton.cpp b/alib2algo/src/stringology/indexing/ExactNondeterministicSubsequenceAutomaton.cpp index 7a0c25b44b..6f138f6533 100644 --- a/alib2algo/src/stringology/indexing/ExactNondeterministicSubsequenceAutomaton.cpp +++ b/alib2algo/src/stringology/indexing/ExactNondeterministicSubsequenceAutomaton.cpp @@ -12,11 +12,7 @@ namespace stringology { namespace indexing { -automaton::Automaton ExactNondeterministicSubsequenceAutomaton::construct(const string::String& text) { - return dispatch(text.getData()); -} - -auto ExactNondeterministicSubsequenceAutomatonLinearString = registration::OverloadRegister < ExactNondeterministicSubsequenceAutomaton, automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, unsigned >, string::LinearString < > > ( ExactNondeterministicSubsequenceAutomaton::construct ); +auto ExactNondeterministicSubsequenceAutomatonLinearString = registration::AbstractRegister < ExactNondeterministicSubsequenceAutomaton, automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, unsigned >, const string::LinearString < > & > ( ExactNondeterministicSubsequenceAutomaton::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/ExactNondeterministicSubsequenceAutomaton.h b/alib2algo/src/stringology/indexing/ExactNondeterministicSubsequenceAutomaton.h index 51996ff31d..4d867e452f 100644 --- a/alib2algo/src/stringology/indexing/ExactNondeterministicSubsequenceAutomaton.h +++ b/alib2algo/src/stringology/indexing/ExactNondeterministicSubsequenceAutomaton.h @@ -8,24 +8,19 @@ #ifndef _EXACT_NONDETERMINISTIC_SUBSEQUENCE_AUTOMATON__H_ #define _EXACT_NONDETERMINISTIC_SUBSEQUENCE_AUTOMATON__H_ -#include <automaton/Automaton.h> #include <automaton/FSM/EpsilonNFA.h> #include <string/LinearString.h> -#include <string/String.h> -#include <core/multipleDispatch.hpp> namespace stringology { namespace indexing { -class ExactNondeterministicSubsequenceAutomaton : public alib::SingleDispatch<ExactNondeterministicSubsequenceAutomaton, automaton::Automaton, const string::StringBase & > { +class ExactNondeterministicSubsequenceAutomaton { public: /** * Performs conversion. * @return left regular grammar equivalent to source automaton. */ - static automaton::Automaton construct(const string::String& text); - template < class SymbolType > static automaton::EpsilonNFA < SymbolType, DefaultEpsilonType, unsigned > construct ( const string::LinearString < SymbolType > & text ); }; diff --git a/alib2algo/src/stringology/indexing/ExactSubsequenceAutomaton.cpp b/alib2algo/src/stringology/indexing/ExactSubsequenceAutomaton.cpp index 185498842f..5892c3ef7c 100644 --- a/alib2algo/src/stringology/indexing/ExactSubsequenceAutomaton.cpp +++ b/alib2algo/src/stringology/indexing/ExactSubsequenceAutomaton.cpp @@ -12,11 +12,7 @@ namespace stringology { namespace indexing { -automaton::Automaton ExactSubsequenceAutomaton::construct(const string::String& text) { - return dispatch(text.getData()); -} - -auto ExactSubsequenceAutomatonLinearString = registration::OverloadRegister < ExactSubsequenceAutomaton, automaton::DFA < DefaultSymbolType, unsigned >, string::LinearString < > > ( ExactSubsequenceAutomaton::construct ); +auto ExactSubsequenceAutomatonLinearString = registration::AbstractRegister < ExactSubsequenceAutomaton, automaton::DFA < DefaultSymbolType, unsigned >, const string::LinearString < > & > ( ExactSubsequenceAutomaton::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/ExactSubsequenceAutomaton.h b/alib2algo/src/stringology/indexing/ExactSubsequenceAutomaton.h index 8a7a695e6c..2e3414c98a 100644 --- a/alib2algo/src/stringology/indexing/ExactSubsequenceAutomaton.h +++ b/alib2algo/src/stringology/indexing/ExactSubsequenceAutomaton.h @@ -8,24 +8,19 @@ #ifndef _EXACT_SUBSEQUENCE_AUTOMATON__H_ #define _EXACT_SUBSEQUENCE_AUTOMATON__H_ -#include <automaton/Automaton.h> #include <automaton/FSM/DFA.h> #include <string/LinearString.h> -#include <string/String.h> -#include <core/multipleDispatch.hpp> namespace stringology { namespace indexing { -class ExactSubsequenceAutomaton : public alib::SingleDispatch<ExactSubsequenceAutomaton, automaton::Automaton, const string::StringBase & > { +class ExactSubsequenceAutomaton { public: /** * Performs conversion. * @return left regular grammar equivalent to source automaton. */ - static automaton::Automaton construct ( const string::String & text ); - template < class SymbolType > static automaton::DFA < SymbolType, unsigned > construct ( const string::LinearString < SymbolType > & text ); }; diff --git a/alib2algo/src/stringology/indexing/NondeterministicExactFactorAutomaton.cpp b/alib2algo/src/stringology/indexing/NondeterministicExactFactorAutomaton.cpp index ca86dc7c6d..c2e2a639bc 100644 --- a/alib2algo/src/stringology/indexing/NondeterministicExactFactorAutomaton.cpp +++ b/alib2algo/src/stringology/indexing/NondeterministicExactFactorAutomaton.cpp @@ -16,11 +16,7 @@ namespace stringology { namespace indexing { -automaton::Automaton NondeterministicExactFactorAutomaton::construct(const string::String& text) { - return dispatch(text.getData()); -} - -auto ExactFactorAutomatonLinearString = registration::OverloadRegister < NondeterministicExactFactorAutomaton, automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, unsigned >, string::LinearString < > > ( NondeterministicExactFactorAutomaton::construct ); +auto ExactFactorAutomatonLinearString = registration::AbstractRegister < NondeterministicExactFactorAutomaton, automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, unsigned >, const string::LinearString < > & > ( NondeterministicExactFactorAutomaton::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/NondeterministicExactFactorAutomaton.h b/alib2algo/src/stringology/indexing/NondeterministicExactFactorAutomaton.h index 96b1cca8d5..785645e251 100644 --- a/alib2algo/src/stringology/indexing/NondeterministicExactFactorAutomaton.h +++ b/alib2algo/src/stringology/indexing/NondeterministicExactFactorAutomaton.h @@ -8,25 +8,20 @@ #ifndef NONDETERMINISTIC_EXACT_FACTOR_AUTOMATON_H_ #define NONDETERMINISTIC_EXACT_FACTOR_AUTOMATON_H_ -#include <automaton/Automaton.h> #include <automaton/FSM/EpsilonNFA.h> #include <string/LinearString.h> -#include <string/String.h> -#include <core/multipleDispatch.hpp> #include <primitive/Unsigned.h> namespace stringology { namespace indexing { -class NondeterministicExactFactorAutomaton : public alib::SingleDispatch<NondeterministicExactFactorAutomaton, automaton::Automaton, const string::StringBase & > { +class NondeterministicExactFactorAutomaton { public: /** * Performs conversion. * @return left regular grammar equivalent to source automaton. */ - static automaton::Automaton construct(const string::String& text); - template < class SymbolType > static automaton::EpsilonNFA < SymbolType, DefaultEpsilonType, unsigned > construct(const string::LinearString < SymbolType > & text); }; diff --git a/alib2algo/src/stringology/indexing/NondeterministicExactSuffixAutomaton.cpp b/alib2algo/src/stringology/indexing/NondeterministicExactSuffixAutomaton.cpp index 9e387658c1..51103a5951 100644 --- a/alib2algo/src/stringology/indexing/NondeterministicExactSuffixAutomaton.cpp +++ b/alib2algo/src/stringology/indexing/NondeterministicExactSuffixAutomaton.cpp @@ -9,10 +9,6 @@ namespace stringology { namespace indexing { -automaton::Automaton NondeterministicExactSuffixAutomaton::construct ( const string::String & pattern ) { - return dispatch ( pattern.getData ( ) ); -} - automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, unsigned > NondeterministicExactSuffixAutomaton::construct ( const string::LinearString < > & pattern ) { automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, unsigned > nfaSuffixAutomaton ( 0 ); @@ -30,7 +26,7 @@ automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, unsigned > Nondet return nfaSuffixAutomaton; } -auto SuffixAutomatonNondeterministicLinearString = registration::OverloadRegister < NondeterministicExactSuffixAutomaton, automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, unsigned >, string::LinearString < > > ( NondeterministicExactSuffixAutomaton::construct ); +auto SuffixAutomatonNondeterministicLinearString = registration::AbstractRegister < NondeterministicExactSuffixAutomaton, automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, unsigned >, const string::LinearString < > & > ( NondeterministicExactSuffixAutomaton::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/NondeterministicExactSuffixAutomaton.h b/alib2algo/src/stringology/indexing/NondeterministicExactSuffixAutomaton.h index ddbc37c41f..723c0ef9b6 100644 --- a/alib2algo/src/stringology/indexing/NondeterministicExactSuffixAutomaton.h +++ b/alib2algo/src/stringology/indexing/NondeterministicExactSuffixAutomaton.h @@ -5,25 +5,20 @@ #ifndef NONDETERMINISTIC_EXACT_SUFFIX_AUTOMATON_H_ #define NONDETERMINISTIC_EXACT_SUFFIX_AUTOMATON_H_ -#include <automaton/Automaton.h> #include <automaton/FSM/EpsilonNFA.h> #include <string/LinearString.h> -#include <string/String.h> -#include <core/multipleDispatch.hpp> #include <primitive/Unsigned.h> namespace stringology { namespace indexing { -class NondeterministicExactSuffixAutomaton : public alib::SingleDispatch < NondeterministicExactSuffixAutomaton, automaton::Automaton, const string::StringBase & > { +class NondeterministicExactSuffixAutomaton { public: /** * Nondeterministic construction of nondeterministic suffix automaton for given pattern. * @return nondeterministic suffix automaton for given pattern. */ - static automaton::Automaton construct ( const string::String & pattern ); - static automaton::EpsilonNFA < DefaultSymbolType, DefaultEpsilonType, unsigned > construct ( const string::LinearString < > & pattern ); }; diff --git a/alib2algo/src/stringology/indexing/PositionHeapNaive.cpp b/alib2algo/src/stringology/indexing/PositionHeapNaive.cpp index e9dc4ffbfa..8fe5ab8dab 100644 --- a/alib2algo/src/stringology/indexing/PositionHeapNaive.cpp +++ b/alib2algo/src/stringology/indexing/PositionHeapNaive.cpp @@ -6,19 +6,13 @@ */ #include "PositionHeapNaive.h" - -#include <string/LinearString.h> #include <registration/AlgoRegistration.hpp> namespace stringology { namespace indexing { -indexes::stringology::PositionHeap < DefaultSymbolType > PositionHeapNaive::construct ( const string::String & string ) { - return dispatch ( string.getData ( ) ); -} - -auto positionHeapNaiveLinearString = registration::OverloadRegister < PositionHeapNaive, indexes::stringology::PositionHeap < DefaultSymbolType >, string::LinearString < > > ( PositionHeapNaive::construct ); +auto positionHeapNaiveLinearString = registration::AbstractRegister < PositionHeapNaive, indexes::stringology::PositionHeap < DefaultSymbolType >, const string::LinearString < > & > ( PositionHeapNaive::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/PositionHeapNaive.h b/alib2algo/src/stringology/indexing/PositionHeapNaive.h index 98eb5416f6..520d723e06 100644 --- a/alib2algo/src/stringology/indexing/PositionHeapNaive.h +++ b/alib2algo/src/stringology/indexing/PositionHeapNaive.h @@ -9,9 +9,7 @@ #define POSITION_HEAP_NAIVE_H_ #include <indexes/stringology/PositionHeap.h> -#include <string/String.h> #include <string/LinearString.h> -#include <core/multipleDispatch.hpp> #include <exception/CommonException.h> namespace stringology { @@ -25,15 +23,13 @@ namespace indexing { * Andrzej Ehrenfeucht, Ross M. McConnell, Nissa Osheim, Sung-Whan Woo */ -class PositionHeapNaive : public alib::SingleDispatch < PositionHeapNaive, indexes::stringology::PositionHeap < DefaultSymbolType >, const string::StringBase & > { +class PositionHeapNaive { public: /** * Creates suffix trie * @param string string to construct suffix trie for * @return automaton */ - static indexes::stringology::PositionHeap < DefaultSymbolType > construct ( const string::String & string ); - template < class SymbolType > static indexes::stringology::PositionHeap < SymbolType > construct ( const string::LinearString < SymbolType > & string ); diff --git a/alib2algo/src/stringology/indexing/SuffixArrayNaive.cpp b/alib2algo/src/stringology/indexing/SuffixArrayNaive.cpp index 4a4d26a02c..f1fe0f3276 100644 --- a/alib2algo/src/stringology/indexing/SuffixArrayNaive.cpp +++ b/alib2algo/src/stringology/indexing/SuffixArrayNaive.cpp @@ -6,19 +6,13 @@ */ #include "SuffixArrayNaive.h" - -#include <string/LinearString.h> #include <registration/AlgoRegistration.hpp> namespace stringology { namespace indexing { -indexes::stringology::SuffixArray < > SuffixArrayNaive::construct ( const string::String & string ) { - return dispatch ( string.getData ( ) ); -} - -auto suffixArrayNaiveLinearString = registration::OverloadRegister < SuffixArrayNaive, indexes::stringology::SuffixArray < >, string::LinearString < > > ( SuffixArrayNaive::construct ); +auto suffixArrayNaiveLinearString = registration::AbstractRegister < SuffixArrayNaive, indexes::stringology::SuffixArray < >, const string::LinearString < > & > ( SuffixArrayNaive::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/SuffixArrayNaive.h b/alib2algo/src/stringology/indexing/SuffixArrayNaive.h index 7d2fb25ed3..8ab969e79b 100644 --- a/alib2algo/src/stringology/indexing/SuffixArrayNaive.h +++ b/alib2algo/src/stringology/indexing/SuffixArrayNaive.h @@ -9,9 +9,7 @@ #define SUFFIX_ARRAY_NAIVE_H_ #include <indexes/stringology/SuffixArray.h> -#include <string/String.h> #include <string/LinearString.h> -#include <core/multipleDispatch.hpp> namespace stringology { @@ -22,15 +20,13 @@ namespace indexing { * */ -class SuffixArrayNaive : public alib::SingleDispatch < SuffixArrayNaive, indexes::stringology::SuffixArray < >, const string::StringBase & > { +class SuffixArrayNaive { public: /** * Creates suffix trie * @param string string to construct suffix trie for * @return automaton */ - static indexes::stringology::SuffixArray < > construct ( const string::String & string ); - template < class SymbolType > static indexes::stringology::SuffixArray < SymbolType > construct ( const string::LinearString < SymbolType > & string ); diff --git a/alib2algo/src/stringology/indexing/SuffixTrieNaive.cpp b/alib2algo/src/stringology/indexing/SuffixTrieNaive.cpp index 82aa80eb7f..8e8986e867 100644 --- a/alib2algo/src/stringology/indexing/SuffixTrieNaive.cpp +++ b/alib2algo/src/stringology/indexing/SuffixTrieNaive.cpp @@ -14,11 +14,7 @@ namespace stringology { namespace indexing { -indexes::stringology::SuffixTrie < DefaultSymbolType > SuffixTrieNaive::construct ( const string::String & string ) { - return dispatch ( string.getData ( ) ); -} - -auto suffixTrieNaiveLinearString = registration::OverloadRegister < SuffixTrieNaive, indexes::stringology::SuffixTrie < DefaultSymbolType >, string::LinearString < > > ( SuffixTrieNaive::construct ); +auto suffixTrieNaiveLinearString = registration::AbstractRegister < SuffixTrieNaive, indexes::stringology::SuffixTrie < DefaultSymbolType >, const string::LinearString < > & > ( SuffixTrieNaive::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/SuffixTrieNaive.h b/alib2algo/src/stringology/indexing/SuffixTrieNaive.h index 4096ea477a..36adf70ea7 100644 --- a/alib2algo/src/stringology/indexing/SuffixTrieNaive.h +++ b/alib2algo/src/stringology/indexing/SuffixTrieNaive.h @@ -9,9 +9,7 @@ #define SUFFIX_TRIE_NAIVE_H_ #include <indexes/stringology/SuffixTrie.h> -#include <string/String.h> #include <string/LinearString.h> -#include <core/multipleDispatch.hpp> namespace stringology { @@ -23,15 +21,13 @@ namespace indexing { * Source: Lectures MI-EVY (CTU in Prague), Year 2014, Lecture 3, slide 4 */ -class SuffixTrieNaive : public alib::SingleDispatch < SuffixTrieNaive, indexes::stringology::SuffixTrie < DefaultSymbolType >, const string::StringBase & > { +class SuffixTrieNaive { public: /** * Creates suffix trie * @param string string to construct suffix trie for * @return automaton */ - static indexes::stringology::SuffixTrie < DefaultSymbolType > construct ( const string::String & string ); - template < class SymbolType > static indexes::stringology::SuffixTrie < SymbolType > construct ( const string::LinearString < SymbolType > & string ); diff --git a/alib2algo/src/stringology/matching/BNDMMatcherConstruction.cpp b/alib2algo/src/stringology/matching/BNDMMatcherConstruction.cpp index 30e4712a7e..43ff31c519 100644 --- a/alib2algo/src/stringology/matching/BNDMMatcherConstruction.cpp +++ b/alib2algo/src/stringology/matching/BNDMMatcherConstruction.cpp @@ -6,19 +6,13 @@ */ #include "BNDMMatcherConstruction.h" - -#include <string/LinearString.h> #include <registration/AlgoRegistration.hpp> namespace stringology { namespace matching { -indexes::stringology::BNDMMatcher < DefaultSymbolType > BNDMMatcherConstruction::construct ( const string::String & string ) { - return dispatch ( string.getData ( ) ); -} - -auto BNDMIndexConstructionLinearString = registration::OverloadRegister < BNDMMatcherConstruction, indexes::stringology::BNDMMatcher < >, string::LinearString < > > ( BNDMMatcherConstruction::construct ); +auto BNDMIndexConstructionLinearString = registration::AbstractRegister < BNDMMatcherConstruction, indexes::stringology::BNDMMatcher < >, const string::LinearString < > & > ( BNDMMatcherConstruction::construct ); } /* namespace matching */ diff --git a/alib2algo/src/stringology/matching/BNDMMatcherConstruction.h b/alib2algo/src/stringology/matching/BNDMMatcherConstruction.h index 223f21234c..7169903389 100644 --- a/alib2algo/src/stringology/matching/BNDMMatcherConstruction.h +++ b/alib2algo/src/stringology/matching/BNDMMatcherConstruction.h @@ -9,9 +9,7 @@ #define BNDM_MATCHER_CONSTRUCTION_H_ #include <indexes/stringology/BNDMMatcher.h> -#include <string/String.h> #include <string/LinearString.h> -#include <core/multipleDispatch.hpp> #include <exception/CommonException.h> namespace stringology { @@ -23,15 +21,13 @@ namespace matching { * */ -class BNDMMatcherConstruction : public alib::SingleDispatch < BNDMMatcherConstruction, indexes::stringology::BNDMMatcher < >, const string::StringBase & > { +class BNDMMatcherConstruction { public: /** * Creates suffix trie * @param string string to construct suffix trie for * @return automaton */ - static indexes::stringology::BNDMMatcher < > construct ( const string::String & string ); - template < class SymbolType, size_t BitmaskBitCount = 64 > static indexes::stringology::BNDMMatcher < SymbolType, BitmaskBitCount > construct ( const string::LinearString < SymbolType > & string ); diff --git a/alib2algo/src/stringology/matching/ExactMatchingAutomaton.cpp b/alib2algo/src/stringology/matching/ExactMatchingAutomaton.cpp index d176d08337..15cbb011ad 100644 --- a/alib2algo/src/stringology/matching/ExactMatchingAutomaton.cpp +++ b/alib2algo/src/stringology/matching/ExactMatchingAutomaton.cpp @@ -6,21 +6,13 @@ */ #include "ExactMatchingAutomaton.h" -#include <string/LinearString.h> -#include <string/Epsilon.h> - -#include <deque> #include <registration/AlgoRegistration.hpp> namespace stringology { namespace matching { -automaton::Automaton ExactMatchingAutomaton::construct(const string::String& pattern) { - return dispatch(pattern.getData()); -} - -auto ExactMatchingAutomatonLinearString = registration::OverloadRegister < ExactMatchingAutomaton, automaton::NFA < DefaultSymbolType, unsigned >, string::LinearString < > > ( ExactMatchingAutomaton::construct ); +auto ExactMatchingAutomatonLinearString = registration::AbstractRegister < ExactMatchingAutomaton, automaton::NFA < DefaultSymbolType, unsigned >, const string::LinearString < > & > ( ExactMatchingAutomaton::construct ); } /* namespace matching */ diff --git a/alib2algo/src/stringology/matching/ExactMatchingAutomaton.h b/alib2algo/src/stringology/matching/ExactMatchingAutomaton.h index 08af7e0d3d..15dfb50240 100644 --- a/alib2algo/src/stringology/matching/ExactMatchingAutomaton.h +++ b/alib2algo/src/stringology/matching/ExactMatchingAutomaton.h @@ -8,24 +8,19 @@ #ifndef _EXACT_MATCHING_AUTOMATON_H__ #define _EXACT_MATCHING_AUTOMATON_H__ -#include <automaton/Automaton.h> #include <automaton/FSM/NFA.h> #include <string/LinearString.h> -#include <string/String.h> -#include <core/multipleDispatch.hpp> namespace stringology { namespace matching { -class ExactMatchingAutomaton : public alib::SingleDispatch<ExactMatchingAutomaton, automaton::Automaton, const string::StringBase & > { +class ExactMatchingAutomaton { public: /** * Performs conversion. * @return left regular grammar equivalent to source automaton. */ - static automaton::Automaton construct(const string::String& pattern); - template < class SymbolType > static automaton::NFA < SymbolType, unsigned > construct(const string::LinearString < SymbolType > & pattern); }; diff --git a/alib2algo/src/stringology/query/BNDMOccurrences.cpp b/alib2algo/src/stringology/query/BNDMOccurrences.cpp index ed5186ff0e..e5eae8709e 100644 --- a/alib2algo/src/stringology/query/BNDMOccurrences.cpp +++ b/alib2algo/src/stringology/query/BNDMOccurrences.cpp @@ -14,11 +14,7 @@ namespace stringology { namespace query { -ext::set < unsigned > BNDMOccurrences::query ( const indexes::stringology::BNDMMatcher < > & pattern, const string::String & subject ) { - return dispatch ( pattern, subject.getData ( ) ); -} - -auto bndmOccurrencesLinearString = registration::OverloadRegister < BNDMOccurrences, ext::set < unsigned >, string::LinearString < > > ( BNDMOccurrences::query ); +auto bndmOccurrencesLinearString = registration::AbstractRegister < BNDMOccurrences, ext::set < unsigned >, const indexes::stringology::BNDMMatcher < > &, const string::LinearString < > & > ( BNDMOccurrences::query ); } /* namespace query */ diff --git a/alib2algo/src/stringology/query/BNDMOccurrences.h b/alib2algo/src/stringology/query/BNDMOccurrences.h index f9b872562e..700ec672db 100644 --- a/alib2algo/src/stringology/query/BNDMOccurrences.h +++ b/alib2algo/src/stringology/query/BNDMOccurrences.h @@ -9,9 +9,7 @@ #define BNDM_OCCURRENCES_H_ #include <indexes/stringology/BNDMMatcher.h> -#include <string/String.h> #include <string/LinearString.h> -#include <core/multipleDispatch.hpp> #include <global/GlobalData.h> #include <foreach> @@ -25,7 +23,7 @@ namespace query { * */ -class BNDMOccurrences : public alib::SingleDispatchFirstStaticParam < BNDMOccurrences, ext::set < unsigned >, const indexes::stringology::BNDMMatcher < > &, const string::StringBase & > { +class BNDMOccurrences { public: /** @@ -34,8 +32,6 @@ public: * @param string string to query by * @return occurences of factors */ - static ext::set < unsigned > query ( const indexes::stringology::BNDMMatcher < DefaultSymbolType > & pattern, const string::String & subject ); - template < class SymbolType, size_t BitmaskBitCount > static ext::set < unsigned > query ( const indexes::stringology::BNDMMatcher < SymbolType, BitmaskBitCount > & pattern, const string::LinearString < SymbolType > & subject ); diff --git a/alib2algo/src/stringology/query/BackwardDAWGMatching.cpp b/alib2algo/src/stringology/query/BackwardDAWGMatching.cpp index b25c1e276b..02510a6eb7 100644 --- a/alib2algo/src/stringology/query/BackwardDAWGMatching.cpp +++ b/alib2algo/src/stringology/query/BackwardDAWGMatching.cpp @@ -18,10 +18,6 @@ namespace stringology { namespace query { -ext::set < unsigned > BackwardDAWGMatching::match ( const string::String & subject, const automaton::Automaton & suffixAutomaton ) { - return dispatch ( subject.getData ( ), suffixAutomaton.getData ( ) ); -} - ext::set < unsigned > BackwardDAWGMatching::match ( const string::LinearString < > & subject, const automaton::DFA < > & suffixAutomaton ) { ext::set < unsigned > occ; @@ -63,7 +59,7 @@ ext::set < unsigned > BackwardDAWGMatching::match ( const string::LinearString < return occ; } -auto BackwardDAWGMatchingLinearStringLinearString = registration::OverloadRegister < BackwardDAWGMatching, ext::set < unsigned >, string::LinearString < >, automaton::DFA < > > ( BackwardDAWGMatching::match ); +auto BackwardDAWGMatchingLinearStringLinearString = registration::AbstractRegister < BackwardDAWGMatching, ext::set < unsigned >, const string::LinearString < > &, const automaton::DFA < > & > ( BackwardDAWGMatching::match ); } /* namespace query */ diff --git a/alib2algo/src/stringology/query/BackwardDAWGMatching.h b/alib2algo/src/stringology/query/BackwardDAWGMatching.h index 494533966e..e47a90a851 100644 --- a/alib2algo/src/stringology/query/BackwardDAWGMatching.h +++ b/alib2algo/src/stringology/query/BackwardDAWGMatching.h @@ -20,13 +20,12 @@ namespace query { /** * Implementation of Backward DAWG Matching. */ -class BackwardDAWGMatching : public alib::DoubleDispatch < BackwardDAWGMatching, ext::set < unsigned >, const string::StringBase &, const automaton::AutomatonBase & > { +class BackwardDAWGMatching { public: /** * Search for pattern in linear string. * @return set set of occurences */ - static ext::set < unsigned > match ( const string::String & subject, const automaton::Automaton & suffixAutomaton ); static ext::set < unsigned > match ( const string::LinearString < > & subject, const automaton::DFA < > & suffixAutomaton ); }; diff --git a/alib2algo/src/stringology/query/BackwardOracleMatching.cpp b/alib2algo/src/stringology/query/BackwardOracleMatching.cpp index dcbcb93050..3e99069b57 100644 --- a/alib2algo/src/stringology/query/BackwardOracleMatching.cpp +++ b/alib2algo/src/stringology/query/BackwardOracleMatching.cpp @@ -18,10 +18,6 @@ namespace stringology { namespace query { -ext::set < unsigned > BackwardOracleMatching::match ( const string::String & subject, const automaton::Automaton & factorOracle ) { - return dispatch ( subject.getData ( ), factorOracle.getData ( ) ); -} - ext::set < unsigned > BackwardOracleMatching::match ( const string::LinearString < > & subject, const automaton::DFA < > & factorOracle ) { ext::set < unsigned > occ; @@ -59,7 +55,7 @@ ext::set < unsigned > BackwardOracleMatching::match ( const string::LinearString return occ; } -auto BackwardOracleMatchingLinearStringLinearString = registration::OverloadRegister < BackwardOracleMatching, ext::set < unsigned >, string::LinearString < >, automaton::DFA < > > ( BackwardOracleMatching::match ); +auto BackwardOracleMatchingLinearStringLinearString = registration::AbstractRegister < BackwardOracleMatching, ext::set < unsigned >, const string::LinearString < > &, const automaton::DFA < > & > ( BackwardOracleMatching::match ); } /* namespace query */ diff --git a/alib2algo/src/stringology/query/BackwardOracleMatching.h b/alib2algo/src/stringology/query/BackwardOracleMatching.h index 69152712e4..911cd93ff1 100644 --- a/alib2algo/src/stringology/query/BackwardOracleMatching.h +++ b/alib2algo/src/stringology/query/BackwardOracleMatching.h @@ -5,11 +5,8 @@ #ifndef STRINGOLOGY_BACKWARD_ORACLE_MATCHING_H__ #define STRINGOLOGY_BACKWARD_ORACLE_MATCHING_H__ -#include <string/String.h> -#include <string/StringFeatures.h> -#include <automaton/Automaton.h> -#include <automaton/AutomatonFeatures.h> -#include <core/multipleDispatch.hpp> +#include <string/LinearString.h> +#include <automaton/FSM/DFA.h> #include <set> @@ -20,13 +17,12 @@ namespace query { /** * Implementation of Backward Oracle Matching. */ -class BackwardOracleMatching : public alib::DoubleDispatch <BackwardOracleMatching, ext::set < unsigned >, const string::StringBase &, const automaton::AutomatonBase & > { +class BackwardOracleMatching { public: /** * Search for pattern in linear string. * @return set set of occurences */ - static ext::set < unsigned > match ( const string::String & subject, const automaton::Automaton & factorOracle ); static ext::set < unsigned > match ( const string::LinearString < > & subject, const automaton::DFA < > & factorOracle ); }; diff --git a/alib2algo/test-src/string/properties/borderArrayTest.cpp b/alib2algo/test-src/string/properties/borderArrayTest.cpp index 1bac06907a..c111f5de3c 100644 --- a/alib2algo/test-src/string/properties/borderArrayTest.cpp +++ b/alib2algo/test-src/string/properties/borderArrayTest.cpp @@ -2,6 +2,7 @@ #include <string/String.h> #include <string/properties/BorderArray.h> +#include <primitive/Character.h> CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( borderArrayTest, "stringology" ); CPPUNIT_TEST_SUITE_REGISTRATION( borderArrayTest ); @@ -13,7 +14,7 @@ void borderArrayTest::tearDown() { } void borderArrayTest::testBorderArray() { - string::String string = string::stringFrom("alfalfaalf"); + string::LinearString < char > string ( "alfalfaalf" ); ext::vector<unsigned> borderArray = string::properties::BorderArray::construct(string); ext::vector<unsigned> expected {0, 0, 0, 0, 1, 2, 3, 1, 1, 2, 3}; diff --git a/alib2algo/test-src/stringology/query/DAWGMatcherTest.cpp b/alib2algo/test-src/stringology/query/DAWGMatcherTest.cpp index 11f346515b..6d933dc80e 100644 --- a/alib2algo/test-src/stringology/query/DAWGMatcherTest.cpp +++ b/alib2algo/test-src/stringology/query/DAWGMatcherTest.cpp @@ -36,9 +36,9 @@ void DAWGMatcherTest::testBackwardDAWGMatching ( ) { for(size_t i = 0; i < subjects.size(); ++i) { - string::String subject = string::stringFrom ( subjects[i] ); - string::String pattern = string::stringFrom ( patterns[i] ); - automaton::Automaton suffixAutomaton = stringology::matching::DAWGMatcherConstruction::construct ( pattern ); + string::LinearString < > subject ( subjects[i] ); + string::LinearString < > pattern ( patterns[i] ); + automaton::DFA < > suffixAutomaton = stringology::matching::DAWGMatcherConstruction::construct ( pattern ); ext::set < unsigned > res = stringology::query::BackwardDAWGMatching::match ( subject, suffixAutomaton ); std::cout << subjects[i] << ' ' << patterns[i] << ' ' << res << std::endl; CPPUNIT_ASSERT ( res == expectedOccs[i] ); diff --git a/alib2algo/test-src/stringology/query/OracleMatcherTest.cpp b/alib2algo/test-src/stringology/query/OracleMatcherTest.cpp index dd501ab3b0..0a9a9d18a1 100644 --- a/alib2algo/test-src/stringology/query/OracleMatcherTest.cpp +++ b/alib2algo/test-src/stringology/query/OracleMatcherTest.cpp @@ -35,9 +35,9 @@ void OracleMatcherTest::testBackwardOracleMatching ( ) { for(size_t i = 0; i < subjects.size(); ++i) { - string::String subject = string::stringFrom ( subjects[i] ); - string::String pattern = string::stringFrom ( patterns[i] ); - automaton::Automaton oracleAutomaton = stringology::matching::OracleMatcherConstruction::construct ( pattern ); + string::LinearString < > subject ( subjects[i] ); + string::LinearString < > pattern ( patterns[i] ); + automaton::DFA < > oracleAutomaton = stringology::matching::OracleMatcherConstruction::construct ( pattern ); ext::set < unsigned > res = stringology::query::BackwardOracleMatching::match ( subject, oracleAutomaton ); std::cout << subjects[i] << ' ' << patterns[i] << ' ' << res << std::endl; CPPUNIT_ASSERT ( res == expectedOccs[i] ); diff --git a/alib2cli/test-src/cli/CliTest.cpp b/alib2cli/test-src/cli/CliTest.cpp index 6b49045781..20f509ac24 100644 --- a/alib2cli/test-src/cli/CliTest.cpp +++ b/alib2cli/test-src/cli/CliTest.cpp @@ -249,7 +249,6 @@ public: }; void CliTest::testSetConstruction ( ) { - abstraction::ContainerRegistry::registerSet < int > ( ); abstraction::AlgorithmRegistry::registerAlgorithm < Print > ( Print::print, abstraction::AlgorithmCategories::AlgorithmCategory::DEFAULT, false, false, std::array < std::string, 1 > ( ) ); cli::Environment environment; diff --git a/alib2common/src/abstraction/PrimitiveRegistrator.cpp b/alib2common/src/abstraction/PrimitiveRegistrator.cpp index 5fbad94d47..c02d2f8471 100644 --- a/alib2common/src/abstraction/PrimitiveRegistrator.cpp +++ b/alib2common/src/abstraction/PrimitiveRegistrator.cpp @@ -5,25 +5,28 @@ * Author: Jan Travnicek */ -#include "CastRegistry.hpp" -#include "XmlFileWriterRegistry.hpp" -#include "NormalizeRegistry.hpp" -#include "ValuePrinterRegistry.hpp" -#include "ImmediateRegistry.hpp" +#include <abstraction/CastRegistry.hpp> +#include <abstraction/XmlFileWriterRegistry.hpp> +#include <abstraction/NormalizeRegistry.hpp> +#include <abstraction/ValuePrinterRegistry.hpp> +#include <abstraction/ImmediateRegistry.hpp> +#include <abstraction/ContainerRegistry.hpp> #include <primitive/Double.h> #include <primitive/Integer.h> +#include <primitive/Unsigned.h> #include <primitive/Bool.h> #include <primitive/UnsignedLong.h> #include <primitive/String.h> -#include "SetAbstraction.hpp" +#include <container/ObjectsVector.h> +#include <container/ObjectsSet.h> namespace abstraction { -class PrimitiveCasts { +class PrimitiveRegistrator { public: - PrimitiveCasts ( ) { + PrimitiveRegistrator ( ) { abstraction::CastRegistry::registerCast < double, int > ( false ); abstraction::CastRegistry::registerCast < int, double > ( false ); @@ -38,11 +41,20 @@ public: abstraction::CastRegistry::registerCast < int, size_t > ( false ); abstraction::CastRegistry::registerCast < int, primitive::Integer > ( false ); - + + abstraction::ContainerRegistry::registerSet < int > ( ); + abstraction::XmlFileWriterRegistry::registerXmlFileWriter < int > ( ); abstraction::XmlFileWriterRegistry::registerXmlFileWriter < double > ( ); abstraction::XmlFileWriterRegistry::registerXmlFileWriter < std::string > ( ); + abstraction::XmlFileWriterRegistry::registerXmlFileWriter < ext::vector < size_t > > ( ); + abstraction::XmlFileWriterRegistry::registerXmlFileWriter < ext::vector < unsigned > > ( ); + abstraction::XmlFileWriterRegistry::registerXmlFileWriter < ext::vector < int > > ( ); + abstraction::XmlFileWriterRegistry::registerXmlFileWriter < ext::set < size_t > > ( ); + abstraction::XmlFileWriterRegistry::registerXmlFileWriter < ext::set < unsigned > > ( ); + abstraction::XmlFileWriterRegistry::registerXmlFileWriter < ext::set < int > > ( ); + abstraction::ValuePrinterRegistry::registerValuePrinter < int > ( ); abstraction::ValuePrinterRegistry::registerValuePrinter < double > ( ); abstraction::ValuePrinterRegistry::registerValuePrinter < std::string > ( ); @@ -53,6 +65,6 @@ public: } }; -auto primitiveCasts = PrimitiveCasts ( ); +auto primitiveRegistrator = PrimitiveRegistrator ( ); } /* namespace abstraction */ diff --git a/alib2data/src/common/PrimitiveRegistrator2.cpp b/alib2data/src/common/PrimitiveRegistrator2.cpp new file mode 100644 index 0000000000..ae699b7f98 --- /dev/null +++ b/alib2data/src/common/PrimitiveRegistrator2.cpp @@ -0,0 +1,39 @@ +/* + * PrimitiveRegistrator.cpp + * + * Created on: 11. 7. 2017 + * Author: Jan Travnicek + */ + +#include <abstraction/CastRegistry.hpp> +#include <abstraction/XmlFileWriterRegistry.hpp> +#include <abstraction/NormalizeRegistry.hpp> +#include <abstraction/ValuePrinterRegistry.hpp> +#include <abstraction/ImmediateRegistry.hpp> +#include <abstraction/ContainerRegistry.hpp> + +#include <primitive/Double.h> +#include <primitive/Integer.h> +#include <primitive/Unsigned.h> +#include <primitive/Bool.h> +#include <primitive/UnsignedLong.h> +#include <primitive/String.h> + +#include <container/ObjectsVector.h> +#include <container/ObjectsSet.h> +#include <container/ObjectsMap.h> + +#include <common/DefaultSymbolType.h> + +namespace abstraction { + +class PrimitiveRegistrator2 { +public: + PrimitiveRegistrator2 ( ) { + abstraction::XmlFileWriterRegistry::registerXmlFileWriter < ext::map < DefaultSymbolType, size_t > > ( ); + } +}; + +auto primitiveRegistrator2 = PrimitiveRegistrator2 ( ); + +} /* namespace abstraction */ diff --git a/astringology2/makefile.conf b/astringology2/makefile.conf index feca5334f5..e37acf3fea 100644 --- a/astringology2/makefile.conf +++ b/astringology2/makefile.conf @@ -1,4 +1,4 @@ EXECUTABLE:=astringology2 -LINK_PATHS=../alib2elgo/ ../alib2algo/ ../alib2data/ ../alib2common/ ../alib2std/ -LINK_LIBRARIES=alib2elgo alib2algo alib2data alib2common alib2std xml2 -INCLUDE_PATHS=\$$(SOURCES_BASE_DIR)/../../alib2elgo/src/ \$$(SOURCES_BASE_DIR)/../../alib2algo/src/ \$$(SOURCES_BASE_DIR)/../../alib2data/src/ \$$(SOURCES_BASE_DIR)/../../alib2common/src/ \$$(SOURCES_BASE_DIR)/../../alib2std/src/ /usr/include/libxml2/ +LINK_PATHS=../alib2cli/ ../alib2elgo/ ../alib2algo/ ../alib2data/ ../alib2common/ ../alib2std/ +LINK_LIBRARIES=alib2cli alib2elgo alib2algo alib2data alib2common alib2std xml2 +INCLUDE_PATHS=\$$(SOURCES_BASE_DIR)/../../alib2cli/src/ \$$(SOURCES_BASE_DIR)/../../alib2common/src/ \$$(SOURCES_BASE_DIR)/../../alib2std/src/ /usr/include/libxml2/ diff --git a/astringology2/src/astringology.cpp b/astringology2/src/astringology.cpp index 62bbb3be77..07a8dd5831 100644 --- a/astringology2/src/astringology.cpp +++ b/astringology2/src/astringology.cpp @@ -8,39 +8,10 @@ #include <tclap/CmdLine.h> #include <global/GlobalData.h> #include <measure> -#include <vector> -#include <sax/FromXMLParserHelper.h> -#include <factory/XmlDataFactory.hpp> #include <exception/CommonException.h> -#include <string/String.h> -#include <automaton/Automaton.h> -#include <container/Container.h> -#include <container/ObjectsSet.h> -#include <container/ObjectsVector.h> - -#include <stringology/exact/ExactFactorMatch.h> -#include <stringology/exact/BoyerMooreHorspool.h> -#include <stringology/exact/BoyerMoore.h> -#include <stringology/exact/ReversedBoyerMooreHorspool.h> -#include <stringology/exact/DeadZoneUsingBadCharacterShift.h> -#include <stringology/query/BNDMOccurrences.h> -#include <stringology/query/BackwardOracleMatching.h> -#include <stringology/query/BackwardDAWGMatching.h> -#include <stringology/matching/ExactMatchingAutomaton.h> -#include <stringology/indexing/NondeterministicExactFactorAutomaton.h> -#include <stringology/indexing/ExactSubsequenceAutomaton.h> -#include <stringology/indexing/ExactNondeterministicSubsequenceAutomaton.h> -#include <stringology/indexing/ExactMultiNondeterministicSubsequenceAutomaton.h> -#include <stringology/indexing/ExactFactorOracleAutomaton.h> -#include <stringology/indexing/NondeterministicExactSuffixAutomaton.h> -#include <string/properties/BorderArray.h> -#include <stringology/indexing/SuffixTrieNaive.h> -#include <stringology/indexing/PositionHeapNaive.h> -#include <stringology/indexing/SuffixArrayNaive.h> -#include <stringology/indexing/BitParallelIndexConstruction.h> -#include <stringology/matching/BNDMMatcherConstruction.h> -#include <stringology/indexing/CompressedBitParallelIndexConstruction.h> +#include <lexer/Lexer.h> +#include <parser/Parser.h> int main ( int argc, char * argv[] ) { try { @@ -50,6 +21,12 @@ int main ( int argc, char * argv[] ) { TCLAP::CmdLine cmd ( "Stringology algorithm access binary", ' ', "0.01" ); std::vector < std::string > allowed; + allowed.push_back ( "exactFactorMatch" ); + allowed.push_back ( "boyerMooreHorspool" ); + allowed.push_back ( "boyerMoore" ); + allowed.push_back ( "reversedBoyerMooreHorspool" ); + allowed.push_back ( "deadZoneUsingBadCharacterShift" ); + allowed.push_back ( "exactMatchingAutomaton" ); allowed.push_back ( "exactNondeterministicFactorAutomaton" ); allowed.push_back ( "exactSubsequenceAutomaton" ); @@ -57,11 +34,6 @@ int main ( int argc, char * argv[] ) { allowed.push_back ( "exactMultiNondeterministicSubsequenceAutomaton" ); allowed.push_back ( "exactFactorOracleAutomaton" ); allowed.push_back ( "exactNondeterministicSuffixAutomaton" ); - allowed.push_back ( "exactFactorMatch" ); - allowed.push_back ( "boyerMooreHorspool" ); - allowed.push_back ( "boyerMoore" ); - allowed.push_back ( "reversedBoyerMooreHorspool" ); - allowed.push_back ( "deadZoneUsingBadCharacterShift" ); allowed.push_back ( "bndmOccurrences" ); allowed.push_back ( "backwardOracleMatching" ); allowed.push_back ( "backwardDAWGMatching" ); @@ -99,314 +71,151 @@ int main ( int argc, char * argv[] ) { if(measure.isSet()) common::GlobalData::measure = true; + cli::Environment environment; + environment.setBinding ( "stdout", "-" ); + measurements::start ( "Overal", measurements::Type::OVERALL ); measurements::start ( "Input read", measurements::Type::AUXILIARY ); - if ( algorithm.getValue ( ) == "exactFactorMatch" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - ext::set < unsigned > res = stringology::exact::ExactFactorMatch::match ( subject, pattern ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); + if ( algorithm.getValue ( ) == "exactFactorMatch" + || algorithm.getValue ( ) == "boyerMooreHorspool" + || algorithm.getValue ( ) == "boyerMoore" + || algorithm.getValue ( ) == "reversedBoyerMooreHorspool" + || algorithm.getValue ( ) == "deadZoneUsingBadCharacterShift" + || algorithm.getValue ( ) == "bndmOccurrences" + || algorithm.getValue ( ) == "backwardOracleMatching" + || algorithm.getValue ( ) == "backwardDAWGMatching" + || algorithm.getValue ( ) == "exactNondeterministicFactorAutomaton" + || algorithm.getValue ( ) == "exactSubsequenceAutomaton" + || algorithm.getValue ( ) == "exactNondeterministicSubsequenceAutomaton" + || algorithm.getValue ( ) == "borderArray" + || algorithm.getValue ( ) == "suffixTrie" + || algorithm.getValue ( ) == "positionHeap" + || algorithm.getValue ( ) == "bitParallelIndex" + || algorithm.getValue ( ) == "compressedBitParallelIndex" + || algorithm.getValue ( ) == "suffixArray" ) { + std::string input; + if ( subjectInput.getValue ( ).size ( ) == 0 ) + input = "-"; + else if ( subjectInput.getValue ( ).size ( ) == 1 ) + input = * subjectInput.getValue ( ).begin ( ); + else + throw exception::CommonException("Multiple parameters when single required."); + + environment.setBinding ( "inputSubject", input ); + cli::Parser parser ( cli::Lexer ( "execute <#inputSubject > $subject" ) ); + parser.parse ( )->run ( environment ); + } - alib::XmlDataFactory::toStdout ( res ); - } else if ( algorithm.getValue ( ) == "boyerMooreHorspool" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); + if ( algorithm.getValue ( ) == "exactFactorMatch" + || algorithm.getValue ( ) == "boyerMooreHorspool" + || algorithm.getValue ( ) == "boyerMoore" + || algorithm.getValue ( ) == "reversedBoyerMooreHorspool" + || algorithm.getValue ( ) == "deadZoneUsingBadCharacterShift" + || algorithm.getValue ( ) == "bndmOccurrences" + || algorithm.getValue ( ) == "backwardOracleMatching" + || algorithm.getValue ( ) == "backwardDAWGMatching" + || algorithm.getValue ( ) == "exactMatchingAutomaton" + || algorithm.getValue ( ) == "exactFactorOracleAutomaton" + || algorithm.getValue ( ) == "exactNondeterministicSuffixAutomaton" + || algorithm.getValue ( ) == "bndmMatcher" + || algorithm.getValue ( ) == "badCharacterShiftTable" + || algorithm.getValue ( ) == "goodSuffixShiftTable" ) { + std::string input; + if ( patternInput.getValue ( ).size ( ) == 0 ) + input = "-"; + else if ( patternInput.getValue ( ).size ( ) == 1 ) + input = * patternInput.getValue ( ).begin ( ); + else + throw exception::CommonException("Multiple parameters when single required."); + + environment.setBinding ( "inputPattern", input ); + cli::Parser parser ( cli::Lexer ( "execute <#inputPattern > $pattern" ) ); + parser.parse ( )->run ( environment ); + } - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); + if ( algorithm.getValue ( ) == "exactMultiNondeterministicSubsequenceAutomaton" ) { + unsigned i = 0; + std::string fragment; + for ( const std::string & input : subjectInput.getValue ( ) ) { + environment.setBinding ( "inputSubject" + ext::to_string ( i ), input ); + fragment += "<#inputSubject" + ext::to_string ( i ) + " "; + i++; + } - ext::set < unsigned > res = stringology::exact::BoyerMooreHorspool::match ( subject, pattern ); + cli::Parser parser ( cli::Lexer ( "execute { :type LinearString " + fragment + " } > $subjects" ) ); + parser.parse ( )->run ( environment ); + } - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); + measurements::end ( ); + measurements::start ( "Algorithm", measurements::Type::MAIN ); - alib::XmlDataFactory::toStdout ( res ); + std::string cliCommand; + if ( algorithm.getValue ( ) == "exactFactorMatch" ) { + cliCommand = "execute stringology::exact::ExactFactorMatch $subject $pattern > $output"; + } else if ( algorithm.getValue ( ) == "boyerMooreHorspool" ) { + cliCommand = "execute stringology::exact::BoyerMooreHorspool $subject $pattern > $output"; } else if ( algorithm.getValue ( ) == "boyerMoore" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - ext::set < unsigned > res = stringology::exact::BoyerMoore::match ( subject, pattern ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( res ); + cliCommand = "execute stringology::exact::BoyerMoore $subject $pattern > $output"; } else if ( algorithm.getValue ( ) == "reversedBoyerMooreHorspool" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - ext::set < unsigned > res = stringology::exact::ReversedBoyerMooreHorspool::match ( subject, pattern ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( res ); + cliCommand = "execute stringology::exact::ReversedBoyerMooreHorspool $subject $pattern > $output"; } else if ( algorithm.getValue ( ) == "deadZoneUsingBadCharacterShift" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - ext::set < unsigned > res = stringology::exact::DeadZoneUsingBadCharacterShift::match ( subject, pattern ); + cliCommand = "execute stringology::exact::DeadZoneUsingBadCharacterShift $subject $pattern > $output"; - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( res ); } else if ( algorithm.getValue ( ) == "bndmOccurrences" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - indexes::stringology::BNDMMatcher < DefaultSymbolType > pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - ext::set < unsigned > res = stringology::query::BNDMOccurrences::query ( pattern, subject ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( res ); + cliCommand = "execute stringology::query::BNDMOccurrences $pattern $subject > $output"; } else if ( algorithm.getValue ( ) == "backwardOracleMatching" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - automaton::Automaton pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - ext::set < unsigned > res = stringology::query::BackwardOracleMatching::match ( subject, pattern ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( res ); + cliCommand = "execute stringology::query::BackwardOracleMatching $subject $pattern > $output"; } else if ( algorithm.getValue ( ) == "backwardDAWGMatching" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - automaton::Automaton pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - ext::set < unsigned > res = stringology::query::BackwardDAWGMatching::match ( subject, pattern ); + cliCommand = "execute stringology::query::BackwardDAWGMatching $subject $pattern > $output"; - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( res ); - } else if ( algorithm.getValue ( ) == "exactMatchingAutomaton" ) { - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - automaton::Automaton automaton = stringology::matching::ExactMatchingAutomaton::construct ( pattern ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( automaton ); } else if ( algorithm.getValue ( ) == "exactNondeterministicFactorAutomaton" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - automaton::Automaton automaton = stringology::indexing::NondeterministicExactFactorAutomaton::construct ( subject ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( automaton ); + cliCommand = "execute stringology::indexing::NondeterministicExactFactorAutomaton $subject > $output"; } else if ( algorithm.getValue ( ) == "exactSubsequenceAutomaton" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - automaton::Automaton automaton = stringology::indexing::ExactSubsequenceAutomaton::construct ( subject ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( automaton ); + cliCommand = "execute stringology::indexing::ExactSubsequenceAutomaton $subject > $output"; } else if ( algorithm.getValue ( ) == "exactNondeterministicSubsequenceAutomaton" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - automaton::Automaton automaton = stringology::indexing::ExactNondeterministicSubsequenceAutomaton::construct ( subject ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( automaton ); + cliCommand = "execute stringology::indexing::ExactNondeterministicSubsequenceAutomaton $subject > $output"; } else if ( algorithm.getValue ( ) == "exactMultiNondeterministicSubsequenceAutomaton" ) { - ext::set < string::String > subjects; - - for ( ext::deque < sax::Token > & tokens : sax::FromXMLParserHelper::parseInput(false, subjectInput) ) { - string::String string = alib::XmlDataFactory::fromTokens ( std::move ( tokens ) ); - subjects.insert ( std::move ( string ) ); - } - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - automaton::Automaton automaton = stringology::indexing::ExactMultiNondeterministicSubsequenceAutomaton::construct ( subjects ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( automaton ); + cliCommand = "execute stringology::indexing::ExactMultiNondeterministicSubsequenceAutomaton $subjects > $output"; } else if ( algorithm.getValue ( ) == "exactFactorOracleAutomaton" ) { - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - automaton::Automaton automaton = stringology::indexing::ExactFactorOracleAutomaton::construct ( pattern ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( automaton ); + cliCommand = "execute stringology::indexing::ExactFactorOracleAutomaton $pattern > $output"; } else if ( algorithm.getValue ( ) == "exactNondeterministicSuffixAutomaton" ) { - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - automaton::Automaton automaton = stringology::indexing::NondeterministicExactSuffixAutomaton::construct ( pattern ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( automaton ); - } else if ( algorithm.getValue ( ) == "borderArray" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - ext::vector < unsigned > borderArray = string::properties::BorderArray::construct ( subject ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( borderArray ); + cliCommand = "execute stringology::indexing::NondeterministicExactSuffixAutomaton $pattern > $output"; } else if ( algorithm.getValue ( ) == "suffixTrie" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - indexes::stringology::SuffixTrie < DefaultSymbolType > suffixTrie = stringology::indexing::SuffixTrieNaive::construct ( subject ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( suffixTrie ); + cliCommand = "execute stringology::indexing::SuffixTrieNaive $subject > $output"; } else if ( algorithm.getValue ( ) == "positionHeap" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - indexes::stringology::PositionHeap < DefaultSymbolType > positionHeap = stringology::indexing::PositionHeapNaive::construct ( subject ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( positionHeap ); + cliCommand = "execute stringology::indexing::PositionHeapNaive $subject > $output"; } else if ( algorithm.getValue ( ) == "bitParallelIndex" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - indexes::stringology::BitParallelIndex < DefaultSymbolType > bitParallelIndex = stringology::indexing::BitParallelIndexConstruction::construct ( subject ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( bitParallelIndex ); - } else if ( algorithm.getValue ( ) == "bndmMatcher" ) { - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - indexes::stringology::BNDMMatcher < DefaultSymbolType > bndmMatcher = stringology::matching::BNDMMatcherConstruction::construct ( pattern ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( bndmMatcher ); + cliCommand = "execute stringology::indexing::BitParallelIndexConstruction $subject > $output"; } else if ( algorithm.getValue ( ) == "compressedBitParallelIndex" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - indexes::stringology::CompressedBitParallelIndex < DefaultSymbolType > compressedBitParallelIndex = stringology::indexing::CompressedBitParallelIndexConstruction::construct ( subject ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( compressedBitParallelIndex ); + cliCommand = "execute stringology::indexing::CompressedBitParallelIndexConstruction $subject > $output"; } else if ( algorithm.getValue ( ) == "suffixArray" ) { - string::String subject = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, subjectInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - indexes::stringology::SuffixArray < > suffixArray = stringology::indexing::SuffixArrayNaive::construct ( subject ); + cliCommand = "execute stringology::indexing::SuffixArrayNaive $subject > $output"; - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); + } else if ( algorithm.getValue ( ) == "bndmMatcher" ) { + cliCommand = "execute stringology::matching::BNDMMatcherConstruction $pattern > $output"; + } else if ( algorithm.getValue ( ) == "exactMatchingAutomaton" ) { + cliCommand = "execute stringology::matching::ExactMatchingAutomaton $pattern > $output"; - alib::XmlDataFactory::toStdout ( suffixArray ); + } else if ( algorithm.getValue ( ) == "borderArray" ) { + cliCommand = "execute string::properties::BorderArray $subject > $output"; } else if ( algorithm.getValue ( ) == "badCharacterShiftTable" ) { - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - ext::map < DefaultSymbolType, size_t > bcs = string::properties::BadCharacterShiftTable::bcs ( pattern ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( bcs ); + cliCommand = "execute string::properties::BadCharacterShiftTable $pattern > $output"; } else if ( algorithm.getValue ( ) == "goodSuffixShiftTable" ) { - string::String pattern = alib::XmlDataFactory::fromTokens ( std::move ( sax::FromXMLParserHelper::parseInput(true, patternInput).front ( ) ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - ext::vector < size_t > gss = string::properties::GoodSuffixShiftTable::gss ( pattern ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( gss ); + cliCommand = "execute string::properties::GoodSuffixShiftTable $pattern > $output"; } else { throw exception::CommonException ( "Invalid algorithm" ); } + cli::Parser parser = cli::Parser ( cli::Lexer ( cliCommand ) ); + parser.parse ( )->run ( environment ); + + measurements::end ( ); + measurements::start ( "Output write", measurements::Type::AUXILIARY ); + + parser = cli::Parser ( cli::Lexer ( "execute $output >#stdout" ) ); + parser.parse ( )->run ( environment ); + measurements::end ( ); measurements::end ( ); -- GitLab