From 8e7d26a66b1eeee0887070638af2027fa7c762d8 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Sun, 23 Aug 2015 22:00:40 +0200 Subject: [PATCH] selfTypeId and typeId <=> type_index and typeId --- alib2data/src/CastApi.hpp | 116 ++++---- alib2data/src/alphabet/BarSymbol.h | 37 ++- alib2data/src/alphabet/BlankSymbol.h | 37 ++- .../src/alphabet/BottomOfTheStackSymbol.h | 37 ++- alib2data/src/alphabet/EndSymbol.h | 37 ++- alib2data/src/alphabet/LabeledSymbol.h | 47 ++- alib2data/src/alphabet/RankedSymbol.h | 49 ++-- alib2data/src/alphabet/StartSymbol.h | 37 ++- .../src/alphabet/SubtreeWildcardSymbol.h | 37 ++- alib2data/src/alphabet/SymbolPairSymbol.h | 42 ++- alib2data/src/alphabet/SymbolSetSymbol.h | 42 ++- alib2data/src/alphabet/UniqueSymbol.h | 44 ++- alib2data/src/alphabet/VariablesBarSymbol.h | 37 ++- alib2data/src/automaton/FSM/CompactNFA.h | 62 ++-- alib2data/src/automaton/FSM/DFA.h | 56 ++-- alib2data/src/automaton/FSM/EpsilonNFA.h | 85 +++--- alib2data/src/automaton/FSM/ExtendedNFA.h | 64 ++-- .../src/automaton/FSM/MultiInitialStateNFA.h | 64 ++-- alib2data/src/automaton/FSM/NFA.h | 62 ++-- alib2data/src/automaton/PDA/DPDA.h | 64 ++-- alib2data/src/automaton/PDA/InputDrivenDPDA.h | 70 +++-- alib2data/src/automaton/PDA/InputDrivenNPDA.h | 71 +++-- alib2data/src/automaton/PDA/NPDA.h | 60 ++-- .../PDA/RealTimeHeightDeterministicDPDA.h | 94 +++--- .../PDA/RealTimeHeightDeterministicNPDA.h | 94 +++--- alib2data/src/automaton/PDA/SinglePopDPDA.h | 62 ++-- alib2data/src/automaton/PDA/SinglePopNPDA.h | 62 ++-- .../src/automaton/PDA/VisiblyPushdownDPDA.h | 68 +++-- .../src/automaton/PDA/VisiblyPushdownNPDA.h | 68 +++-- alib2data/src/automaton/TA/DFTA.h | 69 +++-- alib2data/src/automaton/TA/NFTA.h | 73 +++-- alib2data/src/automaton/TM/OneTapeDTM.h | 51 ++-- alib2data/src/common/base.hpp | 16 +- alib2data/src/common/multipleDispatch.hpp | 274 +++++++++--------- alib2data/src/container/ObjectsMap.h | 104 ++++--- alib2data/src/container/ObjectsPair.h | 100 ++++--- alib2data/src/container/ObjectsSet.h | 104 ++++--- alib2data/src/container/ObjectsVector.h | 104 ++++--- alib2data/src/exception/AlibException.h | 33 +-- alib2data/src/grammar/ContextFree/CFG.h | 57 ++-- alib2data/src/grammar/ContextFree/CNF.h | 69 +++-- .../src/grammar/ContextFree/EpsilonFreeCFG.h | 61 ++-- alib2data/src/grammar/ContextFree/GNF.h | 62 ++-- alib2data/src/grammar/ContextFree/LG.h | 66 ++--- alib2data/src/grammar/ContextSensitive/CSG.h | 55 ++-- .../ContextSensitive/NonContractingGrammar.h | 55 ++-- alib2data/src/grammar/Regular/LeftLG.h | 65 ++--- alib2data/src/grammar/Regular/LeftRG.h | 72 +++-- alib2data/src/grammar/Regular/RightLG.h | 65 ++--- alib2data/src/grammar/Regular/RightRG.h | 69 +++-- .../ContextPreservingUnrestrictedGrammar.h | 51 ++-- .../Unrestricted/UnrestrictedGrammar.h | 51 ++-- alib2data/src/graph/directed/DirectedGraph.h | 84 +++--- .../src/graph/undirected/UndirectedGraph.h | 84 +++--- alib2data/src/label/HexavigesimalLabel.h | 42 ++- alib2data/src/label/LabelPairLabel.h | 42 ++- alib2data/src/label/LabelSetLabel.h | 42 ++- alib2data/src/label/ObjectLabel.h | 39 ++- alib2data/src/label/PrimitiveLabel.h | 42 ++- alib2data/src/label/UniqueLabel.h | 44 ++- alib2data/src/object/Void.h | 33 +-- alib2data/src/primitive/Bool.h | 55 ++-- alib2data/src/primitive/Character.h | 56 ++-- alib2data/src/primitive/Integer.h | 57 ++-- alib2data/src/primitive/String.h | 60 ++-- alib2data/src/primitive/Unsigned.h | 57 ++-- alib2data/src/regexp/formal/FormalRegExp.h | 69 +++-- .../regexp/formal/FormalRegExpAlternation.h | 61 ++-- .../regexp/formal/FormalRegExpConcatenation.h | 60 ++-- .../src/regexp/formal/FormalRegExpEmpty.h | 36 +-- .../src/regexp/formal/FormalRegExpEpsilon.h | 37 +-- .../src/regexp/formal/FormalRegExpIteration.h | 51 ++-- .../src/regexp/formal/FormalRegExpSymbol.h | 53 ++-- .../src/regexp/unbounded/UnboundedRegExp.h | 69 +++-- .../unbounded/UnboundedRegExpAlternation.h | 48 ++- .../unbounded/UnboundedRegExpConcatenation.h | 50 ++-- .../regexp/unbounded/UnboundedRegExpEmpty.h | 36 +-- .../regexp/unbounded/UnboundedRegExpEpsilon.h | 37 +-- .../unbounded/UnboundedRegExpIteration.h | 50 ++-- .../regexp/unbounded/UnboundedRegExpSymbol.h | 52 ++-- alib2data/src/string/CyclicString.h | 63 ++-- alib2data/src/string/Epsilon.h | 46 ++- alib2data/src/string/LinearString.h | 66 ++--- .../src/tree/ranked/PrefixRankedBarPattern.h | 57 ++-- .../src/tree/ranked/PrefixRankedBarTree.h | 55 ++-- .../src/tree/ranked/PrefixRankedPattern.h | 51 ++-- alib2data/src/tree/ranked/PrefixRankedTree.h | 51 ++-- alib2data/src/tree/ranked/RankedPattern.h | 59 ++-- alib2data/src/tree/ranked/RankedTree.h | 59 ++-- alib2data/src/tree/unranked/UnrankedPattern.h | 59 ++-- alib2data/src/tree/unranked/UnrankedTree.h | 59 ++-- alib2data/test-src/common/DispatchTest.cpp | 212 +++++++------- alib2data/test-src/common/VisitorTest.cpp | 214 +++++++------- 93 files changed, 2824 insertions(+), 3104 deletions(-) diff --git a/alib2data/src/CastApi.hpp b/alib2data/src/CastApi.hpp index dc6b942c19..064a62f164 100644 --- a/alib2data/src/CastApi.hpp +++ b/alib2data/src/CastApi.hpp @@ -20,105 +20,113 @@ namespace alib { struct castApi { class CastPoolBase { protected: - std::map<long long, std::function<alib::Object(const alib::ObjectBase&)>> castFunctions; + std::map < std::type_index, std::function < alib::Object ( const alib::ObjectBase & ) > > castFunctions; public: - alib::Object cast(const alib::ObjectBase& from) { - std::map<long long, std::function<alib::Object(const alib::ObjectBase&)>>::iterator res = castFunctions.find(from.selfTypeId()); - if(res == castFunctions.end()) - throw std::bad_cast(); - return res->second(from); + alib::Object cast ( const alib::ObjectBase & from ) { + std::map < std::type_index, std::function < alib::Object ( const alib::ObjectBase & ) > >::iterator res = castFunctions.find ( std::type_index ( typeid ( from ) ) ); + + if ( res == castFunctions.end ( ) ) + throw std::bad_cast ( ); + + return res->second ( from ); } - bool castAvailable(long long from) { - return castFunctions.count(from); + bool castAvailable ( std::type_index from ) { + return castFunctions.count ( from ); } + }; - template<class To> + template < class To > class CastPool : public CastPoolBase { public: - template<class From> - void add() { - int a = 0; - castFunctions.insert(std::make_pair(From::typeId((const From&) a), [](const alib::ObjectBase& from) { return alib::Object(To((const From&) from)); } )); + template < class From > + void add ( ) { + castFunctions.insert ( std::make_pair ( std::type_index ( typeid ( From ) ), [] ( const alib::ObjectBase & from ) { return alib::Object ( To ( ( const From & ) from ) ); } ) ); } - template<class From> - bool test() { - int a = 0; - return castFunctions.count(From::typeId((const From&) a)); + template < class From > + bool test ( ) { + return castFunctions.count ( std::type_index ( typeid ( From ) ) ); } + }; private: - // INFO: Function exist to handle static order of initialisation - static std::map<long long, CastPoolBase*>& castFunctionsById() { - static std::map<long long, CastPoolBase*> res; + // INFO: Function exist to handle static order of initialisation + static std::map < std::type_index, CastPoolBase * > & castFunctionsById ( ) { + static std::map < std::type_index, CastPoolBase * > res; + return res; } - // INFO: Function exist to handle static order of initialisation - static std::map<std::string, CastPoolBase*>& castFunctionsByString() { - static std::map<std::string, CastPoolBase*> res; + // INFO: Function exist to handle static order of initialisation + static std::map < std::string, CastPoolBase * > & castFunctionsByString ( ) { + static std::map < std::string, CastPoolBase * > res; + return res; } public: - template<class To> - static CastPool<To>& getCastPool() { - int a = 0; - std::map<long long, CastPoolBase*>::iterator res = castFunctionsById().find(To::typeId((const To&) a)); - if(res == castFunctionsById().end()) { - CastPool<To>* castPool = new CastPool<To>(); - castPool->template add<To>(); - return * (CastPool<To>*) ( castFunctionsById().insert(std::make_pair(To::typeId((const To&) a), castPool)).first->second ); + template < class To > + static CastPool < To > & getCastPool ( ) { + std::map < std::type_index, CastPoolBase * >::iterator res = castFunctionsById ( ).find ( std::type_index ( typeid ( To ) ) ); + + if ( res == castFunctionsById ( ).end ( ) ) { + CastPool < To > * castPool = new CastPool < To > ( ); + castPool->template add < To > ( ); + return * ( CastPool < To > * )( castFunctionsById ( ).insert ( std::make_pair ( std::type_index ( typeid ( To ) ), castPool ) ).first->second ); } else { - return * (CastPool<To>*) res->second; + return * ( CastPool < To > * )res->second; } } - static CastPoolBase& getCastPool(const std::string& tagName) { - std::map<std::string, CastPoolBase*>::iterator res = castFunctionsByString().find(tagName); - if(res == castFunctionsByString().end()) { - throw std::invalid_argument("Casting to type " + tagName + " not available."); - } else { + static CastPoolBase & getCastPool ( const std::string & tagName ) { + std::map < std::string, CastPoolBase * >::iterator res = castFunctionsByString ( ).find ( tagName ); + + if ( res == castFunctionsByString ( ).end ( ) ) + throw std::invalid_argument ( "Casting to type " + tagName + " not available." ); + else return * res->second; - } } - static CastPoolBase& getCastPool(long long typeId) { - std::map<long long, CastPoolBase*>::iterator res = castFunctionsById().find(typeId); - if(res == castFunctionsById().end()) { - throw std::invalid_argument("Casting to type ? not available."); - } else { + static CastPoolBase & getCastPool ( std::type_index typeId ) { + std::map < std::type_index, CastPoolBase * >::iterator res = castFunctionsById ( ).find ( typeId ); + + if ( res == castFunctionsById ( ).end ( ) ) + throw std::invalid_argument ( "Casting to type ? not available." ); + else return * res->second; - } } - static bool castAvailable(long long to, long long from) { - std::map<long long, CastPoolBase*>::iterator res = castFunctionsById().find(to); - if(res == castFunctionsById().end()) + static bool castAvailable ( std::type_index to, std::type_index from ) { + std::map < std::type_index, CastPoolBase * >::iterator res = castFunctionsById ( ).find ( to ); + + if ( res == castFunctionsById ( ).end ( ) ) return false; - return res->second->castAvailable(from); + + return res->second->castAvailable ( from ); } - template<class To> + template < class To > class CastPoolStringBinder { public: - CastPoolStringBinder(std::string tagName) { - castFunctionsByString().insert(std::make_pair(tagName, & getCastPool<To>())); + CastPoolStringBinder ( std::string tagName ) { + castFunctionsByString ( ).insert ( std::make_pair ( tagName, & getCastPool < To > ( ) ) ); } }; - template<class To, class From> + template < class To, class From > class CastRegister { public: - CastRegister() { - getCastPool<To>().template add<From>(); + CastRegister ( ) { + getCastPool < To > ( ).template add < From > ( ); } + }; + }; } /* namespace alib */ diff --git a/alib2data/src/alphabet/BarSymbol.h b/alib2data/src/alphabet/BarSymbol.h index 31b68af10d..f453079ae5 100644 --- a/alib2data/src/alphabet/BarSymbol.h +++ b/alib2data/src/alphabet/BarSymbol.h @@ -21,46 +21,43 @@ public: * Creates a bar symbol. * @param symbol name of the symbol */ - explicit BarSymbol(); + explicit BarSymbol ( ); - virtual SymbolBase* clone() const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * clone ( ) const; + virtual SymbolBase * plunder ( ) &&; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const BarSymbol& other) const; + virtual int compare ( const BarSymbol & other ) const; - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; static BarSymbol BAR; const static std::string XML_TAG_NAME; - static BarSymbol parse(std::deque<sax::Token>::iterator& input); + static BarSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::BarSymbol> { - int operator()(const alphabet::BarSymbol& first, const alphabet::BarSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::BarSymbol > { + int operator ()( const alphabet::BarSymbol & first, const alphabet::BarSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/alphabet/BlankSymbol.h b/alib2data/src/alphabet/BlankSymbol.h index 55b9d2e0a3..6ae2ec63d4 100644 --- a/alib2data/src/alphabet/BlankSymbol.h +++ b/alib2data/src/alphabet/BlankSymbol.h @@ -21,46 +21,43 @@ public: * Creates a blank symbol. * @param symbol name of the symbol */ - explicit BlankSymbol(); + explicit BlankSymbol ( ); - virtual SymbolBase* clone() const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * clone ( ) const; + virtual SymbolBase * plunder ( ) &&; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const BlankSymbol& other) const; + virtual int compare ( const BlankSymbol & other ) const; - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; static BlankSymbol BLANK; const static std::string XML_TAG_NAME; - static BlankSymbol parse(std::deque<sax::Token>::iterator& input); + static BlankSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::BlankSymbol> { - int operator()(const alphabet::BlankSymbol& first, const alphabet::BlankSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::BlankSymbol > { + int operator ()( const alphabet::BlankSymbol & first, const alphabet::BlankSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/alphabet/BottomOfTheStackSymbol.h b/alib2data/src/alphabet/BottomOfTheStackSymbol.h index 62f1477591..5378b44622 100644 --- a/alib2data/src/alphabet/BottomOfTheStackSymbol.h +++ b/alib2data/src/alphabet/BottomOfTheStackSymbol.h @@ -21,46 +21,43 @@ public: * Creates a blank symbol. * @param symbol name of the symbol */ - explicit BottomOfTheStackSymbol(); + explicit BottomOfTheStackSymbol ( ); - virtual SymbolBase* clone() const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * clone ( ) const; + virtual SymbolBase * plunder ( ) &&; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const BottomOfTheStackSymbol& other) const; + virtual int compare ( const BottomOfTheStackSymbol & other ) const; - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; static BottomOfTheStackSymbol BOTTOM_OF_THE_STACK; const static std::string XML_TAG_NAME; - static BottomOfTheStackSymbol parse(std::deque<sax::Token>::iterator& input); + static BottomOfTheStackSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::BottomOfTheStackSymbol> { - int operator()(const alphabet::BottomOfTheStackSymbol& first, const alphabet::BottomOfTheStackSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::BottomOfTheStackSymbol > { + int operator ()( const alphabet::BottomOfTheStackSymbol & first, const alphabet::BottomOfTheStackSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/alphabet/EndSymbol.h b/alib2data/src/alphabet/EndSymbol.h index 066ae7b667..a92192f2f5 100644 --- a/alib2data/src/alphabet/EndSymbol.h +++ b/alib2data/src/alphabet/EndSymbol.h @@ -21,46 +21,43 @@ public: * Creates a blank symbol. * @param symbol name of the symbol */ - explicit EndSymbol(); + explicit EndSymbol ( ); - virtual SymbolBase* clone() const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * clone ( ) const; + virtual SymbolBase * plunder ( ) &&; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const EndSymbol& other) const; + virtual int compare ( const EndSymbol & other ) const; - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; static EndSymbol END; const static std::string XML_TAG_NAME; - static EndSymbol parse(std::deque<sax::Token>::iterator& input); + static EndSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::EndSymbol> { - int operator()(const alphabet::EndSymbol& first, const alphabet::EndSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::EndSymbol > { + int operator ()( const alphabet::EndSymbol & first, const alphabet::EndSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/alphabet/LabeledSymbol.h b/alib2data/src/alphabet/LabeledSymbol.h index 77dcf0e38b..076db05004 100644 --- a/alib2data/src/alphabet/LabeledSymbol.h +++ b/alib2data/src/alphabet/LabeledSymbol.h @@ -21,59 +21,56 @@ protected: label::Label label; public: - explicit LabeledSymbol(int number); - explicit LabeledSymbol(char character); - explicit LabeledSymbol(std::string label); + explicit LabeledSymbol ( int number ); + explicit LabeledSymbol ( char character ); + explicit LabeledSymbol ( std::string label ); /** * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit LabeledSymbol(label::Label label); + explicit LabeledSymbol ( label::Label label ); - virtual SymbolBase* clone() const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * clone ( ) const; + virtual SymbolBase * plunder ( ) &&; /** * @return name of the symbol */ - const label::Label& getLabel() const; + const label::Label & getLabel ( ) const; - label::Label& getLabel(); + label::Label & getLabel ( ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const LabeledSymbol& other) const; + virtual int compare ( const LabeledSymbol & other ) const; - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static LabeledSymbol parse(std::deque<sax::Token>::iterator& input); + static LabeledSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::LabeledSymbol> { - int operator()(const alphabet::LabeledSymbol& first, const alphabet::LabeledSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::LabeledSymbol > { + int operator ()( const alphabet::LabeledSymbol & first, const alphabet::LabeledSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/alphabet/RankedSymbol.h b/alib2data/src/alphabet/RankedSymbol.h index 46f1c43ffa..93f63b3558 100644 --- a/alib2data/src/alphabet/RankedSymbol.h +++ b/alib2data/src/alphabet/RankedSymbol.h @@ -22,64 +22,61 @@ protected: primitive::Unsigned rank; public: - explicit RankedSymbol(int number, int rank); - explicit RankedSymbol(char character, int rank); - explicit RankedSymbol(std::string label, int rank); + explicit RankedSymbol ( int number, int rank ); + explicit RankedSymbol ( char character, int rank ); + explicit RankedSymbol ( std::string label, int rank ); /** * Creates new symbol with given name and rank. * @param symbol name of the symbol * @param rank of the symbol */ - explicit RankedSymbol(alphabet::Symbol symbol, primitive::Unsigned rank); - explicit RankedSymbol(alphabet::Symbol symbol, int rank); + explicit RankedSymbol ( alphabet::Symbol symbol, primitive::Unsigned rank ); + explicit RankedSymbol ( alphabet::Symbol symbol, int rank ); - virtual SymbolBase* clone() const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * clone ( ) const; + virtual SymbolBase * plunder ( ) &&; /** * @return name of the symbol */ - const alphabet::Symbol& getSymbol() const; + const alphabet::Symbol & getSymbol ( ) const; /** * @return rank of the symbol */ - const primitive::Unsigned& getRank() const; + const primitive::Unsigned & getRank ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const RankedSymbol& other) const; + virtual int compare ( const RankedSymbol & other ) const; - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static RankedSymbol parse(std::deque<sax::Token>::iterator& input); + static RankedSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::RankedSymbol> { - int operator()(const alphabet::RankedSymbol& first, const alphabet::RankedSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::RankedSymbol > { + int operator ()( const alphabet::RankedSymbol & first, const alphabet::RankedSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/alphabet/StartSymbol.h b/alib2data/src/alphabet/StartSymbol.h index cf1b08bbe3..d441dcd0da 100644 --- a/alib2data/src/alphabet/StartSymbol.h +++ b/alib2data/src/alphabet/StartSymbol.h @@ -21,46 +21,43 @@ public: * Creates a blank symbol. * @param symbol name of the symbol */ - explicit StartSymbol(); + explicit StartSymbol ( ); - virtual SymbolBase* clone() const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * clone ( ) const; + virtual SymbolBase * plunder ( ) &&; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const StartSymbol& other) const; + virtual int compare ( const StartSymbol & other ) const; - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; static StartSymbol START; const static std::string XML_TAG_NAME; - static StartSymbol parse(std::deque<sax::Token>::iterator& input); + static StartSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::StartSymbol> { - int operator()(const alphabet::StartSymbol& first, const alphabet::StartSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::StartSymbol > { + int operator ()( const alphabet::StartSymbol & first, const alphabet::StartSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/alphabet/SubtreeWildcardSymbol.h b/alib2data/src/alphabet/SubtreeWildcardSymbol.h index 472a9aade6..8e8822e37f 100644 --- a/alib2data/src/alphabet/SubtreeWildcardSymbol.h +++ b/alib2data/src/alphabet/SubtreeWildcardSymbol.h @@ -21,46 +21,43 @@ public: * Creates a subtreeWildcard symbol. * @param symbol name of the symbol */ - explicit SubtreeWildcardSymbol(); + explicit SubtreeWildcardSymbol ( ); - virtual SymbolBase* clone() const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * clone ( ) const; + virtual SymbolBase * plunder ( ) &&; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const SubtreeWildcardSymbol& other) const; + virtual int compare ( const SubtreeWildcardSymbol & other ) const; - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; static SubtreeWildcardSymbol SUBTREE_WILDCARD; const static std::string XML_TAG_NAME; - static SubtreeWildcardSymbol parse(std::deque<sax::Token>::iterator& input); + static SubtreeWildcardSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::SubtreeWildcardSymbol> { - int operator()(const alphabet::SubtreeWildcardSymbol& first, const alphabet::SubtreeWildcardSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::SubtreeWildcardSymbol > { + int operator ()( const alphabet::SubtreeWildcardSymbol & first, const alphabet::SubtreeWildcardSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/alphabet/SymbolPairSymbol.h b/alib2data/src/alphabet/SymbolPairSymbol.h index 82b6c1fd3a..f034cdc599 100644 --- a/alib2data/src/alphabet/SymbolPairSymbol.h +++ b/alib2data/src/alphabet/SymbolPairSymbol.h @@ -18,60 +18,56 @@ namespace alphabet { */ class SymbolPairSymbol : public SymbolBase { protected: - std::pair<Symbol, Symbol> symbol; + std::pair < Symbol, Symbol > symbol; public: /** * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit SymbolPairSymbol(std::pair<Symbol, Symbol> symbol); + explicit SymbolPairSymbol ( std::pair < Symbol, Symbol > symbol ); - virtual SymbolBase* clone() const; + virtual SymbolBase * clone ( ) const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * plunder ( ) &&; /** * @return name of the symbol */ - const std::pair<Symbol, Symbol>& getData() const; + const std::pair < Symbol, Symbol > & getData ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const SymbolPairSymbol& other) const; + virtual int compare ( const SymbolPairSymbol & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static SymbolPairSymbol parse(std::deque<sax::Token>::iterator& input); + static SymbolPairSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::SymbolPairSymbol> { - int operator()(const alphabet::SymbolPairSymbol& first, const alphabet::SymbolPairSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::SymbolPairSymbol > { + int operator ()( const alphabet::SymbolPairSymbol & first, const alphabet::SymbolPairSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* SYMBOL_PAIR_SYMBOL_H_ */ - diff --git a/alib2data/src/alphabet/SymbolSetSymbol.h b/alib2data/src/alphabet/SymbolSetSymbol.h index bb8ebad910..075e84fe44 100644 --- a/alib2data/src/alphabet/SymbolSetSymbol.h +++ b/alib2data/src/alphabet/SymbolSetSymbol.h @@ -18,60 +18,56 @@ namespace alphabet { */ class SymbolSetSymbol : public SymbolBase { protected: - std::set<Symbol> symbol; + std::set < Symbol > symbol; public: /** * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit SymbolSetSymbol(std::set<Symbol> symbol); + explicit SymbolSetSymbol ( std::set < Symbol > symbol ); - virtual SymbolBase* clone() const; + virtual SymbolBase * clone ( ) const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * plunder ( ) &&; /** * @return name of the symbol */ - const std::set<Symbol>& getData() const; + const std::set < Symbol > & getData ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const SymbolSetSymbol& other) const; + virtual int compare ( const SymbolSetSymbol & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static SymbolSetSymbol parse(std::deque<sax::Token>::iterator& input); + static SymbolSetSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::SymbolSetSymbol> { - int operator()(const alphabet::SymbolSetSymbol& first, const alphabet::SymbolSetSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::SymbolSetSymbol > { + int operator ()( const alphabet::SymbolSetSymbol & first, const alphabet::SymbolSetSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* SYMBOL_SET_SYMBOL_H_ */ - diff --git a/alib2data/src/alphabet/UniqueSymbol.h b/alib2data/src/alphabet/UniqueSymbol.h index 28354a3bfe..5a9f364357 100644 --- a/alib2data/src/alphabet/UniqueSymbol.h +++ b/alib2data/src/alphabet/UniqueSymbol.h @@ -26,57 +26,53 @@ public: * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit UniqueSymbol(Symbol symbol, primitive::Integer id); + explicit UniqueSymbol ( Symbol symbol, primitive::Integer id ); - virtual SymbolBase* clone() const; + virtual SymbolBase * clone ( ) const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * plunder ( ) &&; /** * @return name of the symbol */ - const Symbol& getSymbol() const; + const Symbol & getSymbol ( ) const; - const primitive::Integer& getId() const; + const primitive::Integer & getId ( ) const; - primitive::Integer& getId(); + primitive::Integer & getId ( ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const UniqueSymbol& other) const; + virtual int compare ( const UniqueSymbol & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static UniqueSymbol parse(std::deque<sax::Token>::iterator& input); + static UniqueSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::UniqueSymbol> { - int operator()(const alphabet::UniqueSymbol& first, const alphabet::UniqueSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::UniqueSymbol > { + int operator ()( const alphabet::UniqueSymbol & first, const alphabet::UniqueSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* SYMBOL_ID_SYMBOL_H_ */ - diff --git a/alib2data/src/alphabet/VariablesBarSymbol.h b/alib2data/src/alphabet/VariablesBarSymbol.h index 8407df33aa..0d311be80b 100644 --- a/alib2data/src/alphabet/VariablesBarSymbol.h +++ b/alib2data/src/alphabet/VariablesBarSymbol.h @@ -21,46 +21,43 @@ public: * Creates a bar symbol. * @param symbol name of the symbol */ - explicit VariablesBarSymbol(); + explicit VariablesBarSymbol ( ); - virtual SymbolBase* clone() const; - virtual SymbolBase* plunder() &&; + virtual SymbolBase * clone ( ) const; + virtual SymbolBase * plunder ( ) &&; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const VariablesBarSymbol& other) const; + virtual int compare ( const VariablesBarSymbol & other ) const; - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; static VariablesBarSymbol BAR; const static std::string XML_TAG_NAME; - static VariablesBarSymbol parse(std::deque<sax::Token>::iterator& input); + static VariablesBarSymbol parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual SymbolBase* next() const; - virtual SymbolBase* inc() &&; + virtual SymbolBase * next ( ) const; + virtual SymbolBase * inc ( ) &&; }; } /* namespace alphabet */ namespace std { -template<> -struct compare<alphabet::VariablesBarSymbol> { - int operator()(const alphabet::VariablesBarSymbol& first, const alphabet::VariablesBarSymbol& second) const { - return first.compare(second); +template < > +struct compare < alphabet::VariablesBarSymbol > { + int operator ()( const alphabet::VariablesBarSymbol & first, const alphabet::VariablesBarSymbol & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/FSM/CompactNFA.h b/alib2data/src/automaton/FSM/CompactNFA.h index 926b005b0c..88934dcf89 100644 --- a/alib2data/src/automaton/FSM/CompactNFA.h +++ b/alib2data/src/automaton/FSM/CompactNFA.h @@ -26,27 +26,28 @@ namespace automaton { */ class CompactNFA : public AutomatonBase, public SingleInitialState, public InputAlphabet { protected: - std::map<std::pair<State, string::LinearString>, std::set<State> > transitions; + std::map < std::pair < State, string::LinearString >, std::set < State > > transitions; + public: - explicit CompactNFA(State initialState); - explicit CompactNFA(const EpsilonNFA& other); - explicit CompactNFA(const MultiInitialStateNFA& other); - explicit CompactNFA(const NFA& other); - explicit CompactNFA(const DFA& other); + explicit CompactNFA ( State initialState ); + explicit CompactNFA ( const EpsilonNFA & other ); + explicit CompactNFA ( const MultiInitialStateNFA & other ); + explicit CompactNFA ( const NFA & other ); + explicit CompactNFA ( const DFA & other ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition defined by parameters to the automaton. @@ -55,62 +56,59 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(State current, string::LinearString input, State next); + bool addTransition ( State current, string::LinearString input, State next ); /** * Removes transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const State& current, const string::LinearString& input, const State& next); + bool removeTransition ( const State & current, const string::LinearString & input, const State & next ); /** * @return automaton transitions */ - const std::map<std::pair<State, string::LinearString>, std::set<State>>& getTransitions() const; + const std::map < std::pair < State, string::LinearString >, std::set < State > > & getTransitions ( ) const; /** * @return automaton transitions from state */ - std::map<std::pair<State, string::LinearString>, std::set<State>> getTransitionsFromState(const State& from) const; + std::map < std::pair < State, string::LinearString >, std::set < State > > getTransitionsFromState ( const State & from ) const; /** * @return automaton transitions to state */ - std::map<std::pair<State, string::LinearString>, std::set<State>> getTransitionsToState(const State& from) const; + std::map < std::pair < State, string::LinearString >, std::set < State > > getTransitionsToState ( const State & from ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const CompactNFA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const CompactNFA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static CompactNFA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, CompactNFA& automaton); + static CompactNFA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, CompactNFA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::CompactNFA> { - int operator()(const automaton::CompactNFA& first, const automaton::CompactNFA& second) const { - return first.compare(second); +template < > +struct compare < automaton::CompactNFA > { + int operator ()( const automaton::CompactNFA & first, const automaton::CompactNFA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/FSM/DFA.h b/alib2data/src/automaton/FSM/DFA.h index 2945d99ffd..e36bc3a9b4 100644 --- a/alib2data/src/automaton/FSM/DFA.h +++ b/alib2data/src/automaton/FSM/DFA.h @@ -22,23 +22,24 @@ namespace automaton { */ class DFA : public AutomatonBase, public SingleInitialState, public InputAlphabet { protected: - std::map<std::pair<State, alphabet::Symbol>, State> transitions; + std::map < std::pair < State, alphabet::Symbol >, State > transitions; + public: - explicit DFA(State initialState); + explicit DFA ( State initialState ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition defined by parameters to the automaton. @@ -47,29 +48,29 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(State current, alphabet::Symbol input, const State next); + bool addTransition ( State current, alphabet::Symbol input, const State next ); /** * Removes transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const State& current, const alphabet::Symbol& input, const State& next); + bool removeTransition ( const State & current, const alphabet::Symbol & input, const State & next ); /** * @return automaton transitions */ - const std::map<std::pair<State, alphabet::Symbol>, State>& getTransitions() const; + const std::map < std::pair < State, alphabet::Symbol >, State > & getTransitions ( ) const; /** * @return automaton transitions from state */ - std::map<std::pair<State, alphabet::Symbol>, State> getTransitionsFromState(const State& from) const; + std::map < std::pair < State, alphabet::Symbol >, State > getTransitionsFromState ( const State & from ) const; /** * @return automaton transitions to state */ - std::map<std::pair<State, alphabet::Symbol>, State> getTransitionsToState(const State& from) const; + std::map < std::pair < State, alphabet::Symbol >, State > getTransitionsToState ( const State & from ) const; /** * Determines whether DFA is total deterministic @@ -78,40 +79,37 @@ public: * \li \c size of transition function \forall states and \forall input symbols \delta (from state, input symbol) = 1 * @return true when automaton is total deterministic, false otherwise */ - bool isTotal() const; + bool isTotal ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const DFA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const DFA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static DFA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, DFA& automaton); + static DFA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, DFA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::DFA> { - int operator()(const automaton::DFA& first, const automaton::DFA& second) const { - return first.compare(second); +template < > +struct compare < automaton::DFA > { + int operator ()( const automaton::DFA & first, const automaton::DFA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/FSM/EpsilonNFA.h b/alib2data/src/automaton/FSM/EpsilonNFA.h index f029a69a3c..c69ab4f1ef 100644 --- a/alib2data/src/automaton/FSM/EpsilonNFA.h +++ b/alib2data/src/automaton/FSM/EpsilonNFA.h @@ -27,26 +27,27 @@ namespace automaton { */ class EpsilonNFA : public AutomatonBase, public SingleInitialState, public InputAlphabet { protected: - std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol> >, std::set<State> > transitions; + std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < State > > transitions; + public: - explicit EpsilonNFA(State initialState); - explicit EpsilonNFA(const MultiInitialStateNFA& other); - explicit EpsilonNFA(const NFA& other); - explicit EpsilonNFA(const DFA& other); + explicit EpsilonNFA ( State initialState ); + explicit EpsilonNFA ( const MultiInitialStateNFA & other ); + explicit EpsilonNFA ( const NFA & other ); + explicit EpsilonNFA ( const DFA & other ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition defined by parameters to the automaton. @@ -55,7 +56,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(State from, std::variant<string::Epsilon, alphabet::Symbol> input, State to); + bool addTransition ( State from, std::variant < string::Epsilon, alphabet::Symbol > input, State to ); /** * Adds transition defined by parameters to the automaton. @@ -64,7 +65,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(State from, alphabet::Symbol input, State to); + bool addTransition ( State from, alphabet::Symbol input, State to ); /** * Adds transition defined by parameters to the automaton. @@ -72,73 +73,72 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(State from, State to); + bool addTransition ( State from, State to ); /** * Removes transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const State& current, const alphabet::Symbol& input, const State& next); + bool removeTransition ( const State & current, const alphabet::Symbol & input, const State & next ); /** * Removes transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const State& current, const State& next); + bool removeTransition ( const State & current, const State & next ); /** * @return automaton transitions */ - const std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol> >, std::set<State> >& getTransitions() const; + const std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < State > > & getTransitions ( ) const; /** * @return automaton epsilon transitions */ - std::map<State, std::set<State> > getEpsilonTransitions() const; + std::map < State, std::set < State > > getEpsilonTransitions ( ) const; /** * @return automaton transitions reading some symbol */ - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > getSymbolTransitions() const; - + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > getSymbolTransitions ( ) const; /** * @return automaton transitions from state */ - std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol> >, std::set<State> > getTransitionsFromState(const State& from) const; + std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < State > > getTransitionsFromState ( const State & from ) const; /** * @return automaton epsilon transitions from state */ - std::map<State, std::set<State> > getEpsilonTransitionsFromState(const State& from) const; + std::map < State, std::set < State > > getEpsilonTransitionsFromState ( const State & from ) const; /** * @return automaton transitions from state reading some symbols */ - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > getSymbolTransitionsFromState(const State& from) const; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > getSymbolTransitionsFromState ( const State & from ) const; /** * @return automaton transitions to state */ - std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol> >, std::set<State> > getTransitionsToState(const State& from) const; + std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < State > > getTransitionsToState ( const State & from ) const; /** * @return automaton epsilon transitions to state */ - std::map<State, std::set<State> > getEpsilonTransitionsToState(const State& to) const; + std::map < State, std::set < State > > getEpsilonTransitionsToState ( const State & to ) const; /** * @return automaton transitions to state reading some symbols */ - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > getSymbolTransitionsToState(const State& to) const; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > getSymbolTransitionsToState ( const State & to ) const; /** * Determines whether NFA is without epsilon transitions. * @return true when automaton doesn't contain epsilon transitions, false otherwise */ - bool isEpsilonFree() const; + bool isEpsilonFree ( ) const; /** * Determines whether NFA is deterministic. @@ -147,7 +147,7 @@ public: * \li \c size of transition function \delta (from state, input symbol) \leq 1 * @return true when automaton is deterministic, false otherwise */ - bool isDeterministic() const; + bool isDeterministic ( ) const; /** * Determines whether NFA is total deterministic @@ -156,40 +156,37 @@ public: * \li \c size of transition function \forall states and \forall input symbols \delta (from state, input symbol) = 1 * @return true when automaton is total deterministic, false otherwise */ - bool isTotal() const; + bool isTotal ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const EpsilonNFA& other) const; + virtual int compare ( const EpsilonNFA & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static EpsilonNFA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, EpsilonNFA& automaton); + static EpsilonNFA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, EpsilonNFA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::EpsilonNFA> { - int operator()(const automaton::EpsilonNFA& first, const automaton::EpsilonNFA& second) const { - return first.compare(second); +template < > +struct compare < automaton::EpsilonNFA > { + int operator ()( const automaton::EpsilonNFA & first, const automaton::EpsilonNFA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/FSM/ExtendedNFA.h b/alib2data/src/automaton/FSM/ExtendedNFA.h index 42a7f65bdd..63c3169463 100644 --- a/alib2data/src/automaton/FSM/ExtendedNFA.h +++ b/alib2data/src/automaton/FSM/ExtendedNFA.h @@ -27,28 +27,29 @@ namespace automaton { */ class ExtendedNFA : public AutomatonBase, public SingleInitialState, public InputAlphabet { protected: - std::map<std::pair<State, regexp::RegExp>, std::set<State> > transitions; + std::map < std::pair < State, regexp::RegExp >, std::set < State > > transitions; + public: - explicit ExtendedNFA(State initialState); - explicit ExtendedNFA(const CompactNFA& other); - explicit ExtendedNFA(const EpsilonNFA& other); - explicit ExtendedNFA(const MultiInitialStateNFA& other); - explicit ExtendedNFA(const NFA& other); - explicit ExtendedNFA(const DFA& other); + explicit ExtendedNFA ( State initialState ); + explicit ExtendedNFA ( const CompactNFA & other ); + explicit ExtendedNFA ( const EpsilonNFA & other ); + explicit ExtendedNFA ( const MultiInitialStateNFA & other ); + explicit ExtendedNFA ( const NFA & other ); + explicit ExtendedNFA ( const DFA & other ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition defined by parameters to the automaton. @@ -57,62 +58,59 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(State current, regexp::RegExp input, State next); + bool addTransition ( State current, regexp::RegExp input, State next ); /** * Removes transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const State& current, const regexp::RegExp& input, const State& next); + bool removeTransition ( const State & current, const regexp::RegExp & input, const State & next ); /** * @return automaton transitions */ - const std::map<std::pair<State, regexp::RegExp>, std::set<State> >& getTransitions() const; + const std::map < std::pair < State, regexp::RegExp >, std::set < State > > & getTransitions ( ) const; /** * @return automaton transitions from state */ - std::map<std::pair<State, regexp::RegExp>, std::set<State> > getTransitionsFromState(const State& from) const; + std::map < std::pair < State, regexp::RegExp >, std::set < State > > getTransitionsFromState ( const State & from ) const; /** * @return automaton transitions to state */ - std::map<std::pair<State, regexp::RegExp>, std::set<State> > getTransitionsToState(const State& from) const; + std::map < std::pair < State, regexp::RegExp >, std::set < State > > getTransitionsToState ( const State & from ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const ExtendedNFA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const ExtendedNFA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static ExtendedNFA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, ExtendedNFA& automaton); + static ExtendedNFA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, ExtendedNFA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::ExtendedNFA> { - int operator()(const automaton::ExtendedNFA& first, const automaton::ExtendedNFA& second) const { - return first.compare(second); +template < > +struct compare < automaton::ExtendedNFA > { + int operator ()( const automaton::ExtendedNFA & first, const automaton::ExtendedNFA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/FSM/MultiInitialStateNFA.h b/alib2data/src/automaton/FSM/MultiInitialStateNFA.h index f4cb5568c5..747cb0fbdd 100644 --- a/alib2data/src/automaton/FSM/MultiInitialStateNFA.h +++ b/alib2data/src/automaton/FSM/MultiInitialStateNFA.h @@ -24,25 +24,26 @@ namespace automaton { */ class MultiInitialStateNFA : public AutomatonBase, public MultiInitialStates, public InputAlphabet { protected: - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > transitions; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > transitions; + public: - explicit MultiInitialStateNFA(); - explicit MultiInitialStateNFA(const NFA& other); - explicit MultiInitialStateNFA(const DFA& other); + explicit MultiInitialStateNFA ( ); + explicit MultiInitialStateNFA ( const NFA & other ); + explicit MultiInitialStateNFA ( const DFA & other ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition defined by parameters to the automaton. @@ -51,29 +52,29 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(State current, alphabet::Symbol input, State next); + bool addTransition ( State current, alphabet::Symbol input, State next ); /** * Removes transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const State& current, const alphabet::Symbol& input, const State& next); + bool removeTransition ( const State & current, const alphabet::Symbol & input, const State & next ); /** * @return automaton transitions */ - const std::map<std::pair<State, alphabet::Symbol>, std::set<State> >& getTransitions() const; + const std::map < std::pair < State, alphabet::Symbol >, std::set < State > > & getTransitions ( ) const; /** * @return automaton transitions from state */ - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > getTransitionsFromState(const State& from) const; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > getTransitionsFromState ( const State & from ) const; /** * @return automaton transitions to state */ - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > getTransitionsToState(const State& from) const; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > getTransitionsToState ( const State & from ) const; /** * Determines whether MultiInitialStateNFA is deterministic. @@ -83,7 +84,7 @@ public: * \li \c size of transition function \delta (from state, input symbol) \leq 1 * @return true when automaton is deterministic, false otherwise */ - bool isDeterministic() const; + bool isDeterministic ( ) const; /** * Determines whether MultiInitialStateNFA is total deterministic @@ -92,42 +93,39 @@ public: * \li \c size of transition function \forall states and \forall input symbols \delta (from state, input symbol) = 1 * @return true when automaton is total deterministic, false otherwise */ - bool isTotal() const; + bool isTotal ( ) const; - unsigned transitionsSize() const; + unsigned transitionsSize ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const MultiInitialStateNFA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const MultiInitialStateNFA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static MultiInitialStateNFA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, MultiInitialStateNFA& automaton); + static MultiInitialStateNFA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, MultiInitialStateNFA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::MultiInitialStateNFA> { - int operator()(const automaton::MultiInitialStateNFA& first, const automaton::MultiInitialStateNFA& second) const { - return first.compare(second); +template < > +struct compare < automaton::MultiInitialStateNFA > { + int operator ()( const automaton::MultiInitialStateNFA & first, const automaton::MultiInitialStateNFA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/FSM/NFA.h b/alib2data/src/automaton/FSM/NFA.h index 8b6db5f9ae..057873fd62 100644 --- a/alib2data/src/automaton/FSM/NFA.h +++ b/alib2data/src/automaton/FSM/NFA.h @@ -24,24 +24,25 @@ namespace automaton { */ class NFA : public AutomatonBase, public SingleInitialState, public InputAlphabet { protected: - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > transitions; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > transitions; + public: - explicit NFA(State initialState); - explicit NFA(const DFA& other); + explicit NFA ( State initialState ); + explicit NFA ( const DFA & other ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition defined by parameters to the automaton. @@ -50,29 +51,29 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(State current, alphabet::Symbol input, State next); + bool addTransition ( State current, alphabet::Symbol input, State next ); /** * Removes transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const State& current, const alphabet::Symbol& input, const State& next); + bool removeTransition ( const State & current, const alphabet::Symbol & input, const State & next ); /** * @return automaton transitions */ - const std::map<std::pair<State, alphabet::Symbol>, std::set<State> >& getTransitions() const; + const std::map < std::pair < State, alphabet::Symbol >, std::set < State > > & getTransitions ( ) const; /** * @return automaton transitions from state */ - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > getTransitionsFromState(const State& from) const; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > getTransitionsFromState ( const State & from ) const; /** * @return automaton transitions to state */ - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > getTransitionsToState(const State& from) const; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > getTransitionsToState ( const State & from ) const; /** * Determines whether NFA is deterministic. @@ -81,7 +82,7 @@ public: * \li \c size of transition function \delta (from state, input symbol) \leq 1 * @return true when automaton is deterministic, false otherwise */ - bool isDeterministic() const; + bool isDeterministic ( ) const; /** * Determines whether NFA is total deterministic @@ -90,42 +91,39 @@ public: * \li \c size of transition function \forall states and \forall input symbols \delta (from state, input symbol) = 1 * @return true when automaton is total deterministic, false otherwise */ - bool isTotal() const; + bool isTotal ( ) const; - unsigned transitionsSize() const; + unsigned transitionsSize ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const NFA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const NFA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static NFA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, NFA& automaton); + static NFA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, NFA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::NFA> { - int operator()(const automaton::NFA& first, const automaton::NFA& second) const { - return first.compare(second); +template < > +struct compare < automaton::NFA > { + int operator ()( const automaton::NFA & first, const automaton::NFA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/PDA/DPDA.h b/alib2data/src/automaton/PDA/DPDA.h index ebd2b29c15..199afdf8b7 100644 --- a/alib2data/src/automaton/PDA/DPDA.h +++ b/alib2data/src/automaton/PDA/DPDA.h @@ -30,28 +30,29 @@ namespace automaton { */ class DPDA : public AutomatonBase, public SingleInitialSymbolPushdownStoreAlphabet, public SingleInitialState, public InputAlphabet { protected: - std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<State, std::vector<alphabet::Symbol> > > transitions; + std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < State, std::vector < alphabet::Symbol > > > transitions; + public: - explicit DPDA(State initialState, alphabet::Symbol initialPushdownSymbol); + explicit DPDA ( State initialState, alphabet::Symbol initialPushdownSymbol ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + virtual bool removeStackSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition to the DPDA. @@ -59,70 +60,67 @@ public: * @throws AutomatonException when some part of the transition is not present * in the DPDA (state, input symbol, stack symbol) or when transition already exists */ - bool addTransition(State from, std::variant<string::Epsilon, alphabet::Symbol> input, std::vector<alphabet::Symbol> pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, std::variant < string::Epsilon, alphabet::Symbol > input, std::vector < alphabet::Symbol > pop, State to, std::vector < alphabet::Symbol > push ); - bool addTransition(State from, alphabet::Symbol input, std::vector<alphabet::Symbol> pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, alphabet::Symbol input, std::vector < alphabet::Symbol > pop, State to, std::vector < alphabet::Symbol > push ); - bool addTransition(State from, std::vector<alphabet::Symbol> pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, std::vector < alphabet::Symbol > pop, State to, std::vector < alphabet::Symbol > push ); /** * Removes the transition from the DPDA. * @param transition transition to remove * @throws AutomatonException when transition is not present in the DPDA */ - bool removeTransition(const State& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const std::vector<alphabet::Symbol>& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const std::variant < string::Epsilon, alphabet::Symbol > & input, const std::vector < alphabet::Symbol > & pop, const State & to, const std::vector < alphabet::Symbol > & push ); - bool removeTransition(const State& from, const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const alphabet::Symbol & input, const std::vector < alphabet::Symbol > & pop, const State & to, const std::vector < alphabet::Symbol > & push ); - bool removeTransition(const State& from, const std::vector<alphabet::Symbol>& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const std::vector < alphabet::Symbol > & pop, const State & to, const std::vector < alphabet::Symbol > & push ); /** * @return DPDA transitions */ - const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<State, std::vector<alphabet::Symbol> > >& getTransitions() const; + const std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < State, std::vector < alphabet::Symbol > > > & getTransitions ( ) const; /** * @return automaton transitions from state */ - std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<State, std::vector<alphabet::Symbol> > > getTransitionsFromState(const State& from) const; + std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < State, std::vector < alphabet::Symbol > > > getTransitionsFromState ( const State & from ) const; /** * @return automaton transitions to state */ - std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::pair<State, std::vector<alphabet::Symbol> > > getTransitionsToState(const State& from) const; + std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::pair < State, std::vector < alphabet::Symbol > > > getTransitionsToState ( const State & from ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const DPDA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const DPDA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static DPDA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, DPDA& automaton); + static DPDA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, DPDA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::DPDA> { - int operator()(const automaton::DPDA& first, const automaton::DPDA& second) const { - return first.compare(second); +template < > +struct compare < automaton::DPDA > { + int operator ()( const automaton::DPDA & first, const automaton::DPDA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/PDA/InputDrivenDPDA.h b/alib2data/src/automaton/PDA/InputDrivenDPDA.h index 6ee217375d..a4e0576941 100644 --- a/alib2data/src/automaton/PDA/InputDrivenDPDA.h +++ b/alib2data/src/automaton/PDA/InputDrivenDPDA.h @@ -24,39 +24,40 @@ namespace automaton { */ class InputDrivenDPDA : public AutomatonBase, public SingleInitialSymbolPushdownStoreAlphabet, public SingleInitialState, public InputAlphabet { protected: - std::map<std::pair<State, alphabet::Symbol>, State> transitions; - std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>> inputSymbolToPushdownStoreOperation; + std::map < std::pair < State, alphabet::Symbol >, State > transitions; + std::map < alphabet::Symbol, std::pair < std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > inputSymbolToPushdownStoreOperation; + + void checkPushdownStoreOperation ( const alphabet::Symbol & input, const std::vector < alphabet::Symbol > & pop, const std::vector < alphabet::Symbol > & push ); - void checkPushdownStoreOperation(const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const std::vector<alphabet::Symbol>& push); public: - explicit InputDrivenDPDA(State initialState, alphabet::Symbol initialPushdownSymbol); + explicit InputDrivenDPDA ( State initialState, alphabet::Symbol initialPushdownSymbol ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /* * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + virtual bool removeStackSymbol ( const alphabet::Symbol & symbol ); - bool setPushdownStoreOperation(alphabet::Symbol input, std::vector<alphabet::Symbol> pop, std::vector<alphabet::Symbol> push); + bool setPushdownStoreOperation ( alphabet::Symbol input, std::vector < alphabet::Symbol > pop, std::vector < alphabet::Symbol > push ); - void setPushdownStoreOperations(std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>> operations); + void setPushdownStoreOperations ( std::map < alphabet::Symbol, std::pair < std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > operations ); - bool clearPushdownStoreOperation(const alphabet::Symbol& input); + bool clearPushdownStoreOperation ( const alphabet::Symbol & input ); - const std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>>& getPushdownStoreOperations() const; + const std::map < alphabet::Symbol, std::pair < std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > & getPushdownStoreOperations ( ) const; /** * Adds transition defined by parameters to the automaton. @@ -65,23 +66,23 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(State current, alphabet::Symbol input, State next); + bool addTransition ( State current, alphabet::Symbol input, State next ); /** * Removes transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const State& current, const alphabet::Symbol& input, const State& next); + bool removeTransition ( const State & current, const alphabet::Symbol & input, const State & next ); /** * @return automaton transitions */ - const std::map<std::pair<State, alphabet::Symbol>, State>& getTransitions() const; + const std::map < std::pair < State, alphabet::Symbol >, State > & getTransitions ( ) const; - std::map<std::pair<State, alphabet::Symbol>, State> getTransitionsFromState(const State& from) const; + std::map < std::pair < State, alphabet::Symbol >, State > getTransitionsFromState ( const State & from ) const; - std::map<std::pair<State, alphabet::Symbol>, State> getTransitionsToState(const State& to) const; + std::map < std::pair < State, alphabet::Symbol >, State > getTransitionsToState ( const State & to ) const; /** * Determines whether InputDrivenDPDA is deterministic. @@ -91,40 +92,37 @@ public: * \li \c size of transition function \delta (from state, input symbol) \leq 1 * @return true when automaton is deterministic, false otherwise */ - bool isDeterministic() const; + bool isDeterministic ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const InputDrivenDPDA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const InputDrivenDPDA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static InputDrivenDPDA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, InputDrivenDPDA& automaton); + static InputDrivenDPDA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, InputDrivenDPDA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::InputDrivenDPDA> { - int operator()(const automaton::InputDrivenDPDA& first, const automaton::InputDrivenDPDA& second) const { - return first.compare(second); +template < > +struct compare < automaton::InputDrivenDPDA > { + int operator ()( const automaton::InputDrivenDPDA & first, const automaton::InputDrivenDPDA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/PDA/InputDrivenNPDA.h b/alib2data/src/automaton/PDA/InputDrivenNPDA.h index 535eaf125a..b0f157937f 100644 --- a/alib2data/src/automaton/PDA/InputDrivenNPDA.h +++ b/alib2data/src/automaton/PDA/InputDrivenNPDA.h @@ -24,39 +24,40 @@ namespace automaton { */ class InputDrivenNPDA : public AutomatonBase, public SingleInitialSymbolPushdownStoreAlphabet, public SingleInitialState, public InputAlphabet { protected: - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > transitions; - std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>> inputSymbolToPushdownStoreOperation; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > transitions; + std::map < alphabet::Symbol, std::pair < std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > inputSymbolToPushdownStoreOperation; + + void checkPushdownStoreOperation ( const alphabet::Symbol & input, const std::vector < alphabet::Symbol > & pop, const std::vector < alphabet::Symbol > & push ); - void checkPushdownStoreOperation(const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const std::vector<alphabet::Symbol>& push); public: - explicit InputDrivenNPDA(State initialState, alphabet::Symbol initialPushdownSymbol); + explicit InputDrivenNPDA ( State initialState, alphabet::Symbol initialPushdownSymbol ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /* * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + virtual bool removeStackSymbol ( const alphabet::Symbol & symbol ); - bool setPushdownStoreOperation(alphabet::Symbol input, std::vector<alphabet::Symbol> pop, std::vector<alphabet::Symbol> push); + bool setPushdownStoreOperation ( alphabet::Symbol input, std::vector < alphabet::Symbol > pop, std::vector < alphabet::Symbol > push ); - void setPushdownStoreOperations(std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>> operations); + void setPushdownStoreOperations ( std::map < alphabet::Symbol, std::pair < std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > operations ); - bool clearPushdownStoreOperation(const alphabet::Symbol& input); + bool clearPushdownStoreOperation ( const alphabet::Symbol & input ); - const std::map<alphabet::Symbol, std::pair<std::vector<alphabet::Symbol>, std::vector<alphabet::Symbol>>>& getPushdownStoreOperations() const; + const std::map < alphabet::Symbol, std::pair < std::vector < alphabet::Symbol >, std::vector < alphabet::Symbol > > > & getPushdownStoreOperations ( ) const; /** * Adds transition defined by parameters to the automaton. @@ -65,23 +66,24 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(State current, alphabet::Symbol input, State next); + bool addTransition ( State current, alphabet::Symbol input, State next ); /** * Removes transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const State& current, const alphabet::Symbol& input, const State& next); + bool removeTransition ( const State & current, const alphabet::Symbol & input, const State & next ); /** * @return automaton transitions */ - const std::map<std::pair<State, alphabet::Symbol>, std::set<State> >& getTransitions() const; + const std::map < std::pair < State, alphabet::Symbol >, std::set < State > > & getTransitions ( ) const; + + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > getTransitionsFromState ( const State & from ) const; - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > getTransitionsFromState(const State& from) const; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > getTransitionsToState ( const State & to ) const; - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > getTransitionsToState(const State& to) const; /** * Determines whether InputDrivenNPDA is deterministic. * FA is deterministic if and only if: @@ -90,40 +92,37 @@ public: * \li \c size of transition function \delta (from state, input symbol) \leq 1 * @return true when automaton is deterministic, false otherwise */ - bool isDeterministic() const; + bool isDeterministic ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const InputDrivenNPDA& other) const; + virtual int compare ( const InputDrivenNPDA & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static InputDrivenNPDA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, InputDrivenNPDA& automaton); + static InputDrivenNPDA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, InputDrivenNPDA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::InputDrivenNPDA> { - int operator()(const automaton::InputDrivenNPDA& first, const automaton::InputDrivenNPDA& second) const { - return first.compare(second); +template < > +struct compare < automaton::InputDrivenNPDA > { + int operator ()( const automaton::InputDrivenNPDA & first, const automaton::InputDrivenNPDA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/PDA/NPDA.h b/alib2data/src/automaton/PDA/NPDA.h index d9f0b7be56..dbc9eba711 100644 --- a/alib2data/src/automaton/PDA/NPDA.h +++ b/alib2data/src/automaton/PDA/NPDA.h @@ -26,28 +26,29 @@ namespace automaton { */ class NPDA : public AutomatonBase, public SingleInitialSymbolPushdownStoreAlphabet, public SingleInitialState, public InputAlphabet { protected: - std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<State, std::vector<alphabet::Symbol> > > > transitions; + std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::pair < State, std::vector < alphabet::Symbol > > > > transitions; + public: - explicit NPDA(State initialState, alphabet::Symbol initialPushdownSymbol); + explicit NPDA ( State initialState, alphabet::Symbol initialPushdownSymbol ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + virtual bool removeStackSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition to the NPDA. @@ -55,60 +56,57 @@ public: * @throws AutomatonException when some part of the transition is not present * in the NPDA (state, input symbol, stack symbol) or when transition already exists */ - bool addTransition(State from, std::variant<string::Epsilon, alphabet::Symbol> input, std::vector<alphabet::Symbol> pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, std::variant < string::Epsilon, alphabet::Symbol > input, std::vector < alphabet::Symbol > pop, State to, std::vector < alphabet::Symbol > push ); - bool addTransition(State from, alphabet::Symbol input, std::vector<alphabet::Symbol> pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, alphabet::Symbol input, std::vector < alphabet::Symbol > pop, State to, std::vector < alphabet::Symbol > push ); - bool addTransition(State from, std::vector<alphabet::Symbol> pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, std::vector < alphabet::Symbol > pop, State to, std::vector < alphabet::Symbol > push ); /** * Removes the transition from the NPDA. * @param transition transition to remove * @throws AutomatonException when transition is not present in the NPDA */ - bool removeTransition(const State& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const std::vector<alphabet::Symbol>& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const std::variant < string::Epsilon, alphabet::Symbol > & input, const std::vector < alphabet::Symbol > & pop, const State & to, const std::vector < alphabet::Symbol > & push ); - bool removeTransition(const State& from, const alphabet::Symbol& input, const std::vector<alphabet::Symbol>& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const alphabet::Symbol & input, const std::vector < alphabet::Symbol > & pop, const State & to, const std::vector < alphabet::Symbol > & push ); - bool removeTransition(const State& from, const std::vector<alphabet::Symbol>& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const std::vector < alphabet::Symbol > & pop, const State & to, const std::vector < alphabet::Symbol > & push ); /** * @return NPDA transitions */ - const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, std::vector<alphabet::Symbol> >, std::set<std::pair<State, std::vector<alphabet::Symbol> > > >& getTransitions() const; + const std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, std::vector < alphabet::Symbol > >, std::set < std::pair < State, std::vector < alphabet::Symbol > > > > & getTransitions ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const NPDA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const NPDA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static NPDA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, NPDA& automaton); + static NPDA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, NPDA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::NPDA> { - int operator()(const automaton::NPDA& first, const automaton::NPDA& second) const { - return first.compare(second); +template < > +struct compare < automaton::NPDA > { + int operator ()( const automaton::NPDA & first, const automaton::NPDA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h index b5b9da828c..3df41d3b2e 100644 --- a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h +++ b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicDPDA.h @@ -26,30 +26,31 @@ namespace automaton { */ class RealTimeHeightDeterministicDPDA : public AutomatonBase, public InputAlphabet, public SingleInitialState, public BottomOfTheStackSymbolPushdownStoreAlphabet { protected: - std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol>>, std::pair<State, alphabet::Symbol> > callTransitions; - std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, State> returnTransitions; - std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol>>, State> localTransitions; + std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::pair < State, alphabet::Symbol > > callTransitions; + std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, State > returnTransitions; + std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, State > localTransitions; + public: - explicit RealTimeHeightDeterministicDPDA(State initialState, alphabet::Symbol bottomOfTheStackSymbol); + explicit RealTimeHeightDeterministicDPDA ( State initialState, alphabet::Symbol bottomOfTheStackSymbol ); + + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* clone() const; - - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /* * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + virtual bool removeStackSymbol ( const alphabet::Symbol & symbol ); /** * Adds call transition defined by parameters to the automaton. @@ -58,9 +59,9 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addCallTransition(State current, std::variant<string::Epsilon, alphabet::Symbol> input, State next, alphabet::Symbol push); - bool addCallTransition(State current, State next, alphabet::Symbol push); - bool addCallTransition(State current, alphabet::Symbol input, State next, alphabet::Symbol push); + bool addCallTransition ( State current, std::variant < string::Epsilon, alphabet::Symbol > input, State next, alphabet::Symbol push ); + bool addCallTransition ( State current, State next, alphabet::Symbol push ); + bool addCallTransition ( State current, alphabet::Symbol input, State next, alphabet::Symbol push ); /** * Adds return transition defined by parameters to the automaton. @@ -69,9 +70,9 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addReturnTransition(State current, std::variant<string::Epsilon, alphabet::Symbol> input, alphabet::Symbol pop, State next); - bool addReturnTransition(State current, alphabet::Symbol pop, State next); - bool addReturnTransition(State current, alphabet::Symbol input, alphabet::Symbol pop, State next); + bool addReturnTransition ( State current, std::variant < string::Epsilon, alphabet::Symbol > input, alphabet::Symbol pop, State next ); + bool addReturnTransition ( State current, alphabet::Symbol pop, State next ); + bool addReturnTransition ( State current, alphabet::Symbol input, alphabet::Symbol pop, State next ); /** * Adds local transition defined by parameters to the automaton. @@ -80,75 +81,72 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addLocalTransition(State current, std::variant<string::Epsilon, alphabet::Symbol> input, State next); - bool addLocalTransition(State current, State next); - bool addLocalTransition(State current, alphabet::Symbol input, State next); + bool addLocalTransition ( State current, std::variant < string::Epsilon, alphabet::Symbol > input, State next ); + bool addLocalTransition ( State current, State next ); + bool addLocalTransition ( State current, alphabet::Symbol input, State next ); /** * Removes call transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeCallTransition(const State& current, const std::variant<string::Epsilon, alphabet::Symbol>& input, const State& next, const alphabet::Symbol& push); - bool removeCallTransition(const State& current, const State& next, const alphabet::Symbol& push); - bool removeCallTransition(const State& current, const alphabet::Symbol& input, const State& next, const alphabet::Symbol& push); + bool removeCallTransition ( const State & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const State & next, const alphabet::Symbol & push ); + bool removeCallTransition ( const State & current, const State & next, const alphabet::Symbol & push ); + bool removeCallTransition ( const State & current, const alphabet::Symbol & input, const State & next, const alphabet::Symbol & push ); /** * Removes return transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeReturnTransition(const State& current, const std::variant<string::Epsilon, alphabet::Symbol>& input, const alphabet::Symbol& pop, const State& next); - bool removeReturnTransition(const State& current, const alphabet::Symbol& pop, const State& next); - bool removeReturnTransition(const State& current, const alphabet::Symbol& input, const alphabet::Symbol& pop, const State& next); + bool removeReturnTransition ( const State & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const alphabet::Symbol & pop, const State & next ); + bool removeReturnTransition ( const State & current, const alphabet::Symbol & pop, const State & next ); + bool removeReturnTransition ( const State & current, const alphabet::Symbol & input, const alphabet::Symbol & pop, const State & next ); /** * Removes transition local from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeLocalTransition(const State& current, const std::variant<string::Epsilon, alphabet::Symbol>& input, const State& next); - bool removeLocalTransition(const State& current, const State& next); - bool removeLocalTransition(const State& current, const alphabet::Symbol& input, const State& next); + bool removeLocalTransition ( const State & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const State & next ); + bool removeLocalTransition ( const State & current, const State & next ); + bool removeLocalTransition ( const State & current, const alphabet::Symbol & input, const State & next ); - const std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol>>, std::pair<State, alphabet::Symbol> >& getCallTransitions() const; + const std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::pair < State, alphabet::Symbol > > & getCallTransitions ( ) const; - const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, State>& getReturnTransitions() const; + const std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, State > & getReturnTransitions ( ) const; - const std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol>>, State>& getLocalTransitions() const; + const std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, State > & getLocalTransitions ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const RealTimeHeightDeterministicDPDA& other) const; + virtual int compare ( const RealTimeHeightDeterministicDPDA & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static RealTimeHeightDeterministicDPDA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, RealTimeHeightDeterministicDPDA& automaton); + static RealTimeHeightDeterministicDPDA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, RealTimeHeightDeterministicDPDA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::RealTimeHeightDeterministicDPDA> { - int operator()(const automaton::RealTimeHeightDeterministicDPDA& first, const automaton::RealTimeHeightDeterministicDPDA& second) const { - return first.compare(second); +template < > +struct compare < automaton::RealTimeHeightDeterministicDPDA > { + int operator ()( const automaton::RealTimeHeightDeterministicDPDA & first, const automaton::RealTimeHeightDeterministicDPDA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h index cb24b8f09b..35e5443fb0 100644 --- a/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h +++ b/alib2data/src/automaton/PDA/RealTimeHeightDeterministicNPDA.h @@ -26,30 +26,31 @@ namespace automaton { */ class RealTimeHeightDeterministicNPDA : public AutomatonBase, public BottomOfTheStackSymbolPushdownStoreAlphabet, public MultiInitialStates, public InputAlphabet { protected: - std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol>>, std::set<std::pair<State, alphabet::Symbol> > > callTransitions; - std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<State> > returnTransitions; - std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol>>, std::set<State> > localTransitions; + std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < std::pair < State, alphabet::Symbol > > > callTransitions; + std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::set < State > > returnTransitions; + std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < State > > localTransitions; + public: - explicit RealTimeHeightDeterministicNPDA(alphabet::Symbol bottomOfTheStackSymbol); + explicit RealTimeHeightDeterministicNPDA ( alphabet::Symbol bottomOfTheStackSymbol ); + + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* clone() const; - - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /* * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + virtual bool removeStackSymbol ( const alphabet::Symbol & symbol ); /** * Adds call transition defined by parameters to the automaton. @@ -58,9 +59,9 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addCallTransition(State current, std::variant<string::Epsilon, alphabet::Symbol> input, State next, alphabet::Symbol push); - bool addCallTransition(State current, State next, alphabet::Symbol push); - bool addCallTransition(State current, alphabet::Symbol input, State next, alphabet::Symbol push); + bool addCallTransition ( State current, std::variant < string::Epsilon, alphabet::Symbol > input, State next, alphabet::Symbol push ); + bool addCallTransition ( State current, State next, alphabet::Symbol push ); + bool addCallTransition ( State current, alphabet::Symbol input, State next, alphabet::Symbol push ); /** * Adds return transition defined by parameters to the automaton. @@ -69,9 +70,9 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addReturnTransition(State current, std::variant<string::Epsilon, alphabet::Symbol> input, alphabet::Symbol pop, State next); - bool addReturnTransition(State current, alphabet::Symbol pop, State next); - bool addReturnTransition(State current, alphabet::Symbol input, alphabet::Symbol pop, State next); + bool addReturnTransition ( State current, std::variant < string::Epsilon, alphabet::Symbol > input, alphabet::Symbol pop, State next ); + bool addReturnTransition ( State current, alphabet::Symbol pop, State next ); + bool addReturnTransition ( State current, alphabet::Symbol input, alphabet::Symbol pop, State next ); /** * Adds local transition defined by parameters to the automaton. @@ -80,75 +81,72 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addLocalTransition(State current, std::variant<string::Epsilon, alphabet::Symbol> input, State next); - bool addLocalTransition(State current, State next); - bool addLocalTransition(State current, alphabet::Symbol input, State next); + bool addLocalTransition ( State current, std::variant < string::Epsilon, alphabet::Symbol > input, State next ); + bool addLocalTransition ( State current, State next ); + bool addLocalTransition ( State current, alphabet::Symbol input, State next ); /** * Removes call transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeCallTransition(const State& current, const std::variant<string::Epsilon, alphabet::Symbol>& input, const State& next, const alphabet::Symbol& push); - bool removeCallTransition(const State& current, const State& next, const alphabet::Symbol& push); - bool removeCallTransition(const State& current, const alphabet::Symbol& input, const State& next, const alphabet::Symbol& push); + bool removeCallTransition ( const State & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const State & next, const alphabet::Symbol & push ); + bool removeCallTransition ( const State & current, const State & next, const alphabet::Symbol & push ); + bool removeCallTransition ( const State & current, const alphabet::Symbol & input, const State & next, const alphabet::Symbol & push ); /** * Removes return transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeReturnTransition(const State& current, const std::variant<string::Epsilon, alphabet::Symbol>& input, const alphabet::Symbol& pop, const State& next); - bool removeReturnTransition(const State& current, const alphabet::Symbol& pop, const State& next); - bool removeReturnTransition(const State& current, const alphabet::Symbol& input, const alphabet::Symbol& pop, const State& next); + bool removeReturnTransition ( const State & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const alphabet::Symbol & pop, const State & next ); + bool removeReturnTransition ( const State & current, const alphabet::Symbol & pop, const State & next ); + bool removeReturnTransition ( const State & current, const alphabet::Symbol & input, const alphabet::Symbol & pop, const State & next ); /** * Removes transition local from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeLocalTransition(const State& current, const std::variant<string::Epsilon, alphabet::Symbol>& input, const State& next); - bool removeLocalTransition(const State& current, const State& next); - bool removeLocalTransition(const State& current, const alphabet::Symbol& input, const State& next); + bool removeLocalTransition ( const State & current, const std::variant < string::Epsilon, alphabet::Symbol > & input, const State & next ); + bool removeLocalTransition ( const State & current, const State & next ); + bool removeLocalTransition ( const State & current, const alphabet::Symbol & input, const State & next ); - const std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol>>, std::set<std::pair<State, alphabet::Symbol> > >& getCallTransitions() const; + const std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < std::pair < State, alphabet::Symbol > > > & getCallTransitions ( ) const; - const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<State> >& getReturnTransitions() const; + const std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::set < State > > & getReturnTransitions ( ) const; - const std::map<std::pair<State, std::variant<string::Epsilon, alphabet::Symbol>>, std::set<State> >& getLocalTransitions() const; + const std::map < std::pair < State, std::variant < string::Epsilon, alphabet::Symbol > >, std::set < State > > & getLocalTransitions ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const RealTimeHeightDeterministicNPDA& other) const; + virtual int compare ( const RealTimeHeightDeterministicNPDA & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static RealTimeHeightDeterministicNPDA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, RealTimeHeightDeterministicNPDA& automaton); + static RealTimeHeightDeterministicNPDA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, RealTimeHeightDeterministicNPDA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::RealTimeHeightDeterministicNPDA> { - int operator()(const automaton::RealTimeHeightDeterministicNPDA& first, const automaton::RealTimeHeightDeterministicNPDA& second) const { - return first.compare(second); +template < > +struct compare < automaton::RealTimeHeightDeterministicNPDA > { + int operator ()( const automaton::RealTimeHeightDeterministicNPDA & first, const automaton::RealTimeHeightDeterministicNPDA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/PDA/SinglePopDPDA.h b/alib2data/src/automaton/PDA/SinglePopDPDA.h index ee81912b41..4f5a80440f 100644 --- a/alib2data/src/automaton/PDA/SinglePopDPDA.h +++ b/alib2data/src/automaton/PDA/SinglePopDPDA.h @@ -28,30 +28,31 @@ namespace automaton { * if $\delta (q, a, r) \neq \emptyset$, $\delta (q, a, s) \neq \emptyset$ then $r \neq s$. * if $\delta(q, a, r) \neq \emptyset$, $\delta (q, \varepsilon, s) \neq \emptyset$, then $r \neq s$. */ -class SinglePopDPDA: public AutomatonBase, public SingleInitialSymbolPushdownStoreAlphabet, public SingleInitialState, public InputAlphabet { +class SinglePopDPDA : public AutomatonBase, public SingleInitialSymbolPushdownStoreAlphabet, public SingleInitialState, public InputAlphabet { protected: - std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::pair<State, std::vector<alphabet::Symbol> > > transitions; + std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::pair < State, std::vector < alphabet::Symbol > > > transitions; + public: - explicit SinglePopDPDA(State initialState, alphabet::Symbol initialPushdownSymbol); + explicit SinglePopDPDA ( State initialState, alphabet::Symbol initialPushdownSymbol ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + virtual bool removeStackSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition to the SinglePopDPDA. @@ -59,60 +60,57 @@ public: * @throws AutomatonException when some part of the transition is not present * in the SinglePopDPDA (state, input symbol, stack symbol) or when transition already exists */ - bool addTransition(State from, std::variant<string::Epsilon, alphabet::Symbol> input, alphabet::Symbol pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, std::variant < string::Epsilon, alphabet::Symbol > input, alphabet::Symbol pop, State to, std::vector < alphabet::Symbol > push ); - bool addTransition(State from, alphabet::Symbol input, alphabet::Symbol pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, alphabet::Symbol input, alphabet::Symbol pop, State to, std::vector < alphabet::Symbol > push ); - bool addTransition(State from, alphabet::Symbol pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, alphabet::Symbol pop, State to, std::vector < alphabet::Symbol > push ); /** * Removes the transition from the SinglePopDPDA. * @param transition transition to remove * @throws AutomatonException when transition is not present in the SinglePopDPDA */ - bool removeTransition(const State& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const alphabet::Symbol& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const std::variant < string::Epsilon, alphabet::Symbol > & input, const alphabet::Symbol & pop, const State & to, const std::vector < alphabet::Symbol > & push ); - bool removeTransition(const State& from, const alphabet::Symbol& input, const alphabet::Symbol& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const alphabet::Symbol & input, const alphabet::Symbol & pop, const State & to, const std::vector < alphabet::Symbol > & push ); - bool removeTransition(const State& from, const alphabet::Symbol& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const alphabet::Symbol & pop, const State & to, const std::vector < alphabet::Symbol > & push ); /** * @return SinglePopDPDA transitions */ - const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::pair<State, std::vector<alphabet::Symbol> > >& getTransitions() const; + const std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::pair < State, std::vector < alphabet::Symbol > > > & getTransitions ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const SinglePopDPDA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const SinglePopDPDA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static SinglePopDPDA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, SinglePopDPDA& automaton); + static SinglePopDPDA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, SinglePopDPDA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::SinglePopDPDA> { - int operator()(const automaton::SinglePopDPDA& first, const automaton::SinglePopDPDA& second) const { - return first.compare(second); +template < > +struct compare < automaton::SinglePopDPDA > { + int operator ()( const automaton::SinglePopDPDA & first, const automaton::SinglePopDPDA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/PDA/SinglePopNPDA.h b/alib2data/src/automaton/PDA/SinglePopNPDA.h index 9be2fce8e4..1782b58298 100644 --- a/alib2data/src/automaton/PDA/SinglePopNPDA.h +++ b/alib2data/src/automaton/PDA/SinglePopNPDA.h @@ -24,30 +24,31 @@ namespace automaton { /** * Push Down Automaton */ -class SinglePopNPDA: public AutomatonBase, public SingleInitialSymbolPushdownStoreAlphabet, public SingleInitialState, public InputAlphabet { +class SinglePopNPDA : public AutomatonBase, public SingleInitialSymbolPushdownStoreAlphabet, public SingleInitialState, public InputAlphabet { protected: - std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<State, std::vector<alphabet::Symbol> > > > transitions; + std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::set < std::pair < State, std::vector < alphabet::Symbol > > > > transitions; + public: - explicit SinglePopNPDA(State initialState, alphabet::Symbol initialPushdownSymbol); + explicit SinglePopNPDA ( State initialState, alphabet::Symbol initialPushdownSymbol ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + virtual bool removeStackSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition to the SinglePopNPDA. @@ -55,60 +56,57 @@ public: * @throws AutomatonException when some part of the transition is not present * in the SinglePopNPDA (state, input symbol, stack symbol) or when transition already exists */ - bool addTransition(State from, std::variant<string::Epsilon, alphabet::Symbol> input, alphabet::Symbol pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, std::variant < string::Epsilon, alphabet::Symbol > input, alphabet::Symbol pop, State to, std::vector < alphabet::Symbol > push ); - bool addTransition(State from, alphabet::Symbol input, alphabet::Symbol pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, alphabet::Symbol input, alphabet::Symbol pop, State to, std::vector < alphabet::Symbol > push ); - bool addTransition(State from, alphabet::Symbol pop, State to, std::vector<alphabet::Symbol> push); + bool addTransition ( State from, alphabet::Symbol pop, State to, std::vector < alphabet::Symbol > push ); /** * Removes the transition from the SinglePopNPDA. * @param transition transition to remove * @throws AutomatonException when transition is not present in the SinglePopNPDA */ - bool removeTransition(const State& from, const std::variant<string::Epsilon, alphabet::Symbol>& input, const alphabet::Symbol& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const std::variant < string::Epsilon, alphabet::Symbol > & input, const alphabet::Symbol & pop, const State & to, const std::vector < alphabet::Symbol > & push ); - bool removeTransition(const State& from, const alphabet::Symbol& input, const alphabet::Symbol& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const alphabet::Symbol & input, const alphabet::Symbol & pop, const State & to, const std::vector < alphabet::Symbol > & push ); - bool removeTransition(const State& from, const alphabet::Symbol& pop, const State& to, const std::vector<alphabet::Symbol>& push); + bool removeTransition ( const State & from, const alphabet::Symbol & pop, const State & to, const std::vector < alphabet::Symbol > & push ); /** * @return SinglePopNPDA transitions */ - const std::map<std::tuple<State, std::variant<string::Epsilon, alphabet::Symbol>, alphabet::Symbol>, std::set<std::pair<State, std::vector<alphabet::Symbol> > > >& getTransitions() const; + const std::map < std::tuple < State, std::variant < string::Epsilon, alphabet::Symbol >, alphabet::Symbol >, std::set < std::pair < State, std::vector < alphabet::Symbol > > > > & getTransitions ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const SinglePopNPDA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const SinglePopNPDA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static SinglePopNPDA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, SinglePopNPDA& automaton); + static SinglePopNPDA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, SinglePopNPDA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::SinglePopNPDA> { - int operator()(const automaton::SinglePopNPDA& first, const automaton::SinglePopNPDA& second) const { - return first.compare(second); +template < > +struct compare < automaton::SinglePopNPDA > { + int operator ()( const automaton::SinglePopNPDA & first, const automaton::SinglePopNPDA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h b/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h index 0c5c76289f..df9285dfe9 100644 --- a/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h +++ b/alib2data/src/automaton/PDA/VisiblyPushdownDPDA.h @@ -24,30 +24,31 @@ namespace automaton { */ class VisiblyPushdownDPDA : public AutomatonBase, public CallReturnLocalInputAlphabet, public SingleInitialState, public BottomOfTheStackSymbolPushdownStoreAlphabet { protected: - std::map<std::pair<State, alphabet::Symbol>, std::pair<State, alphabet::Symbol> > callTransitions; - std::map<std::tuple<State, alphabet::Symbol, alphabet::Symbol>, State > returnTransitions; - std::map<std::pair<State, alphabet::Symbol>, State > localTransitions; + std::map < std::pair < State, alphabet::Symbol >, std::pair < State, alphabet::Symbol > > callTransitions; + std::map < std::tuple < State, alphabet::Symbol, alphabet::Symbol >, State > returnTransitions; + std::map < std::pair < State, alphabet::Symbol >, State > localTransitions; + public: - explicit VisiblyPushdownDPDA(State initialSymbol, alphabet::Symbol bottomOfTheStackSymbol); + explicit VisiblyPushdownDPDA ( State initialSymbol, alphabet::Symbol bottomOfTheStackSymbol ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /* * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + virtual bool removeStackSymbol ( const alphabet::Symbol & symbol ); /** * Adds call transition defined by parameters to the automaton. @@ -56,7 +57,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addCallTransition(State current, alphabet::Symbol input, State next, alphabet::Symbol push); + bool addCallTransition ( State current, alphabet::Symbol input, State next, alphabet::Symbol push ); /** * Adds return transition defined by parameters to the automaton. @@ -65,7 +66,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addReturnTransition(State current, alphabet::Symbol input, alphabet::Symbol pop, State next); + bool addReturnTransition ( State current, alphabet::Symbol input, alphabet::Symbol pop, State next ); /** * Adds local transition defined by parameters to the automaton. @@ -74,67 +75,64 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addLocalTransition(State current, alphabet::Symbol input, State next); + bool addLocalTransition ( State current, alphabet::Symbol input, State next ); /** * Removes call transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeCallTransition(const State& current, const alphabet::Symbol& input, const State& next, const alphabet::Symbol& push); + bool removeCallTransition ( const State & current, const alphabet::Symbol & input, const State & next, const alphabet::Symbol & push ); /** * Removes return transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeReturnTransition(const State& current, const alphabet::Symbol& input, const alphabet::Symbol& pop, const State& next); + bool removeReturnTransition ( const State & current, const alphabet::Symbol & input, const alphabet::Symbol & pop, const State & next ); /** * Removes transition local from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeLocalTransition(const State& current, const alphabet::Symbol& input, const State& next); + bool removeLocalTransition ( const State & current, const alphabet::Symbol & input, const State & next ); - const std::map<std::pair<State, alphabet::Symbol>, std::pair<State, alphabet::Symbol> >& getCallTransitions() const; + const std::map < std::pair < State, alphabet::Symbol >, std::pair < State, alphabet::Symbol > > & getCallTransitions ( ) const; - const std::map<std::tuple<State, alphabet::Symbol, alphabet::Symbol>, State>& getReturnTransitions() const; + const std::map < std::tuple < State, alphabet::Symbol, alphabet::Symbol >, State > & getReturnTransitions ( ) const; - const std::map<std::pair<State, alphabet::Symbol>, State>& getLocalTransitions() const; + const std::map < std::pair < State, alphabet::Symbol >, State > & getLocalTransitions ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const VisiblyPushdownDPDA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const VisiblyPushdownDPDA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static VisiblyPushdownDPDA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, VisiblyPushdownDPDA& automaton); + static VisiblyPushdownDPDA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, VisiblyPushdownDPDA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::VisiblyPushdownDPDA> { - int operator()(const automaton::VisiblyPushdownDPDA& first, const automaton::VisiblyPushdownDPDA& second) const { - return first.compare(second); +template < > +struct compare < automaton::VisiblyPushdownDPDA > { + int operator ()( const automaton::VisiblyPushdownDPDA & first, const automaton::VisiblyPushdownDPDA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h b/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h index 8e9f2e3c18..bba11c1613 100644 --- a/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h +++ b/alib2data/src/automaton/PDA/VisiblyPushdownNPDA.h @@ -24,30 +24,31 @@ namespace automaton { */ class VisiblyPushdownNPDA : public AutomatonBase, public BottomOfTheStackSymbolPushdownStoreAlphabet, public MultiInitialStates, public CallReturnLocalInputAlphabet { protected: - std::map<std::pair<State, alphabet::Symbol>, std::set<std::pair<State, alphabet::Symbol> > > callTransitions; - std::map<std::tuple<State, alphabet::Symbol, alphabet::Symbol>, std::set<State> > returnTransitions; - std::map<std::pair<State, alphabet::Symbol>, std::set<State> > localTransitions; + std::map < std::pair < State, alphabet::Symbol >, std::set < std::pair < State, alphabet::Symbol > > > callTransitions; + std::map < std::tuple < State, alphabet::Symbol, alphabet::Symbol >, std::set < State > > returnTransitions; + std::map < std::pair < State, alphabet::Symbol >, std::set < State > > localTransitions; + public: - explicit VisiblyPushdownNPDA(alphabet::Symbol bottomOfTheStackSymbol); + explicit VisiblyPushdownNPDA ( alphabet::Symbol bottomOfTheStackSymbol ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /* * @copydoc Automaton::removeStackSymbol(const Symbol&) */ - virtual bool removeStackSymbol(const alphabet::Symbol& symbol); + virtual bool removeStackSymbol ( const alphabet::Symbol & symbol ); /** * Adds call transition defined by parameters to the automaton. @@ -56,7 +57,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addCallTransition(State current, alphabet::Symbol input, State next, alphabet::Symbol push); + bool addCallTransition ( State current, alphabet::Symbol input, State next, alphabet::Symbol push ); /** * Adds return transition defined by parameters to the automaton. @@ -65,7 +66,7 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addReturnTransition(State current, alphabet::Symbol input, alphabet::Symbol pop, State next); + bool addReturnTransition ( State current, alphabet::Symbol input, alphabet::Symbol pop, State next ); /** * Adds local transition defined by parameters to the automaton. @@ -74,67 +75,64 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addLocalTransition(State current, alphabet::Symbol input, State next); + bool addLocalTransition ( State current, alphabet::Symbol input, State next ); /** * Removes call transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeCallTransition(const State& current, const alphabet::Symbol& input, const State& next, const alphabet::Symbol& push); + bool removeCallTransition ( const State & current, const alphabet::Symbol & input, const State & next, const alphabet::Symbol & push ); /** * Removes return transition from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeReturnTransition(const State& current, const alphabet::Symbol& input, const alphabet::Symbol& pop, const State& next); + bool removeReturnTransition ( const State & current, const alphabet::Symbol & input, const alphabet::Symbol & pop, const State & next ); /** * Removes transition local from the automaton. * @param transition transition to remove * @throws AutomatonException when transition doesn't exists. */ - bool removeLocalTransition(const State& current, const alphabet::Symbol& input, const State& next); + bool removeLocalTransition ( const State & current, const alphabet::Symbol & input, const State & next ); - const std::map<std::pair<State, alphabet::Symbol>, std::set<std::pair<State, alphabet::Symbol> > >& getCallTransitions() const; + const std::map < std::pair < State, alphabet::Symbol >, std::set < std::pair < State, alphabet::Symbol > > > & getCallTransitions ( ) const; - const std::map<std::tuple<State, alphabet::Symbol, alphabet::Symbol>, std::set<State> >& getReturnTransitions() const; + const std::map < std::tuple < State, alphabet::Symbol, alphabet::Symbol >, std::set < State > > & getReturnTransitions ( ) const; - const std::map<std::pair<State, alphabet::Symbol>, std::set<State> >& getLocalTransitions() const; + const std::map < std::pair < State, alphabet::Symbol >, std::set < State > > & getLocalTransitions ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const VisiblyPushdownNPDA& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const VisiblyPushdownNPDA & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static VisiblyPushdownNPDA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, VisiblyPushdownNPDA& automaton); + static VisiblyPushdownNPDA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, VisiblyPushdownNPDA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::VisiblyPushdownNPDA> { - int operator()(const automaton::VisiblyPushdownNPDA& first, const automaton::VisiblyPushdownNPDA& second) const { - return first.compare(second); +template < > +struct compare < automaton::VisiblyPushdownNPDA > { + int operator ()( const automaton::VisiblyPushdownNPDA & first, const automaton::VisiblyPushdownNPDA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/TA/DFTA.h b/alib2data/src/automaton/TA/DFTA.h index 1e798a9ad8..62263e1f18 100644 --- a/alib2data/src/automaton/TA/DFTA.h +++ b/alib2data/src/automaton/TA/DFTA.h @@ -12,7 +12,8 @@ #include <vector> #include "../AutomatonBase.h" #include "../common/States.h" -//#include "../common/InputAlphabet.h" + +// #include "../common/InputAlphabet.h" #include "../../alphabet/RankedSymbol.h" namespace automaton { @@ -23,25 +24,26 @@ namespace automaton { */ class DFTA : public AutomatonBase, public States { protected: - std::set<alphabet::RankedSymbol> inputAlphabet; - std::map<std::pair<alphabet::RankedSymbol, std::vector<State> >, State > transitions; + std::set < alphabet::RankedSymbol > inputAlphabet; + std::map < std::pair < alphabet::RankedSymbol, std::vector < State > >, State > transitions; + public: - explicit DFTA(); + explicit DFTA ( ); - virtual AutomatonBase* clone() const; - - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * clone ( ) const; + + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::RankedSymbol& symbol); - + virtual bool removeInputSymbol ( const alphabet::RankedSymbol & symbol ); + /** * Adds transition defined by parameters to the automaton. * @param current current symbol in node @@ -49,61 +51,58 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(const alphabet::RankedSymbol & current, const std::vector<State> & children, const State & next); + bool addTransition ( const alphabet::RankedSymbol & current, const std::vector < State > & children, const State & next ); /** * Removes transition from the automaton. * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const alphabet::RankedSymbol symbol, const std::vector<State> & states, const State & next); + bool removeTransition ( const alphabet::RankedSymbol symbol, const std::vector < State > & states, const State & next ); /** * @return automaton transitions */ - const std::map<std::pair<alphabet::RankedSymbol, std::vector<State> >, State > & getTransitions() const {return transitions;} + const std::map < std::pair < alphabet::RankedSymbol, std::vector < State > >, State > & getTransitions ( ) const { return transitions; } - std::set<State> getTransitionRightSide(const alphabet::RankedSymbol symbol, const std::vector<State> & states); + std::set < State > getTransitionRightSide ( const alphabet::RankedSymbol symbol, const std::vector < State > & states ); - unsigned transitionsSize() const; + unsigned transitionsSize ( ) const; - const std::set<alphabet::RankedSymbol> & getInputAlphabet() const {return inputAlphabet;} + const std::set < alphabet::RankedSymbol > & getInputAlphabet ( ) const { return inputAlphabet; } - void setInputSymbols(const std::set<alphabet::RankedSymbol> & symbols) {inputAlphabet = symbols;} + void setInputSymbols ( const std::set < alphabet::RankedSymbol > & symbols ) { inputAlphabet = symbols; } - void addInputSymbol(const alphabet::RankedSymbol & symbol) {inputAlphabet.insert(symbol);} + void addInputSymbol ( const alphabet::RankedSymbol & symbol ) { inputAlphabet.insert ( symbol ); } - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const DFTA& other) const; + virtual int compare ( const DFTA & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual operator std::string ( ) const; const static std::string XML_TAG_NAME; - static DFTA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, DFTA& automaton); + static DFTA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, DFTA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::DFTA> { - int operator()(const automaton::DFTA& first, const automaton::DFTA& second) const { - return first.compare(second); +template < > +struct compare < automaton::DFTA > { + int operator ()( const automaton::DFTA & first, const automaton::DFTA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/TA/NFTA.h b/alib2data/src/automaton/TA/NFTA.h index 8dc1649931..92b26daee4 100644 --- a/alib2data/src/automaton/TA/NFTA.h +++ b/alib2data/src/automaton/TA/NFTA.h @@ -12,7 +12,8 @@ #include <vector> #include "../AutomatonBase.h" #include "../common/States.h" -//#include "../common/InputAlphabet.h" + +// #include "../common/InputAlphabet.h" #include "../../alphabet/RankedSymbol.h" #include "DFTA.h" @@ -25,26 +26,27 @@ namespace automaton { */ class NFTA : public AutomatonBase, public States { protected: - std::set<alphabet::RankedSymbol> inputAlphabet; - std::map<std::pair<alphabet::RankedSymbol, std::vector<State> >, std::set<State> > transitions; + std::set < alphabet::RankedSymbol > inputAlphabet; + std::map < std::pair < alphabet::RankedSymbol, std::vector < State > >, std::set < State > > transitions; + public: - explicit NFTA(); - explicit NFTA(const DFTA& other); + explicit NFTA ( ); + explicit NFTA ( const DFTA & other ); - virtual AutomatonBase* clone() const; - - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * clone ( ) const; + + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * @copydoc Automaton::removeInputSymbol(const Symbol&) */ - virtual bool removeInputSymbol(const alphabet::RankedSymbol& symbol); - + virtual bool removeInputSymbol ( const alphabet::RankedSymbol & symbol ); + /** * Adds transition defined by parameters to the automaton. * @param current current symbol in node @@ -52,20 +54,20 @@ public: * @param next next state * @throws AutomatonException when transition already exists or when transition contains state or symbol not present in the automaton */ - bool addTransition(const alphabet::RankedSymbol & current, const std::vector<State> & children, const State & next); + bool addTransition ( const alphabet::RankedSymbol & current, const std::vector < State > & children, const State & next ); /** * Removes transition from the automaton. * @throws AutomatonException when transition doesn't exists. */ - bool removeTransition(const alphabet::RankedSymbol symbol, const std::vector<State> & states, const State & next); + bool removeTransition ( const alphabet::RankedSymbol symbol, const std::vector < State > & states, const State & next ); /** * @return automaton transitions */ - const std::map<std::pair<alphabet::RankedSymbol, std::vector<State> >, std::set<State> > & getTransitions() const {return transitions;} + const std::map < std::pair < alphabet::RankedSymbol, std::vector < State > >, std::set < State > > & getTransitions ( ) const { return transitions; } - std::set<State> getTransitionRightSide(const alphabet::RankedSymbol symbol, const std::vector<State> & states); + std::set < State > getTransitionRightSide ( const alphabet::RankedSymbol symbol, const std::vector < State > & states ); /** * Determines whether NFTA is deterministic. @@ -74,48 +76,45 @@ public: * \li \c size of transition function \delta (from state, input symbol) \leq 1 * @return true when automaton is deterministic, false otherwise */ - bool isDeterministic() const; + bool isDeterministic ( ) const; - unsigned transitionsSize() const; + unsigned transitionsSize ( ) const; - const std::set<alphabet::RankedSymbol> & getInputAlphabet() const {return inputAlphabet;} + const std::set < alphabet::RankedSymbol > & getInputAlphabet ( ) const { return inputAlphabet; } - void setInputSymbols(const std::set<alphabet::RankedSymbol> & symbols) {inputAlphabet = symbols;} + void setInputSymbols ( const std::set < alphabet::RankedSymbol > & symbols ) { inputAlphabet = symbols; } - void addInputSymbol(const alphabet::RankedSymbol & symbol) {inputAlphabet.insert(symbol);} + void addInputSymbol ( const alphabet::RankedSymbol & symbol ) { inputAlphabet.insert ( symbol ); } - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const NFTA& other) const; + virtual int compare ( const NFTA & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual operator std::string ( ) const; const static std::string XML_TAG_NAME; - static NFTA parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, NFTA& automaton); + static NFTA parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, NFTA & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::NFTA> { - int operator()(const automaton::NFTA& first, const automaton::NFTA& second) const { - return first.compare(second); +template < > +struct compare < automaton::NFTA > { + int operator ()( const automaton::NFTA & first, const automaton::NFTA & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/automaton/TM/OneTapeDTM.h b/alib2data/src/automaton/TM/OneTapeDTM.h index a48e2bedb5..d8a05e8719 100644 --- a/alib2data/src/automaton/TM/OneTapeDTM.h +++ b/alib2data/src/automaton/TM/OneTapeDTM.h @@ -24,26 +24,26 @@ namespace automaton { */ class OneTapeDTM : public AutomatonBase, public SingleInitialState, public BlankSymbolInputTapeAlphabet { protected: - std::map<std::pair<State, alphabet::Symbol>, std::tuple<State, alphabet::Symbol, Shift> > transitions; + std::map < std::pair < State, alphabet::Symbol >, std::tuple < State, alphabet::Symbol, Shift > > transitions; public: - explicit OneTapeDTM(State initialState, alphabet::Symbol blank); + explicit OneTapeDTM ( State initialState, alphabet::Symbol blank ); - virtual AutomatonBase* clone() const; + virtual AutomatonBase * clone ( ) const; - virtual AutomatonBase* plunder() &&; + virtual AutomatonBase * plunder ( ) &&; /** * @copydoc Automaton::removeState(const State&) */ - virtual bool removeState(const State& state); + virtual bool removeState ( const State & state ); /** * Removes input symbol from the input alphabet. * @param symbol Symbol to remove * @throws AutomatonException when symbol is part of the transition */ - virtual bool removeInputSymbol(const alphabet::Symbol& symbol); + virtual bool removeInputSymbol ( const alphabet::Symbol & symbol ); /** * Removes symbol from the tape alphabet. @@ -51,7 +51,7 @@ public: * @throw AutomatonException when Symbol is not present in the tape alphabet, * when it is used in transition or when it is present in input alphabet */ - virtual bool removeTapeSymbol(const alphabet::Symbol& symbol); + virtual bool removeTapeSymbol ( const alphabet::Symbol & symbol ); /** * Adds transition to the automaton. @@ -59,52 +59,49 @@ public: * @throws AutomatonException when some part of the transition is not present * in the TM (state, tape symbol) or when transition already exists */ - bool addTransition(State from, alphabet::Symbol input, State to, alphabet::Symbol output, Shift shift); + bool addTransition ( State from, alphabet::Symbol input, State to, alphabet::Symbol output, Shift shift ); /** * Removes the transition from the TM. * @param transition transition to remove * @throws AutomatonException when transition is not present in the TM */ - bool removeTransition(const State& from, const alphabet::Symbol& input, const State& to, const alphabet::Symbol& output, const Shift& shift); + bool removeTransition ( const State & from, const alphabet::Symbol & input, const State & to, const alphabet::Symbol & output, const Shift & shift ); /** * @return TM transitions */ - const std::map<std::pair<State, alphabet::Symbol>, std::tuple<State, alphabet::Symbol, Shift> >& getTransitions() const; + const std::map < std::pair < State, alphabet::Symbol >, std::tuple < State, alphabet::Symbol, Shift > > & getTransitions ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const OneTapeDTM& other) const; + virtual int compare ( const OneTapeDTM & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static OneTapeDTM parse(std::deque<sax::Token>::iterator& input); - static void parseTransition(std::deque<sax::Token>::iterator& input, OneTapeDTM& automaton); + static OneTapeDTM parse ( std::deque < sax::Token >::iterator & input ); + static void parseTransition ( std::deque < sax::Token >::iterator & input, OneTapeDTM & automaton ); - void compose(std::deque<sax::Token>& out) const; - void composeTransitions(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeTransitions ( std::deque < sax::Token > & out ) const; }; } /* namespace automaton */ namespace std { -template<> -struct compare<automaton::OneTapeDTM> { - int operator()(const automaton::OneTapeDTM& first, const automaton::OneTapeDTM& second) const { - return first.compare(second); +template < > +struct compare < automaton::OneTapeDTM > { + int operator ()( const automaton::OneTapeDTM & first, const automaton::OneTapeDTM & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/common/base.hpp b/alib2data/src/common/base.hpp index ddc6bd6284..8ab1304e04 100644 --- a/alib2data/src/common/base.hpp +++ b/alib2data/src/common/base.hpp @@ -9,6 +9,7 @@ #define BASE_H_ #include <typeinfo> +#include <typeindex> #include <ostream> #include <stdexcept> @@ -19,8 +20,6 @@ class base { public: virtual ~base ( ) noexcept { } - virtual long long selfTypeId ( ) const = 0; - virtual T * clone ( ) const = 0; virtual T * plunder ( ) && = 0; @@ -51,13 +50,12 @@ public: virtual int compare ( const T & other ) const = 0; - template < typename R > - // TODO what if someone want to control the ordering? + template < typename R > static int compare ( const R & first, const T & second ) { - if ( first.selfTypeId ( ) < second.selfTypeId ( ) ) + if ( std::type_index ( typeid ( first ) ) < std::type_index ( typeid ( second ) ) ) return -1; - else if ( first.selfTypeId ( ) > second.selfTypeId ( ) ) + else if ( std::type_index ( typeid ( first ) ) > std::type_index ( typeid ( second ) ) ) return 1; else return first.compare ( ( const R & ) second ); @@ -71,12 +69,6 @@ public: virtual void operator >>( std::ostream & ) const = 0; virtual explicit operator std::string ( ) const = 0; - - template < typename R > - static long long typeId ( const R & ) { - return ( long long ) & base::typeId < R >; - } - }; } /* namespace alib */ diff --git a/alib2data/src/common/multipleDispatch.hpp b/alib2data/src/common/multipleDispatch.hpp index 5b34f5b554..a283962525 100644 --- a/alib2data/src/common/multipleDispatch.hpp +++ b/alib2data/src/common/multipleDispatch.hpp @@ -17,301 +17,309 @@ namespace std { -template<class ReturnType, class FirstParameterType> +template < class ReturnType, class FirstParameterType > class SingleDispatch { public: class RegistratorWrapperBase { public: - virtual ReturnType eval(const FirstParameterType&) = 0; - + virtual ReturnType eval ( const FirstParameterType & ) = 0; }; private: - typedef SingleDispatch<ReturnType, FirstParameterType> SelfType; + typedef SingleDispatch < ReturnType, FirstParameterType > SelfType; - std::map<long long, typename SelfType::RegistratorWrapperBase*> registeredFunctions; + std::map < std::type_index, typename SelfType::RegistratorWrapperBase * > registeredFunctions; public: - template<class RealReturnType, class RealFirstParameterType> + template < class RealReturnType, class RealFirstParameterType > class RegistratorWrapper : public RegistratorWrapperBase { - std::function<RealReturnType(const RealFirstParameterType&)> callback; + std::function < RealReturnType ( const RealFirstParameterType & ) > callback; public: - ReturnType eval(const FirstParameterType& first) { - return ReturnType(callback((const RealFirstParameterType&) first)); + ReturnType eval ( const FirstParameterType & first ) { + return ReturnType ( callback ( ( const RealFirstParameterType & ) first ) ); } - RegistratorWrapper(SelfType& pool, RealReturnType(*callback)(const RealFirstParameterType&)) : callback(callback) { - int a = 0; - if(! pool.registeredFunctions.insert(std::make_pair(RealFirstParameterType::typeId((const RealFirstParameterType&) a), this)).second ) - throw std::logic_error("Callback alreary registered."); + RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( const RealFirstParameterType & ) ) : callback ( callback ) { + if ( !pool.registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) + throw std::logic_error ( "Callback alreary registered." ); } + }; - ReturnType dispatch(const FirstParameterType& first) { - typename std::map<long long, RegistratorWrapperBase*>::iterator callback = registeredFunctions.find(first.selfTypeId()); - if(callback == registeredFunctions.end()) throw std::bad_function_call(); - return callback->second->eval(first); + ReturnType dispatch ( const FirstParameterType & first ) { + typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); + + if ( callback == registeredFunctions.end ( ) ) throw std::bad_function_call ( ); + + return callback->second->eval ( first ); } }; -template<class ReturnType, class StaticParamType, class FirstParameterType> +template < class ReturnType, class StaticParamType, class FirstParameterType > class SingleDispatchFirstStaticParam { public: class RegistratorWrapperBase { public: - virtual ReturnType eval(StaticParamType, const FirstParameterType&) = 0; - + virtual ReturnType eval ( StaticParamType, const FirstParameterType & ) = 0; }; private: - typedef SingleDispatchFirstStaticParam<ReturnType, StaticParamType, FirstParameterType> SelfType; + typedef SingleDispatchFirstStaticParam < ReturnType, StaticParamType, FirstParameterType > SelfType; - std::map<long long, typename SelfType::RegistratorWrapperBase*> registeredFunctions; + std::map < std::type_index, typename SelfType::RegistratorWrapperBase * > registeredFunctions; public: - template<class RealReturnType, class RealFirstParameterType> + template < class RealReturnType, class RealFirstParameterType > class RegistratorWrapper : public RegistratorWrapperBase { - std::function<RealReturnType(StaticParamType, const RealFirstParameterType&)> callback; + std::function < RealReturnType ( StaticParamType, const RealFirstParameterType & ) > callback; public: - ReturnType eval(StaticParamType res, const FirstParameterType& first) { - return ReturnType(callback(res, (const RealFirstParameterType&) first)); + ReturnType eval ( StaticParamType res, const FirstParameterType & first ) { + return ReturnType ( callback ( res, ( const RealFirstParameterType & ) first ) ); } - RegistratorWrapper(SelfType& pool, RealReturnType(*callback)(StaticParamType, const RealFirstParameterType&)) : callback(callback) { - int a = 0; - if(! pool.registeredFunctions.insert(std::make_pair(RealFirstParameterType::typeId((const RealFirstParameterType&) a), this)).second ) - throw std::logic_error("Callback alreary registered."); + RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( StaticParamType, const RealFirstParameterType & ) ) : callback ( callback ) { + if ( !pool.registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) + throw std::logic_error ( "Callback alreary registered." ); } + }; - ReturnType dispatch(StaticParamType res, const FirstParameterType& first) { - typename std::map<long long, RegistratorWrapperBase*>::iterator callback = registeredFunctions.find(first.selfTypeId()); - if(callback == registeredFunctions.end()) throw std::bad_function_call(); - return callback->second->eval(res, first); + ReturnType dispatch ( StaticParamType res, const FirstParameterType & first ) { + typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); + + if ( callback == registeredFunctions.end ( ) ) throw std::bad_function_call ( ); + + return callback->second->eval ( res, first ); } }; -template<class ReturnType, class FirstParameterType, class StaticParamType> +template < class ReturnType, class FirstParameterType, class StaticParamType > class SingleDispatchLastStaticParam { public: class RegistratorWrapperBase { public: - virtual ReturnType eval(const FirstParameterType&, StaticParamType) = 0; - + virtual ReturnType eval ( const FirstParameterType &, StaticParamType ) = 0; }; private: - typedef SingleDispatchLastStaticParam<ReturnType, FirstParameterType, StaticParamType> SelfType; + typedef SingleDispatchLastStaticParam < ReturnType, FirstParameterType, StaticParamType > SelfType; - std::map<long long, typename SelfType::RegistratorWrapperBase*> registeredFunctions; + std::map < std::type_index, typename SelfType::RegistratorWrapperBase * > registeredFunctions; public: - template<class RealReturnType, class RealFirstParameterType> + template < class RealReturnType, class RealFirstParameterType > class RegistratorWrapper : public RegistratorWrapperBase { - std::function<RealReturnType(const RealFirstParameterType&, StaticParamType)> callback; + std::function < RealReturnType ( const RealFirstParameterType &, StaticParamType ) > callback; public: - ReturnType eval(const FirstParameterType& first, StaticParamType res) { - return ReturnType(callback((const RealFirstParameterType&) first, res)); + ReturnType eval ( const FirstParameterType & first, StaticParamType res ) { + return ReturnType ( callback ( ( const RealFirstParameterType & ) first, res ) ); } - RegistratorWrapper(SelfType& pool, RealReturnType(*callback)(const RealFirstParameterType&, StaticParamType)) : callback(callback) { - int a = 0; - if(! pool.registeredFunctions.insert(std::make_pair(RealFirstParameterType::typeId((const RealFirstParameterType&) a), this)). second) - throw std::logic_error("Callback alreary registered."); + RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( const RealFirstParameterType &, StaticParamType ) ) : callback ( callback ) { + if ( !pool.registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) + throw std::logic_error ( "Callback alreary registered." ); } + }; - ReturnType dispatch(const FirstParameterType& first, StaticParamType res) { - typename std::map<long long, RegistratorWrapperBase*>::iterator callback = registeredFunctions.find(first.selfTypeId()); - if(callback == registeredFunctions.end()) throw std::bad_function_call(); - return callback->second->eval(first, res); + ReturnType dispatch ( const FirstParameterType & first, StaticParamType res ) { + typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); + + if ( callback == registeredFunctions.end ( ) ) throw std::bad_function_call ( ); + + return callback->second->eval ( first, res ); } }; -template<class ReturnType, class FirstParameterType, class FirstStaticParamType, class SecondStaticParamType> +template < class ReturnType, class FirstParameterType, class FirstStaticParamType, class SecondStaticParamType > class SingleDispatch2LastStaticParams { public: class RegistratorWrapperBase { public: - virtual ReturnType eval(const FirstParameterType&, FirstStaticParamType, SecondStaticParamType) = 0; - + virtual ReturnType eval ( const FirstParameterType &, FirstStaticParamType, SecondStaticParamType ) = 0; }; private: - typedef SingleDispatch2LastStaticParams<ReturnType, FirstParameterType, FirstStaticParamType, SecondStaticParamType> SelfType; + typedef SingleDispatch2LastStaticParams < ReturnType, FirstParameterType, FirstStaticParamType, SecondStaticParamType > SelfType; - std::map<long long, typename SelfType::RegistratorWrapperBase*> registeredFunctions; + std::map < std::type_index, typename SelfType::RegistratorWrapperBase * > registeredFunctions; public: - template<class RealReturnType, class RealFirstParameterType> + template < class RealReturnType, class RealFirstParameterType > class RegistratorWrapper : public RegistratorWrapperBase { - std::function<RealReturnType(const RealFirstParameterType&, FirstStaticParamType, SecondStaticParamType)> callback; + std::function < RealReturnType ( const RealFirstParameterType &, FirstStaticParamType, SecondStaticParamType ) > callback; public: - ReturnType eval(const FirstParameterType& first, FirstStaticParamType res, SecondStaticParamType res2) { - return ReturnType(callback((const RealFirstParameterType&) first, res, res2)); + ReturnType eval ( const FirstParameterType & first, FirstStaticParamType res, SecondStaticParamType res2 ) { + return ReturnType ( callback ( ( const RealFirstParameterType & ) first, res, res2 ) ); } - RegistratorWrapper(SelfType& pool, RealReturnType(*callback)(const RealFirstParameterType&, FirstStaticParamType, SecondStaticParamType)) : callback(callback) { - int a = 0; - if(! pool.registeredFunctions.insert(std::make_pair(RealFirstParameterType::typeId((const RealFirstParameterType&) a), this)). second) - throw std::logic_error("Callback alreary registered."); + RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( const RealFirstParameterType &, FirstStaticParamType, SecondStaticParamType ) ) : callback ( callback ) { + if ( !pool.registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) + throw std::logic_error ( "Callback alreary registered." ); } + }; - ReturnType dispatch(const FirstParameterType& first, FirstStaticParamType res, SecondStaticParamType res2) { - typename std::map<long long, RegistratorWrapperBase*>::iterator callback = registeredFunctions.find(first.selfTypeId()); - if(callback == registeredFunctions.end()) throw std::bad_function_call(); - return callback->second->eval(first, res, res2); + ReturnType dispatch ( const FirstParameterType & first, FirstStaticParamType res, SecondStaticParamType res2 ) { + typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); + + if ( callback == registeredFunctions.end ( ) ) throw std::bad_function_call ( ); + + return callback->second->eval ( first, res, res2 ); } }; // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -template<class ReturnType, class ParametersType> +template < class ReturnType, class ParametersType > class PromotingDoubleDispatch { public: class RegistratorWrapperBase { public: - virtual ReturnType eval(bool firstAttempt, const ParametersType&, const ParametersType&) = 0; - virtual bool available(bool firstAttempt, long long first, long long second) = 0; + virtual ReturnType eval ( bool firstAttempt, const ParametersType &, const ParametersType & ) = 0; + virtual bool available ( bool firstAttempt, std::type_index first, std::type_index second ) = 0; }; private: - typedef PromotingDoubleDispatch<ReturnType, ParametersType> SelfType; + typedef PromotingDoubleDispatch < ReturnType, ParametersType > SelfType; - std::map<long long, typename SelfType::RegistratorWrapperBase*> registeredFunctions; + std::map < std::type_index, typename SelfType::RegistratorWrapperBase * > registeredFunctions; public: - template<class RealReturnType, class RealParametersType> + template < class RealReturnType, class RealParametersType > class RegistratorWrapper : public RegistratorWrapperBase { - std::function<RealReturnType(const RealParametersType&, const RealParametersType&)> callback; + std::function < RealReturnType ( const RealParametersType &, const RealParametersType & ) > callback; public: - ReturnType eval(bool firstAttempt, const ParametersType& first, const ParametersType& second) { - if(first.selfTypeId() == second.selfTypeId()) - return ReturnType(callback((const RealParametersType&) first, (const RealParametersType&) second)); + ReturnType eval ( bool firstAttempt, const ParametersType & first, const ParametersType & second ) { + if ( std::type_index ( typeid ( first ) ) == std::type_index ( typeid ( second ) ) ) + return ReturnType ( callback ( ( const RealParametersType & ) first, ( const RealParametersType & ) second ) ); - if(firstAttempt) { - alib::Object casted = alib::castApi::getCastPool(first.selfTypeId()).cast(second); - return ReturnType(callback((const RealParametersType&) first, (const RealParametersType&) casted.getData())); + if ( firstAttempt ) { + alib::Object casted = alib::castApi::getCastPool ( std::type_index ( typeid ( first ) ) ).cast ( second ); + return ReturnType ( callback ( ( const RealParametersType & ) first, ( const RealParametersType & ) casted.getData ( ) ) ); } else { - alib::Object casted = alib::castApi::getCastPool(second.selfTypeId()).cast(first); - return ReturnType(callback((const RealParametersType&) casted.getData(), (const RealParametersType&) second)); + alib::Object casted = alib::castApi::getCastPool ( std::type_index ( typeid ( second ) ) ).cast ( first ); + return ReturnType ( callback ( ( const RealParametersType & ) casted.getData ( ), ( const RealParametersType & ) second ) ); } } - bool available(bool firstAttempt, long long first, long long second) { - if(first == second) return true; - - if(firstAttempt) - return alib::castApi::castAvailable(first, second); + bool available ( bool firstAttempt, std::type_index first, std::type_index second ) { + if ( first == second ) return true; + + if ( firstAttempt ) + return alib::castApi::castAvailable ( first, second ); else - return alib::castApi::castAvailable(second, first); + return alib::castApi::castAvailable ( second, first ); } - RegistratorWrapper(SelfType& pool, RealReturnType(*callback)(const RealParametersType&, const RealParametersType&)) : callback(callback) { - int a = 0; - if(! pool.registeredFunctions.insert(std::make_pair(RealParametersType::typeId((const RealParametersType&) a), this)).second ) - throw std::logic_error("Callback alreary registered."); + RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( const RealParametersType &, const RealParametersType & ) ) : callback ( callback ) { + if ( !pool.registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealParametersType ) ), this ) ).second ) + throw std::logic_error ( "Callback alreary registered." ); } + }; - ReturnType dispatch(const ParametersType& first, const ParametersType& second) { - typename std::map<long long, RegistratorWrapperBase*>::iterator callback = registeredFunctions.find(first.selfTypeId()); - if(callback != registeredFunctions.end() && callback->second->available(true, first.selfTypeId(), second.selfTypeId())) return callback->second->eval(true, first, second); + ReturnType dispatch ( const ParametersType & first, const ParametersType & second ) { + typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); - callback = registeredFunctions.find(second.selfTypeId()); - if(callback != registeredFunctions.end() && callback->second->available(false, first.selfTypeId(), second.selfTypeId())) return callback->second->eval(false, first, second); + if ( ( callback != registeredFunctions.end ( ) ) && callback->second->available ( true, std::type_index ( typeid ( first ) ), std::type_index ( typeid ( second ) ) ) ) return callback->second->eval ( true, first, second ); - throw std::bad_function_call(); + callback = registeredFunctions.find ( std::type_index ( typeid ( second ) ) ); + + if ( ( callback != registeredFunctions.end ( ) ) && callback->second->available ( false, std::type_index ( typeid ( first ) ), std::type_index ( typeid ( second ) ) ) ) return callback->second->eval ( false, first, second ); + + throw std::bad_function_call ( ); } }; // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -template<class ReturnType, class FirstParameterType, class SecondParameterType> +template < class ReturnType, class FirstParameterType, class SecondParameterType > class DoubleDispatch { public: class RegistratorWrapperBase { public: - virtual ReturnType eval(const FirstParameterType&, const SecondParameterType&) = 0; - + virtual ReturnType eval ( const FirstParameterType &, const SecondParameterType & ) = 0; }; private: - typedef DoubleDispatch<ReturnType, FirstParameterType, SecondParameterType> SelfType; + typedef DoubleDispatch < ReturnType, FirstParameterType, SecondParameterType > SelfType; - std::map<std::pair<long long, long long>, typename SelfType::RegistratorWrapperBase*> registeredFunctions; + std::map < std::pair < std::type_index, std::type_index >, typename SelfType::RegistratorWrapperBase * > registeredFunctions; public: - template<class RealReturnType, class RealFirstParameterType, class RealSecondParameterType> + template < class RealReturnType, class RealFirstParameterType, class RealSecondParameterType > class RegistratorWrapper : public RegistratorWrapperBase { - std::function<RealReturnType(const RealFirstParameterType&, const RealSecondParameterType&)> callback; + std::function < RealReturnType ( const RealFirstParameterType &, const RealSecondParameterType & ) > callback; public: - ReturnType eval(const FirstParameterType& first, const SecondParameterType& second) { - return ReturnType(callback((const RealFirstParameterType&) first, (const RealSecondParameterType&) second)); + ReturnType eval ( const FirstParameterType & first, const SecondParameterType & second ) { + return ReturnType ( callback ( ( const RealFirstParameterType & ) first, ( const RealSecondParameterType & ) second ) ); } - RegistratorWrapper(SelfType& pool, RealReturnType(*callback)(const RealFirstParameterType&, const RealSecondParameterType&)) : callback(callback) { - int a = 0; - if(! pool.registeredFunctions.insert(std::make_pair(std::make_pair(RealFirstParameterType::typeId((const RealFirstParameterType&) a), RealSecondParameterType::typeId((const RealSecondParameterType&) a)), this)).second ) - throw std::logic_error("Callback alreary registered."); + RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( const RealFirstParameterType &, const RealSecondParameterType & ) ) : callback ( callback ) { + if ( !pool.registeredFunctions.insert ( std::make_pair ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), std::type_index ( typeid ( RealSecondParameterType ) ) ), this ) ).second ) + throw std::logic_error ( "Callback alreary registered." ); } + }; - ReturnType dispatch(const FirstParameterType& first, const SecondParameterType& second) { - typename std::map<std::pair<long long, long long>, RegistratorWrapperBase*>::iterator callback = registeredFunctions.find(std::make_pair(first.selfTypeId(), second.selfTypeId())); - if(callback == registeredFunctions.end()) throw std::bad_function_call(); - return callback->second->eval(first, second); + ReturnType dispatch ( const FirstParameterType & first, const SecondParameterType & second ) { + typename std::map < std::pair < std::type_index, std::type_index >, RegistratorWrapperBase * >::iterator callback = registeredFunctions.find ( std::make_pair ( std::type_index ( typeid ( first ) ), std::type_index ( typeid ( second ) ) ) ); + + if ( callback == registeredFunctions.end ( ) ) throw std::bad_function_call ( ); + + return callback->second->eval ( first, second ); } }; -template<class ReturnType, class StaticParamType, class FirstParameterType, class SecondParameterType> +template < class ReturnType, class StaticParamType, class FirstParameterType, class SecondParameterType > class DoubleDispatchFirstStaticParam { public: class RegistratorWrapperBase { public: - virtual ReturnType eval(StaticParamType, const FirstParameterType&, const SecondParameterType&) = 0; - + virtual ReturnType eval ( StaticParamType, const FirstParameterType &, const SecondParameterType & ) = 0; }; private: - typedef DoubleDispatchFirstStaticParam<ReturnType, StaticParamType, FirstParameterType, SecondParameterType> SelfType; + typedef DoubleDispatchFirstStaticParam < ReturnType, StaticParamType, FirstParameterType, SecondParameterType > SelfType; - std::map<std::pair<long long, long long>, typename SelfType::RegistratorWrapperBase*> registeredFunctions; + std::map < std::pair < std::type_index, std::type_index >, typename SelfType::RegistratorWrapperBase * > registeredFunctions; public: - template<class RealReturnType, class RealFirstParameterType, class RealSecondParameterType> + template < class RealReturnType, class RealFirstParameterType, class RealSecondParameterType > class RegistratorWrapper : public RegistratorWrapperBase { - std::function<RealReturnType(StaticParamType, const RealFirstParameterType&, const RealSecondParameterType&)> callback; + std::function < RealReturnType ( StaticParamType, const RealFirstParameterType &, const RealSecondParameterType & ) > callback; public: - ReturnType eval(StaticParamType res, const FirstParameterType& first, const SecondParameterType& second) { - return ReturnType(callback(res, (const RealFirstParameterType&) first, (const SecondParameterType&) second)); + ReturnType eval ( StaticParamType res, const FirstParameterType & first, const SecondParameterType & second ) { + return ReturnType ( callback ( res, ( const RealFirstParameterType & ) first, ( const SecondParameterType & ) second ) ); } - RegistratorWrapper(SelfType& pool, RealReturnType(*callback)(StaticParamType, const RealFirstParameterType&, const RealSecondParameterType&)) : callback(callback) { - int a = 0; - if(! pool.registeredFunctions.insert(std::make_pair(std::make_pair(RealFirstParameterType::typeId((const RealFirstParameterType&) a), RealSecondParameterType::typeId((const RealSecondParameterType&) a)), this)).second ) - throw std::logic_error("Callback alreary registered."); + RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( StaticParamType, const RealFirstParameterType &, const RealSecondParameterType & ) ) : callback ( callback ) { + if ( !pool.registeredFunctions.insert ( std::make_pair ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), std::type_index ( typeid ( RealSecondParameterType ) ) ), this ) ).second ) + throw std::logic_error ( "Callback alreary registered." ); } + }; - ReturnType dispatch(StaticParamType res, const FirstParameterType& first, const SecondParameterType& second) { - typename std::map<std::pair<long long, long long>, RegistratorWrapperBase*>::iterator callback = registeredFunctions.find(std::make_pair(first.selfTypeId(), first.selfTypeId())); - if(callback == registeredFunctions.end()) throw std::bad_function_call(); - return callback->second->eval(res, first, second); + ReturnType dispatch ( StaticParamType res, const FirstParameterType & first, const SecondParameterType & second ) { + typename std::map < std::pair < std::type_index, std::type_index >, RegistratorWrapperBase * >::iterator callback = registeredFunctions.find ( std::make_pair ( std::type_index ( typeid ( first ) ), std::type_index ( typeid ( first ) ) ) ); + + if ( callback == registeredFunctions.end ( ) ) throw std::bad_function_call ( ); + + return callback->second->eval ( res, first, second ); } }; diff --git a/alib2data/src/container/ObjectsMap.h b/alib2data/src/container/ObjectsMap.h index 85dbb16e3a..bc647b3077 100644 --- a/alib2data/src/container/ObjectsMap.h +++ b/alib2data/src/container/ObjectsMap.h @@ -23,99 +23,95 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -class ObjectsMap : public std::map<alib::Object, alib::Object>, public ContainerBase { +class ObjectsMap : public std::map < alib::Object, alib::Object >, public ContainerBase { public: - explicit ObjectsMap(std::map<alib::Object, alib::Object>); - explicit ObjectsMap(); + explicit ObjectsMap ( std::map < alib::Object, alib::Object > ); + explicit ObjectsMap ( ); - virtual ContainerBase* clone() const; - - virtual ContainerBase* plunder() &&; + virtual ContainerBase * clone ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); - } + virtual ContainerBase * plunder ( ) &&; - virtual int compare(const ObjectsMap& other) const; + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); + } - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const ObjectsMap & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static ObjectsMap parse(std::deque<sax::Token>::iterator& input); - template<class T, class R> - static std::map<T, R> parseRaw(std::deque<sax::Token>::iterator& input); + static ObjectsMap parse ( std::deque < sax::Token >::iterator & input ); + template < class T, class R > + static std::map < T, R > parseRaw ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; - template<class T, class R> - static void compose(std::deque<sax::Token>& out, const std::map<T, R>& input); + void compose ( std::deque < sax::Token > & out ) const; + template < class T, class R > + static void compose ( std::deque < sax::Token > & out, const std::map < T, R > & input ); }; -template<class T, class R> -std::map<T, R> ObjectsMap::parseRaw(std::deque<sax::Token>::iterator& input) { - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, ObjectsMap::XML_TAG_NAME); +template < class T, class R > +std::map < T, R > ObjectsMap::parseRaw ( std::deque < sax::Token >::iterator & input ) { + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, ObjectsMap::XML_TAG_NAME ); - std::map<T, R> map; - while(sax::FromXMLParserHelper::isTokenType(input, sax::Token::TokenType::START_ELEMENT)) { - map.insert(alib::xmlApi<std::pair<T, R>>::parse(input)); - } + std::map < T, R > map; - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, ObjectsMap::XML_TAG_NAME); + while ( sax::FromXMLParserHelper::isTokenType ( input, sax::Token::TokenType::START_ELEMENT ) ) + map.insert ( alib::xmlApi < std::pair < T, R > >::parse ( input ) ); + + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, ObjectsMap::XML_TAG_NAME ); return map; } -template<class T, class R> -void ObjectsMap::compose(std::deque<sax::Token>& out, const std::map<T, R>& input) { - out.emplace_back(ObjectsMap::XML_TAG_NAME, sax::Token::TokenType::START_ELEMENT); +template < class T, class R > +void ObjectsMap::compose ( std::deque < sax::Token > & out, const std::map < T, R > & input ) { + out.emplace_back ( ObjectsMap::XML_TAG_NAME, sax::Token::TokenType::START_ELEMENT ); - for(const std::pair<T, R>& item : input) { - alib::xmlApi<std::pair<T, R>>::compose(out, item); - } + for ( const std::pair < T, R > & item : input ) + alib::xmlApi < std::pair < T, R > >::compose ( out, item ); - out.emplace_back(ObjectsMap::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT); + out.emplace_back ( ObjectsMap::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT ); } } /* namespace container */ namespace std { -template<> -struct compare<container::ObjectsMap> { - int operator()(const container::ObjectsMap& first, const container::ObjectsMap& second) const { - return first.compare(second); +template < > +struct compare < container::ObjectsMap > { + int operator ()( const container::ObjectsMap & first, const container::ObjectsMap & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ namespace alib { -template<typename T, typename R> -struct xmlApi<std::map<T, R>> { - static std::map<T, R> parse(std::deque<sax::Token>::iterator& input); - static bool first(const std::deque<sax::Token>::const_iterator& input); - static void compose(std::deque<sax::Token>& output, const std::map<T, R>& data); +template < typename T, typename R > +struct xmlApi < std::map < T, R > > { + static std::map < T, R > parse ( std::deque < sax::Token >::iterator & input ); + static bool first ( const std::deque < sax::Token >::const_iterator & input ); + static void compose ( std::deque < sax::Token > & output, const std::map < T, R > & data ); }; -template<typename T, typename R> -std::map<T, R> xmlApi<std::map<T, R>>::parse(std::deque<sax::Token>::iterator& input) { - return container::ObjectsMap::parseRaw<T, R>(input); +template < typename T, typename R > +std::map < T, R > xmlApi < std::map < T, R > >::parse ( std::deque < sax::Token >::iterator & input ) { + return container::ObjectsMap::parseRaw < T, R > ( input ); } -template<typename T, typename R> -bool xmlApi<std::map<T, R>>::first(const std::deque<sax::Token>::const_iterator& input) { - return sax::FromXMLParserHelper::isToken(input, sax::Token::TokenType::START_ELEMENT, container::ObjectsMap::XML_TAG_NAME); +template < typename T, typename R > +bool xmlApi < std::map < T, R > >::first ( const std::deque < sax::Token >::const_iterator & input ) { + return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, container::ObjectsMap::XML_TAG_NAME ); } -template<typename T, typename R> -void xmlApi<std::map<T, R>>::compose(std::deque<sax::Token>& output, const std::map<T, R>& input) { - return container::ObjectsMap::compose<T, R>(output, input); +template < typename T, typename R > +void xmlApi < std::map < T, R > >::compose ( std::deque < sax::Token > & output, const std::map < T, R > & input ) { + return container::ObjectsMap::compose < T, R > ( output, input ); } } /* namespace alib */ diff --git a/alib2data/src/container/ObjectsPair.h b/alib2data/src/container/ObjectsPair.h index d6eef9a0c2..2b879d2c98 100644 --- a/alib2data/src/container/ObjectsPair.h +++ b/alib2data/src/container/ObjectsPair.h @@ -22,96 +22,94 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -class ObjectsPair : public std::pair<alib::Object, alib::Object>, public ContainerBase { +class ObjectsPair : public std::pair < alib::Object, alib::Object >, public ContainerBase { public: - explicit ObjectsPair(alib::Object first, alib::Object second); - explicit ObjectsPair(std::pair<alib::Object, alib::Object>); + explicit ObjectsPair ( alib::Object first, alib::Object second ); + explicit ObjectsPair ( std::pair < alib::Object, alib::Object > ); - virtual ContainerBase* clone() const; + virtual ContainerBase * clone ( ) const; - virtual ContainerBase* plunder() &&; + virtual ContainerBase * plunder ( ) &&; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const ObjectsPair& other) const; + virtual int compare ( const ObjectsPair & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static ObjectsPair parse(std::deque<sax::Token>::iterator& input); - template<class T, class R> - static std::pair<T, R> parseRaw(std::deque<sax::Token>::iterator& input); + static ObjectsPair parse ( std::deque < sax::Token >::iterator & input ); + template < class T, class R > + static std::pair < T, R > parseRaw ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; - template<class T, class R> - static void compose(std::deque<sax::Token>& out, const std::pair<T, R>& input); + void compose ( std::deque < sax::Token > & out ) const; + template < class T, class R > + static void compose ( std::deque < sax::Token > & out, const std::pair < T, R > & input ); }; -template<class T, class R> -std::pair<T, R> ObjectsPair::parseRaw(std::deque<sax::Token>::iterator& input) { - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, ObjectsPair::XML_TAG_NAME); +template < class T, class R > +std::pair < T, R > ObjectsPair::parseRaw ( std::deque < sax::Token >::iterator & input ) { + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, ObjectsPair::XML_TAG_NAME ); - T first = alib::xmlApi<T>::parse(input); - R second = alib::xmlApi<R>::parse(input); + T first = alib::xmlApi < T >::parse ( input ); + R second = alib::xmlApi < R >::parse ( input ); - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, ObjectsPair::XML_TAG_NAME); - return std::make_pair(std::move(first), std::move(second)); + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, ObjectsPair::XML_TAG_NAME ); + + return std::make_pair ( std::move ( first ), std::move ( second ) ); } -template<class T, class R> -void ObjectsPair::compose(std::deque<sax::Token>& out, const std::pair<T, R>& input) { - out.emplace_back(ObjectsPair::XML_TAG_NAME, sax::Token::TokenType::START_ELEMENT); +template < class T, class R > +void ObjectsPair::compose ( std::deque < sax::Token > & out, const std::pair < T, R > & input ) { + out.emplace_back ( ObjectsPair::XML_TAG_NAME, sax::Token::TokenType::START_ELEMENT ); - alib::xmlApi<T>::compose(out, input.first); - alib::xmlApi<R>::compose(out, input.second); + alib::xmlApi < T >::compose ( out, input.first ); + alib::xmlApi < R >::compose ( out, input.second ); - out.emplace_back(ObjectsPair::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT); + out.emplace_back ( ObjectsPair::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT ); } } /* namespace container */ namespace std { -template<> -struct compare<container::ObjectsPair> { - int operator()(const container::ObjectsPair& first, const container::ObjectsPair& second) const { - return first.compare(second); +template < > +struct compare < container::ObjectsPair > { + int operator ()( const container::ObjectsPair & first, const container::ObjectsPair & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ namespace alib { -template<typename T, typename R> -struct xmlApi<std::pair<T, R>> { - static std::pair<T, R> parse(std::deque<sax::Token>::iterator& input); - static bool first(const std::deque<sax::Token>::const_iterator& input); - static void compose(std::deque<sax::Token>& output, const std::pair<T, R>& data); +template < typename T, typename R > +struct xmlApi < std::pair < T, R > > { + static std::pair < T, R > parse ( std::deque < sax::Token >::iterator & input ); + static bool first ( const std::deque < sax::Token >::const_iterator & input ); + static void compose ( std::deque < sax::Token > & output, const std::pair < T, R > & data ); }; -template<typename T, typename R> -std::pair<T, R> xmlApi<std::pair<T, R>>::parse(std::deque<sax::Token>::iterator& input) { - return container::ObjectsPair::parseRaw<T, R>(input); +template < typename T, typename R > +std::pair < T, R > xmlApi < std::pair < T, R > >::parse ( std::deque < sax::Token >::iterator & input ) { + return container::ObjectsPair::parseRaw < T, R > ( input ); } -template<typename T, typename R> -bool xmlApi<std::pair<T, R>>::first(const std::deque<sax::Token>::const_iterator& input) { - return sax::FromXMLParserHelper::isToken(input, sax::Token::TokenType::START_ELEMENT, container::ObjectsPair::XML_TAG_NAME); +template < typename T, typename R > +bool xmlApi < std::pair < T, R > >::first ( const std::deque < sax::Token >::const_iterator & input ) { + return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, container::ObjectsPair::XML_TAG_NAME ); } -template<typename T, typename R> -void xmlApi<std::pair<T, R>>::compose(std::deque<sax::Token>& output, const std::pair<T, R>& input) { - return container::ObjectsPair::compose<T, R>(output, input); +template < typename T, typename R > +void xmlApi < std::pair < T, R > >::compose ( std::deque < sax::Token > & output, const std::pair < T, R > & input ) { + return container::ObjectsPair::compose < T, R > ( output, input ); } } /* namespace alib */ diff --git a/alib2data/src/container/ObjectsSet.h b/alib2data/src/container/ObjectsSet.h index b9f813742a..0487478e9d 100644 --- a/alib2data/src/container/ObjectsSet.h +++ b/alib2data/src/container/ObjectsSet.h @@ -22,99 +22,95 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -class ObjectsSet : public std::set<alib::Object>, public ContainerBase { +class ObjectsSet : public std::set < alib::Object >, public ContainerBase { public: - explicit ObjectsSet(std::set<alib::Object>); - explicit ObjectsSet(); + explicit ObjectsSet ( std::set < alib::Object > ); + explicit ObjectsSet ( ); - virtual ContainerBase* clone() const; - - virtual ContainerBase* plunder() &&; + virtual ContainerBase * clone ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); - } + virtual ContainerBase * plunder ( ) &&; - virtual int compare(const ObjectsSet& other) const; + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); + } - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const ObjectsSet & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static ObjectsSet parse(std::deque<sax::Token>::iterator& input); - template<class T> - static std::set<T> parseRaw(std::deque<sax::Token>::iterator& input); + static ObjectsSet parse ( std::deque < sax::Token >::iterator & input ); + template < class T > + static std::set < T > parseRaw ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; - template<class T> - static void compose(std::deque<sax::Token>& out, const std::set<T>& input); + void compose ( std::deque < sax::Token > & out ) const; + template < class T > + static void compose ( std::deque < sax::Token > & out, const std::set < T > & input ); }; -template<class T> -std::set<T> ObjectsSet::parseRaw(std::deque<sax::Token>::iterator& input) { - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, ObjectsSet::XML_TAG_NAME); +template < class T > +std::set < T > ObjectsSet::parseRaw ( std::deque < sax::Token >::iterator & input ) { + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, ObjectsSet::XML_TAG_NAME ); - std::set<T> set; - while(sax::FromXMLParserHelper::isTokenType(input, sax::Token::TokenType::START_ELEMENT)) { - set.insert(alib::xmlApi<T>::parse(input)); - } + std::set < T > set; - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, ObjectsSet::XML_TAG_NAME); + while ( sax::FromXMLParserHelper::isTokenType ( input, sax::Token::TokenType::START_ELEMENT ) ) + set.insert ( alib::xmlApi < T >::parse ( input ) ); + + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, ObjectsSet::XML_TAG_NAME ); return set; } -template<class T> -void ObjectsSet::compose(std::deque<sax::Token>& out, const std::set<T>& input) { - out.emplace_back(ObjectsSet::XML_TAG_NAME, sax::Token::TokenType::START_ELEMENT); +template < class T > +void ObjectsSet::compose ( std::deque < sax::Token > & out, const std::set < T > & input ) { + out.emplace_back ( ObjectsSet::XML_TAG_NAME, sax::Token::TokenType::START_ELEMENT ); - for(const T& item : input) { - alib::xmlApi<T>::compose(out, item); - } + for ( const T & item : input ) + alib::xmlApi < T >::compose ( out, item ); - out.emplace_back(ObjectsSet::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT); + out.emplace_back ( ObjectsSet::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT ); } } /* namespace container */ namespace std { -template<> -struct compare<container::ObjectsSet> { - int operator()(const container::ObjectsSet& first, const container::ObjectsSet& second) const { - return first.compare(second); +template < > +struct compare < container::ObjectsSet > { + int operator ()( const container::ObjectsSet & first, const container::ObjectsSet & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ namespace alib { -template<typename T> -struct xmlApi<std::set<T>> { - static std::set<T> parse(std::deque<sax::Token>::iterator& input); - static bool first(const std::deque<sax::Token>::const_iterator& input); - static void compose(std::deque<sax::Token>& output, const std::set<T>& data); +template < typename T > +struct xmlApi < std::set < T > > { + static std::set < T > parse ( std::deque < sax::Token >::iterator & input ); + static bool first ( const std::deque < sax::Token >::const_iterator & input ); + static void compose ( std::deque < sax::Token > & output, const std::set < T > & data ); }; -template<typename T> -std::set<T> xmlApi<std::set<T>>::parse(std::deque<sax::Token>::iterator& input) { - return container::ObjectsSet::parseRaw<T>(input); +template < typename T > +std::set < T > xmlApi < std::set < T > >::parse ( std::deque < sax::Token >::iterator & input ) { + return container::ObjectsSet::parseRaw < T > ( input ); } -template<typename T> -bool xmlApi<std::set<T>>::first(const std::deque<sax::Token>::const_iterator& input) { - return sax::FromXMLParserHelper::isToken(input, sax::Token::TokenType::START_ELEMENT, container::ObjectsSet::XML_TAG_NAME); +template < typename T > +bool xmlApi < std::set < T > >::first ( const std::deque < sax::Token >::const_iterator & input ) { + return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, container::ObjectsSet::XML_TAG_NAME ); } -template<typename T> -void xmlApi<std::set<T>>::compose(std::deque<sax::Token>& output, const std::set<T>& input) { - return container::ObjectsSet::compose<T>(output, input); +template < typename T > +void xmlApi < std::set < T > >::compose ( std::deque < sax::Token > & output, const std::set < T > & input ) { + return container::ObjectsSet::compose < T > ( output, input ); } } /* namespace alib */ diff --git a/alib2data/src/container/ObjectsVector.h b/alib2data/src/container/ObjectsVector.h index 3420a04644..97d4782c8e 100644 --- a/alib2data/src/container/ObjectsVector.h +++ b/alib2data/src/container/ObjectsVector.h @@ -22,99 +22,95 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -class ObjectsVector : public std::vector<alib::Object>, public ContainerBase { +class ObjectsVector : public std::vector < alib::Object >, public ContainerBase { public: - explicit ObjectsVector(std::vector<alib::Object>); - explicit ObjectsVector(); + explicit ObjectsVector ( std::vector < alib::Object > ); + explicit ObjectsVector ( ); - virtual ContainerBase* clone() const; - - virtual ContainerBase* plunder() &&; + virtual ContainerBase * clone ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); - } + virtual ContainerBase * plunder ( ) &&; - virtual int compare(const ObjectsVector& other) const; + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); + } - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const ObjectsVector & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static ObjectsVector parse(std::deque<sax::Token>::iterator& input); - template<class T> - static std::vector<T> parseRaw(std::deque<sax::Token>::iterator& input); + static ObjectsVector parse ( std::deque < sax::Token >::iterator & input ); + template < class T > + static std::vector < T > parseRaw ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; - template<class T> - static void compose(std::deque<sax::Token>& out, const std::vector<T>& input); + void compose ( std::deque < sax::Token > & out ) const; + template < class T > + static void compose ( std::deque < sax::Token > & out, const std::vector < T > & input ); }; -template<class T> -std::vector<T> ObjectsVector::parseRaw(std::deque<sax::Token>::iterator& input) { - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, ObjectsVector::XML_TAG_NAME); +template < class T > +std::vector < T > ObjectsVector::parseRaw ( std::deque < sax::Token >::iterator & input ) { + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, ObjectsVector::XML_TAG_NAME ); - std::vector<T> vector; - while(sax::FromXMLParserHelper::isTokenType(input, sax::Token::TokenType::START_ELEMENT)) { - vector.push_back(alib::xmlApi<T>::parse(input)); - } + std::vector < T > vector; - sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, ObjectsVector::XML_TAG_NAME); + while ( sax::FromXMLParserHelper::isTokenType ( input, sax::Token::TokenType::START_ELEMENT ) ) + vector.push_back ( alib::xmlApi < T >::parse ( input ) ); + + sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, ObjectsVector::XML_TAG_NAME ); return vector; } -template<class T> -void ObjectsVector::compose(std::deque<sax::Token>& out, const std::vector<T>& input) { - out.emplace_back(ObjectsVector::XML_TAG_NAME, sax::Token::TokenType::START_ELEMENT); +template < class T > +void ObjectsVector::compose ( std::deque < sax::Token > & out, const std::vector < T > & input ) { + out.emplace_back ( ObjectsVector::XML_TAG_NAME, sax::Token::TokenType::START_ELEMENT ); - for(const T& item : input) { - alib::xmlApi<T>::compose(out, item); - } + for ( const T & item : input ) + alib::xmlApi < T >::compose ( out, item ); - out.emplace_back(ObjectsVector::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT); + out.emplace_back ( ObjectsVector::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT ); } } /* namespace container */ namespace std { -template<> -struct compare<container::ObjectsVector> { - int operator()(const container::ObjectsVector& first, const container::ObjectsVector& second) const { - return first.compare(second); +template < > +struct compare < container::ObjectsVector > { + int operator ()( const container::ObjectsVector & first, const container::ObjectsVector & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ namespace alib { -template<typename T> -struct xmlApi<std::vector<T>> { - static std::vector<T> parse(std::deque<sax::Token>::iterator& input); - static bool first(const std::deque<sax::Token>::const_iterator& input); - static void compose(std::deque<sax::Token>& output, const std::vector<T>& data); +template < typename T > +struct xmlApi < std::vector < T > > { + static std::vector < T > parse ( std::deque < sax::Token >::iterator & input ); + static bool first ( const std::deque < sax::Token >::const_iterator & input ); + static void compose ( std::deque < sax::Token > & output, const std::vector < T > & data ); }; -template<typename T> -std::vector<T> xmlApi<std::vector<T>>::parse(std::deque<sax::Token>::iterator& input) { - return container::ObjectsVector::parseRaw<T>(input); +template < typename T > +std::vector < T > xmlApi < std::vector < T > >::parse ( std::deque < sax::Token >::iterator & input ) { + return container::ObjectsVector::parseRaw < T > ( input ); } -template<typename T> -bool xmlApi<std::vector<T>>::first(const std::deque<sax::Token>::const_iterator& input) { - return sax::FromXMLParserHelper::isToken(input, sax::Token::TokenType::START_ELEMENT, container::ObjectsVector::XML_TAG_NAME); +template < typename T > +bool xmlApi < std::vector < T > >::first ( const std::deque < sax::Token >::const_iterator & input ) { + return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, container::ObjectsVector::XML_TAG_NAME ); } -template<typename T> -void xmlApi<std::vector<T>>::compose(std::deque<sax::Token>& output, const std::vector<T>& input) { - return container::ObjectsVector::compose<T>(output, input); +template < typename T > +void xmlApi < std::vector < T > >::compose ( std::deque < sax::Token > & output, const std::vector < T > & input ) { + return container::ObjectsVector::compose < T > ( output, input ); } } /* namespace alib */ diff --git a/alib2data/src/exception/AlibException.h b/alib2data/src/exception/AlibException.h index 3f17e24135..611fbf1747 100644 --- a/alib2data/src/exception/AlibException.h +++ b/alib2data/src/exception/AlibException.h @@ -36,9 +36,9 @@ public: virtual ~AlibException ( ) noexcept; - virtual alib::ObjectBase* clone() const; - - virtual alib::ObjectBase* plunder() &&; + virtual alib::ObjectBase * clone ( ) const; + + virtual alib::ObjectBase * plunder ( ) &&; /** * @return reason why the exception occured @@ -55,36 +55,33 @@ public: */ const std::string & getBacktrace ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const AlibException& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const AlibException & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static AlibException parse(std::deque<sax::Token>::iterator& input); + static AlibException parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace exception */ namespace std { -template<> -struct compare<::exception::AlibException> { - int operator()(const ::exception::AlibException& first, const ::exception::AlibException& second) const { - return first.compare(second); +template < > +struct compare < ::exception::AlibException > { + int operator ()( const::exception::AlibException & first, const::exception::AlibException & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/ContextFree/CFG.h b/alib2data/src/grammar/ContextFree/CFG.h index a638b22444..955c3e3dae 100644 --- a/alib2data/src/grammar/ContextFree/CFG.h +++ b/alib2data/src/grammar/ContextFree/CFG.h @@ -19,65 +19,62 @@ namespace grammar { * Context free grammar. Type 2 in Chomsky hierarchy. Produces context free language. */ class CFG : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> rules; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > rules; public: - explicit CFG(alphabet::Symbol initialSymbol); + explicit CFG ( alphabet::Symbol initialSymbol ); - explicit CFG(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit CFG ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - const std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> & getRules() const; + const std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & getRules ( ) const; - bool removeRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool addRawRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRawRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> getRawRules() const; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > getRawRules ( ) const; - bool removeRawRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRawRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const CFG& other) const; + virtual int compare ( const CFG & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static CFG parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, CFG& grammar); + static CFG parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, CFG & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::CFG> { - int operator()(const grammar::CFG& first, const grammar::CFG& second) const { - return first.compare(second); +template < > +struct compare < grammar::CFG > { + int operator ()( const grammar::CFG & first, const grammar::CFG & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/ContextFree/CNF.h b/alib2data/src/grammar/ContextFree/CNF.h index e2344bd081..d93a5dbaff 100644 --- a/alib2data/src/grammar/ContextFree/CNF.h +++ b/alib2data/src/grammar/ContextFree/CNF.h @@ -20,73 +20,70 @@ namespace grammar { * Context free grammar in chomsky normal form. Type 2 in Chomsky hierarchy. Produces context free languages. */ class CNF : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>> rules; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > > > rules; bool generatesEpsilon; public: - explicit CNF(alphabet::Symbol initialSymbol); + explicit CNF ( alphabet::Symbol initialSymbol ); - explicit CNF(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit CNF ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(alphabet::Symbol leftHandSide, std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>> rightHandSide); - bool addRule(alphabet::Symbol leftHandSide, alphabet::Symbol rightHandSide); - bool addRule(alphabet::Symbol leftHandSide, std::pair<alphabet::Symbol, alphabet::Symbol> rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > rightHandSide ); + bool addRule ( alphabet::Symbol leftHandSide, alphabet::Symbol rightHandSide ); + bool addRule ( alphabet::Symbol leftHandSide, std::pair < alphabet::Symbol, alphabet::Symbol > rightHandSide ); - const std::map<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>> & getRules() const; + const std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > > > & getRules ( ) const; - bool removeRule(const alphabet::Symbol& leftHandSide, const std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>& rightHandSide); - bool removeRule(const alphabet::Symbol& leftHandSide, const alphabet::Symbol& rightHandSide); - bool removeRule(const alphabet::Symbol& leftHandSide, const std::pair<alphabet::Symbol, alphabet::Symbol>& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > & rightHandSide ); + bool removeRule ( const alphabet::Symbol & leftHandSide, const alphabet::Symbol & rightHandSide ); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::pair < alphabet::Symbol, alphabet::Symbol > & rightHandSide ); - bool addRawRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRawRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> getRawRules() const; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > getRawRules ( ) const; - bool removeRawRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRawRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - void setGeneratesEpsilon(bool genEps); - bool getGeneratesEpsilon() const; + void setGeneratesEpsilon ( bool genEps ); + bool getGeneratesEpsilon ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const CNF& other) const; + virtual int compare ( const CNF & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static CNF parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, CNF& grammar); + static CNF parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, CNF & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::CNF> { - int operator()(const grammar::CNF& first, const grammar::CNF& second) const { - return first.compare(second); +template < > +struct compare < grammar::CNF > { + int operator ()( const grammar::CNF & first, const grammar::CNF & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h b/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h index b868a0dd87..2afbe8cfb2 100644 --- a/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h +++ b/alib2data/src/grammar/ContextFree/EpsilonFreeCFG.h @@ -19,69 +19,66 @@ namespace grammar { * Epsilon free context free grammar. Type 2 in Chomsky hierarchy. Produces context free languages. */ class EpsilonFreeCFG : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> rules; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > rules; bool generatesEpsilon; public: - explicit EpsilonFreeCFG(alphabet::Symbol initialSymbol); + explicit EpsilonFreeCFG ( alphabet::Symbol initialSymbol ); - explicit EpsilonFreeCFG(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit EpsilonFreeCFG ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - const std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> & getRules() const; + const std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & getRules ( ) const; - bool removeRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool addRawRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRawRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> getRawRules() const; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > getRawRules ( ) const; - bool removeRawRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRawRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - void setGeneratesEpsilon(bool genEps); - bool getGeneratesEpsilon() const; + void setGeneratesEpsilon ( bool genEps ); + bool getGeneratesEpsilon ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const EpsilonFreeCFG& other) const; + virtual int compare ( const EpsilonFreeCFG & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static EpsilonFreeCFG parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, EpsilonFreeCFG& grammar); + static EpsilonFreeCFG parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, EpsilonFreeCFG & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::EpsilonFreeCFG> { - int operator()(const grammar::EpsilonFreeCFG& first, const grammar::EpsilonFreeCFG& second) const { - return first.compare(second); +template < > +struct compare < grammar::EpsilonFreeCFG > { + int operator ()( const grammar::EpsilonFreeCFG & first, const grammar::EpsilonFreeCFG & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/ContextFree/GNF.h b/alib2data/src/grammar/ContextFree/GNF.h index ca190d077e..9d2cd6f624 100644 --- a/alib2data/src/grammar/ContextFree/GNF.h +++ b/alib2data/src/grammar/ContextFree/GNF.h @@ -19,69 +19,67 @@ namespace grammar { * Context free grammar in greibach normal form. Type 2 in Chomsky hierarchy. Produces context free languages. */ class GNF : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<alphabet::Symbol, std::set<std::pair<alphabet::Symbol, std::vector<alphabet::Symbol> >> > rules; + std::map < alphabet::Symbol, std::set < std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > > > rules; bool generatesEpsilon; + public: - explicit GNF(alphabet::Symbol initialSymbol); + explicit GNF ( alphabet::Symbol initialSymbol ); - explicit GNF(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit GNF ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(alphabet::Symbol leftHandSide, std::pair<alphabet::Symbol, std::vector<alphabet::Symbol> > rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > rightHandSide ); - const std::map<alphabet::Symbol, std::set<std::pair<alphabet::Symbol, std::vector<alphabet::Symbol> >> > & getRules() const; + const std::map < alphabet::Symbol, std::set < std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > > > & getRules ( ) const; - bool removeRule(const alphabet::Symbol& leftHandSide, const std::pair<alphabet::Symbol, std::vector<alphabet::Symbol> >& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > & rightHandSide ); - bool addRawRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRawRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> getRawRules() const; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > getRawRules ( ) const; - bool removeRawRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRawRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - void setGeneratesEpsilon(bool genEps); + void setGeneratesEpsilon ( bool genEps ); - bool getGeneratesEpsilon() const; + bool getGeneratesEpsilon ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const GNF& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const GNF & other ) const; - virtual explicit operator std::string () const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static GNF parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, GNF& grammar); + static GNF parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, GNF & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::GNF> { - int operator()(const grammar::GNF& first, const grammar::GNF& second) const { - return first.compare(second); +template < > +struct compare < grammar::GNF > { + int operator ()( const grammar::GNF & first, const grammar::GNF & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/ContextFree/LG.h b/alib2data/src/grammar/ContextFree/LG.h index 395c94026c..c18393883a 100644 --- a/alib2data/src/grammar/ContextFree/LG.h +++ b/alib2data/src/grammar/ContextFree/LG.h @@ -21,68 +21,66 @@ namespace grammar { * Linear grammar in chomsky normal form. Type 3 in Chomsky hierarchy. Produces regular languages. */ class LG : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<alphabet::Symbol, std::set<std::variant<std::vector<alphabet::Symbol>, std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>> >> > rules; + std::map < alphabet::Symbol, std::set < std::variant < std::vector < alphabet::Symbol >, std::tuple < std::vector < alphabet::Symbol >, alphabet::Symbol, std::vector < alphabet::Symbol > > > > > rules; + public: - explicit LG(alphabet::Symbol initialSymbol); + explicit LG ( alphabet::Symbol initialSymbol ); - explicit LG(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit LG ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(alphabet::Symbol leftHandSide, std::variant<std::vector<alphabet::Symbol>, std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>> > rightHandSide); - bool addRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); - bool addRule(alphabet::Symbol leftHandSide, std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>> rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, std::variant < std::vector < alphabet::Symbol >, std::tuple < std::vector < alphabet::Symbol >, alphabet::Symbol, std::vector < alphabet::Symbol > > > rightHandSide ); + bool addRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); + bool addRule ( alphabet::Symbol leftHandSide, std::tuple < std::vector < alphabet::Symbol >, alphabet::Symbol, std::vector < alphabet::Symbol > > rightHandSide ); - const std::map<alphabet::Symbol, std::set<std::variant<std::vector<alphabet::Symbol>, std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>> >> > & getRules() const; + const std::map < alphabet::Symbol, std::set < std::variant < std::vector < alphabet::Symbol >, std::tuple < std::vector < alphabet::Symbol >, alphabet::Symbol, std::vector < alphabet::Symbol > > > > > & getRules ( ) const; - bool removeRule(const alphabet::Symbol& leftHandSide, const std::variant<std::vector<alphabet::Symbol>, std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>> >& rightHandSide); - bool removeRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); - bool removeRule(const alphabet::Symbol& leftHandSide, const std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::variant < std::vector < alphabet::Symbol >, std::tuple < std::vector < alphabet::Symbol >, alphabet::Symbol, std::vector < alphabet::Symbol > > > & rightHandSide ); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::tuple < std::vector < alphabet::Symbol >, alphabet::Symbol, std::vector < alphabet::Symbol > > & rightHandSide ); - bool addRawRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRawRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> getRawRules() const; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > getRawRules ( ) const; - bool removeRawRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRawRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const LG& other) const; - - virtual void operator>>(std::ostream& os) const; + virtual int compare ( const LG & other ) const; - virtual explicit operator std::string () const; + virtual void operator >>( std::ostream & os ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static LG parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, LG& grammar); + static LG parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, LG & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::LG> { - int operator()(const grammar::LG& first, const grammar::LG& second) const { - return first.compare(second); +template < > +struct compare < grammar::LG > { + int operator ()( const grammar::LG & first, const grammar::LG & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/ContextSensitive/CSG.h b/alib2data/src/grammar/ContextSensitive/CSG.h index b0c85e09e0..48572908f7 100644 --- a/alib2data/src/grammar/ContextSensitive/CSG.h +++ b/alib2data/src/grammar/ContextSensitive/CSG.h @@ -19,63 +19,60 @@ namespace grammar { * Epsilon free context free grammar. Type 2 in Chomsky hierarchy. Produces context free languages. */ class CSG : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>, std::set<std::vector<alphabet::Symbol>>> rules; + std::map < std::tuple < std::vector < alphabet::Symbol >, alphabet::Symbol, std::vector < alphabet::Symbol > >, std::set < std::vector < alphabet::Symbol > > > rules; bool generatesEpsilon; public: - explicit CSG(alphabet::Symbol initialSymbol); + explicit CSG ( alphabet::Symbol initialSymbol ); - explicit CSG(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit CSG ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(std::vector<alphabet::Symbol> lContext, alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rContext, std::vector<alphabet::Symbol> rightHandSide); + bool addRule ( std::vector < alphabet::Symbol > lContext, alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rContext, std::vector < alphabet::Symbol > rightHandSide ); - const std::map<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>, std::set<std::vector<alphabet::Symbol>>> & getRules() const; + const std::map < std::tuple < std::vector < alphabet::Symbol >, alphabet::Symbol, std::vector < alphabet::Symbol > >, std::set < std::vector < alphabet::Symbol > > > & getRules ( ) const; - bool removeRule(const std::vector<alphabet::Symbol>& lContext, const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rContext, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRule ( const std::vector < alphabet::Symbol > & lContext, const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rContext, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - void setGeneratesEpsilon(bool genEps); - bool getGeneratesEpsilon() const; + void setGeneratesEpsilon ( bool genEps ); + bool getGeneratesEpsilon ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const CSG& other) const; + virtual int compare ( const CSG & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static CSG parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, CSG& grammar); + static CSG parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, CSG & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::CSG> { - int operator()(const grammar::CSG& first, const grammar::CSG& second) const { - return first.compare(second); +template < > +struct compare < grammar::CSG > { + int operator ()( const grammar::CSG & first, const grammar::CSG & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h b/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h index c868985553..3f5f49bb85 100644 --- a/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h +++ b/alib2data/src/grammar/ContextSensitive/NonContractingGrammar.h @@ -19,63 +19,60 @@ namespace grammar { * Non contracting grammar. Type 1 in Chomsky hierarchy. Produces context sensitive language. */ class NonContractingGrammar : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>> rules; + std::map < std::vector < alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > rules; bool generatesEpsilon; public: - explicit NonContractingGrammar(alphabet::Symbol initialSymbol); + explicit NonContractingGrammar ( alphabet::Symbol initialSymbol ); - explicit NonContractingGrammar(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit NonContractingGrammar ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(std::vector<alphabet::Symbol> leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRule ( std::vector < alphabet::Symbol > leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - const std::map<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>> & getRules() const; + const std::map < std::vector < alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & getRules ( ) const; - bool removeRule(const std::vector<alphabet::Symbol>& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRule ( const std::vector < alphabet::Symbol > & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - void setGeneratesEpsilon(bool genEps); - bool getGeneratesEpsilon() const; + void setGeneratesEpsilon ( bool genEps ); + bool getGeneratesEpsilon ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const NonContractingGrammar& other) const; + virtual int compare ( const NonContractingGrammar & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static NonContractingGrammar parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, NonContractingGrammar& grammar); + static NonContractingGrammar parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, NonContractingGrammar & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::NonContractingGrammar> { - int operator()(const grammar::NonContractingGrammar& first, const grammar::NonContractingGrammar& second) const { - return first.compare(second); +template < > +struct compare < grammar::NonContractingGrammar > { + int operator ()( const grammar::NonContractingGrammar & first, const grammar::NonContractingGrammar & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/Regular/LeftLG.h b/alib2data/src/grammar/Regular/LeftLG.h index f88b385f6e..3546666f23 100644 --- a/alib2data/src/grammar/Regular/LeftLG.h +++ b/alib2data/src/grammar/Regular/LeftLG.h @@ -20,69 +20,66 @@ namespace grammar { * Left linear grammar in chomsky normal form. Type 3 in Chomsky hierarchy. Produces regular languages. */ class LeftLG : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<alphabet::Symbol, std::set<std::variant<std::vector<alphabet::Symbol>, std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>> >> > rules; + std::map < alphabet::Symbol, std::set < std::variant < std::vector < alphabet::Symbol >, std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > > > > rules; public: - explicit LeftLG(alphabet::Symbol initialSymbol); + explicit LeftLG ( alphabet::Symbol initialSymbol ); - explicit LeftLG(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit LeftLG ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(alphabet::Symbol leftHandSide, std::variant<std::vector<alphabet::Symbol>, std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>> > rightHandSide); - bool addRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); - bool addRule(alphabet::Symbol leftHandSide, std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>> rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, std::variant < std::vector < alphabet::Symbol >, std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > > rightHandSide ); + bool addRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); + bool addRule ( alphabet::Symbol leftHandSide, std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > rightHandSide ); - const std::map<alphabet::Symbol, std::set<std::variant<std::vector<alphabet::Symbol>, std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>> >> > & getRules() const; + const std::map < alphabet::Symbol, std::set < std::variant < std::vector < alphabet::Symbol >, std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > > > > & getRules ( ) const; - bool removeRule(const alphabet::Symbol& leftHandSide, const std::variant<std::vector<alphabet::Symbol>, std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>> >& rightHandSide); - bool removeRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); - bool removeRule(const alphabet::Symbol& leftHandSide, const std::pair<alphabet::Symbol, std::vector<alphabet::Symbol>>& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::variant < std::vector < alphabet::Symbol >, std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > > & rightHandSide ); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::pair < alphabet::Symbol, std::vector < alphabet::Symbol > > & rightHandSide ); - bool addRawRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRawRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> getRawRules() const; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > getRawRules ( ) const; - bool removeRawRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRawRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const LeftLG& other) const; + virtual int compare ( const LeftLG & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static LeftLG parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, LeftLG& grammar); + static LeftLG parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, LeftLG & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::LeftLG> { - int operator()(const grammar::LeftLG& first, const grammar::LeftLG& second) const { - return first.compare(second); +template < > +struct compare < grammar::LeftLG > { + int operator ()( const grammar::LeftLG & first, const grammar::LeftLG & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/Regular/LeftRG.h b/alib2data/src/grammar/Regular/LeftRG.h index 4980e6797a..3f3c2ece02 100644 --- a/alib2data/src/grammar/Regular/LeftRG.h +++ b/alib2data/src/grammar/Regular/LeftRG.h @@ -32,7 +32,7 @@ class LeftRG : public GrammarBase, public TerminalNonterminalAlphabetInitialSymb /** * Transition function as mapping from nonterminal symbol on the left hand side to set of either terminal symbols or doublets of terminal symbol and nonterminal symbol */ - std::map<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>> rules; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > > > rules; /** * Boolean signaling whether grammar generates empty string or don't. @@ -43,133 +43,127 @@ public: /** * Creates a new instance of Left regular grammar with concrete initial symbol */ - explicit LeftRG(alphabet::Symbol initialSymbol); + explicit LeftRG ( alphabet::Symbol initialSymbol ); /** * Creates a new instance of Left regular grammar with concrete nonterminal, terminal alphabet and initial symbol */ - explicit LeftRG(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit LeftRG ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); /** * @copydoc alib::base::clone() */ - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; /** * @copydoc alib::base::plunder() */ - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; /** * Add a new rule of a grammar in form of A -> aB or A -> a, where A, B \in N and a \in T */ - bool addRule(alphabet::Symbol leftHandSide, std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>> rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > rightHandSide ); /** * Add a new rule of a grammar in form of A -> a, where A \in N and a \in T */ - bool addRule(alphabet::Symbol leftHandSide, alphabet::Symbol rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, alphabet::Symbol rightHandSide ); /** * Add a new rule of a grammar in form of A -> aB, where A, B \in N and a \in T */ - bool addRule(alphabet::Symbol leftHandSide, std::pair<alphabet::Symbol, alphabet::Symbol> rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, std::pair < alphabet::Symbol, alphabet::Symbol > rightHandSide ); /** * Get rules of the grammar */ - const std::map<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>> & getRules() const; + const std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > > > & getRules ( ) const; /** * Add a new rule of a grammar in form of A -> aB or A -> a, where A, B \in N and a \in T */ - bool removeRule(const alphabet::Symbol& leftHandSide, const std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > & rightHandSide ); /** * Add a new rule of a grammar in form of A -> a, where A \in N and a \in T */ - bool removeRule(const alphabet::Symbol& leftHandSide, const alphabet::Symbol& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const alphabet::Symbol & rightHandSide ); /** * Add a new rule of a grammar in form of A -> aB, where A, B \in N and a \in T */ - bool removeRule(const alphabet::Symbol& leftHandSide, const std::pair<alphabet::Symbol, alphabet::Symbol>& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::pair < alphabet::Symbol, alphabet::Symbol > & rightHandSide ); - bool addRawRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRawRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> getRawRules() const; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > getRawRules ( ) const; - bool removeRawRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRawRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); /** * @copydoc TerminalNonterminalAlphabetInitialSymbol::removeTerminalSymbol() */ - virtual bool removeTerminalSymbol(const alphabet::Symbol& symbol); + virtual bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); /** * @copydoc TerminalNonterminalAlphabetInitialSymbol::removeNonterminalSymbol() */ - virtual bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + virtual bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); /** * Sets sing representing that grammar generates or doesn't generate empty word */ - void setGeneratesEpsilon(bool genEps); + void setGeneratesEpsilon ( bool genEps ); /** * Gets sing representing that grammar generates or doesn't generate empty word */ - bool getGeneratesEpsilon() const; + bool getGeneratesEpsilon ( ) const; /** * double dispatch operator helper */ - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } /** * compare * @param other the other instance */ - virtual int compare(const LeftRG& other) const; + virtual int compare ( const LeftRG & other ) const; /** * print this instance as raw representation to ostream * @param os ostream where to print */ - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; /** * casts this instance to as compact as possible string representation */ - virtual explicit operator std::string () const; - - /** - * @copydoc alib::base_base::selfTypeId - */ - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static LeftRG parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, LeftRG& grammar); + static LeftRG parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, LeftRG & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::LeftRG> { - int operator()(const grammar::LeftRG& first, const grammar::LeftRG& second) const { - return first.compare(second); +template < > +struct compare < grammar::LeftRG > { + int operator ()( const grammar::LeftRG & first, const grammar::LeftRG & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/Regular/RightLG.h b/alib2data/src/grammar/Regular/RightLG.h index 4db7497946..e7978c7045 100644 --- a/alib2data/src/grammar/Regular/RightLG.h +++ b/alib2data/src/grammar/Regular/RightLG.h @@ -20,69 +20,66 @@ namespace grammar { * Right linear grammar in chomsky normal form. Type 3 in Chomsky hierarchy. Produces regular languages. */ class RightLG : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<alphabet::Symbol, std::set<std::variant<std::vector<alphabet::Symbol>, std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol> >> > rules; + std::map < alphabet::Symbol, std::set < std::variant < std::vector < alphabet::Symbol >, std::pair < std::vector < alphabet::Symbol >, alphabet::Symbol > > > > rules; public: - explicit RightLG(alphabet::Symbol initialSymbol); + explicit RightLG ( alphabet::Symbol initialSymbol ); - explicit RightLG(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit RightLG ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(alphabet::Symbol leftHandSide, std::variant<std::vector<alphabet::Symbol>, std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol> > rightHandSide); - bool addRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); - bool addRule(alphabet::Symbol leftHandSide, std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol> rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, std::variant < std::vector < alphabet::Symbol >, std::pair < std::vector < alphabet::Symbol >, alphabet::Symbol > > rightHandSide ); + bool addRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); + bool addRule ( alphabet::Symbol leftHandSide, std::pair < std::vector < alphabet::Symbol >, alphabet::Symbol > rightHandSide ); - const std::map<alphabet::Symbol, std::set<std::variant<std::vector<alphabet::Symbol>, std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol> >> > & getRules() const; + const std::map < alphabet::Symbol, std::set < std::variant < std::vector < alphabet::Symbol >, std::pair < std::vector < alphabet::Symbol >, alphabet::Symbol > > > > & getRules ( ) const; - bool removeRule(const alphabet::Symbol& leftHandSide, const std::variant<std::vector<alphabet::Symbol>, std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol> >& rightHandSide); - bool removeRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); - bool removeRule(const alphabet::Symbol& leftHandSide, const std::pair<std::vector<alphabet::Symbol>, alphabet::Symbol>& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::variant < std::vector < alphabet::Symbol >, std::pair < std::vector < alphabet::Symbol >, alphabet::Symbol > > & rightHandSide ); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::pair < std::vector < alphabet::Symbol >, alphabet::Symbol > & rightHandSide ); - bool addRawRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRawRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> getRawRules() const; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > getRawRules ( ) const; - bool removeRawRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRawRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const RightLG& other) const; + virtual int compare ( const RightLG & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static RightLG parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, RightLG& grammar); + static RightLG parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, RightLG & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::RightLG> { - int operator()(const grammar::RightLG& first, const grammar::RightLG& second) const { - return first.compare(second); +template < > +struct compare < grammar::RightLG > { + int operator ()( const grammar::RightLG & first, const grammar::RightLG & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/Regular/RightRG.h b/alib2data/src/grammar/Regular/RightRG.h index 332fbf1fc6..c24d9f3a3a 100644 --- a/alib2data/src/grammar/Regular/RightRG.h +++ b/alib2data/src/grammar/Regular/RightRG.h @@ -32,7 +32,7 @@ class RightRG : public GrammarBase, public TerminalNonterminalAlphabetInitialSym /** * Transition function as mapping from nonterminal symbol on the left hand side to set of either terminal symbols or doublets of terminal symbol and nonterminal symbol */ - std::map<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>> rules; + std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > > > rules; /** * Boolean signaling whether grammar generates empty string or don't. @@ -40,69 +40,66 @@ class RightRG : public GrammarBase, public TerminalNonterminalAlphabetInitialSym bool generatesEpsilon; public: - explicit RightRG(alphabet::Symbol initialSymbol); + explicit RightRG ( alphabet::Symbol initialSymbol ); - explicit RightRG(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit RightRG ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(alphabet::Symbol leftHandSide, std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>> rightHandSide); - bool addRule(alphabet::Symbol leftHandSide, alphabet::Symbol rightHandSide); - bool addRule(alphabet::Symbol leftHandSide, std::pair<alphabet::Symbol, alphabet::Symbol> rightHandSide); + bool addRule ( alphabet::Symbol leftHandSide, std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > rightHandSide ); + bool addRule ( alphabet::Symbol leftHandSide, alphabet::Symbol rightHandSide ); + bool addRule ( alphabet::Symbol leftHandSide, std::pair < alphabet::Symbol, alphabet::Symbol > rightHandSide ); - const std::map<alphabet::Symbol, std::set<std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>>> & getRules() const; + const std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > > > & getRules ( ) const; - bool removeRule(const alphabet::Symbol& leftHandSide, const std::variant<alphabet::Symbol, std::pair<alphabet::Symbol, alphabet::Symbol>>& rightHandSide); - bool removeRule(const alphabet::Symbol& leftHandSide, const alphabet::Symbol& rightHandSide); - bool removeRule(const alphabet::Symbol& leftHandSide, const std::pair<alphabet::Symbol, alphabet::Symbol>& rightHandSide); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::variant < alphabet::Symbol, std::pair < alphabet::Symbol, alphabet::Symbol > > & rightHandSide ); + bool removeRule ( const alphabet::Symbol & leftHandSide, const alphabet::Symbol & rightHandSide ); + bool removeRule ( const alphabet::Symbol & leftHandSide, const std::pair < alphabet::Symbol, alphabet::Symbol > & rightHandSide ); - bool addRawRule(alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRawRule ( alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - std::map<alphabet::Symbol, std::set<std::vector<alphabet::Symbol>>> getRawRules() const; + std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > getRawRules ( ) const; - bool removeRawRule(const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRawRule ( const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - void setGeneratesEpsilon(bool genEps); - bool getGeneratesEpsilon() const; + void setGeneratesEpsilon ( bool genEps ); + bool getGeneratesEpsilon ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const RightRG& other) const; + virtual int compare ( const RightRG & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static RightRG parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, RightRG& grammar); + static RightRG parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, RightRG & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::RightRG> { - int operator()(const grammar::RightRG& first, const grammar::RightRG& second) const { - return first.compare(second); +template < > +struct compare < grammar::RightRG > { + int operator ()( const grammar::RightRG & first, const grammar::RightRG & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h b/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h index 6eb85a1b20..a025a8af91 100644 --- a/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h +++ b/alib2data/src/grammar/Unrestricted/ContextPreservingUnrestrictedGrammar.h @@ -19,59 +19,56 @@ namespace grammar { * Epsilon free context free grammar. Type 2 in Chomsky hierarchy. Produces context free languages. */ class ContextPreservingUnrestrictedGrammar : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>, std::set<std::vector<alphabet::Symbol>>> rules; + std::map < std::tuple < std::vector < alphabet::Symbol >, alphabet::Symbol, std::vector < alphabet::Symbol > >, std::set < std::vector < alphabet::Symbol > > > rules; public: - explicit ContextPreservingUnrestrictedGrammar(alphabet::Symbol initialSymbol); + explicit ContextPreservingUnrestrictedGrammar ( alphabet::Symbol initialSymbol ); - explicit ContextPreservingUnrestrictedGrammar(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit ContextPreservingUnrestrictedGrammar ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(std::vector<alphabet::Symbol> lContext, alphabet::Symbol leftHandSide, std::vector<alphabet::Symbol> rContext, std::vector<alphabet::Symbol> rightHandSide); + bool addRule ( std::vector < alphabet::Symbol > lContext, alphabet::Symbol leftHandSide, std::vector < alphabet::Symbol > rContext, std::vector < alphabet::Symbol > rightHandSide ); - const std::map<std::tuple<std::vector<alphabet::Symbol>, alphabet::Symbol, std::vector<alphabet::Symbol>>, std::set<std::vector<alphabet::Symbol>>> & getRules() const; + const std::map < std::tuple < std::vector < alphabet::Symbol >, alphabet::Symbol, std::vector < alphabet::Symbol > >, std::set < std::vector < alphabet::Symbol > > > & getRules ( ) const; - bool removeRule(const std::vector<alphabet::Symbol>& lContext, const alphabet::Symbol& leftHandSide, const std::vector<alphabet::Symbol>& rContext, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRule ( const std::vector < alphabet::Symbol > & lContext, const alphabet::Symbol & leftHandSide, const std::vector < alphabet::Symbol > & rContext, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const ContextPreservingUnrestrictedGrammar& other) const; + virtual int compare ( const ContextPreservingUnrestrictedGrammar & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static ContextPreservingUnrestrictedGrammar parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, ContextPreservingUnrestrictedGrammar& grammar); + static ContextPreservingUnrestrictedGrammar parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, ContextPreservingUnrestrictedGrammar & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::ContextPreservingUnrestrictedGrammar> { - int operator()(const grammar::ContextPreservingUnrestrictedGrammar& first, const grammar::ContextPreservingUnrestrictedGrammar& second) const { - return first.compare(second); +template < > +struct compare < grammar::ContextPreservingUnrestrictedGrammar > { + int operator ()( const grammar::ContextPreservingUnrestrictedGrammar & first, const grammar::ContextPreservingUnrestrictedGrammar & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h b/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h index 9655bb1441..0adb0952fd 100644 --- a/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h +++ b/alib2data/src/grammar/Unrestricted/UnrestrictedGrammar.h @@ -19,59 +19,56 @@ namespace grammar { * Unrestricted grammar. Type 0 in Chomsky hierarchy. Produces recursively enumerable language. */ class UnrestrictedGrammar : public GrammarBase, public TerminalNonterminalAlphabetInitialSymbol { - std::map<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>> rules; + std::map < std::vector < alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > rules; public: - explicit UnrestrictedGrammar(alphabet::Symbol initialSymbol); + explicit UnrestrictedGrammar ( alphabet::Symbol initialSymbol ); - explicit UnrestrictedGrammar(std::set<alphabet::Symbol> nonTerminalSymbols, std::set<alphabet::Symbol> terminalSymbols, alphabet::Symbol initialSymbol); + explicit UnrestrictedGrammar ( std::set < alphabet::Symbol > nonTerminalSymbols, std::set < alphabet::Symbol > terminalSymbols, alphabet::Symbol initialSymbol ); - virtual GrammarBase* clone() const; + virtual GrammarBase * clone ( ) const; - virtual GrammarBase* plunder() &&; + virtual GrammarBase * plunder ( ) &&; - bool addRule(std::vector<alphabet::Symbol> leftHandSide, std::vector<alphabet::Symbol> rightHandSide); + bool addRule ( std::vector < alphabet::Symbol > leftHandSide, std::vector < alphabet::Symbol > rightHandSide ); - const std::map<std::vector<alphabet::Symbol>, std::set<std::vector<alphabet::Symbol>>> & getRules() const; + const std::map < std::vector < alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > & getRules ( ) const; - bool removeRule(const std::vector<alphabet::Symbol>& leftHandSide, const std::vector<alphabet::Symbol>& rightHandSide); + bool removeRule ( const std::vector < alphabet::Symbol > & leftHandSide, const std::vector < alphabet::Symbol > & rightHandSide ); - bool removeTerminalSymbol(const alphabet::Symbol& symbol); + bool removeTerminalSymbol ( const alphabet::Symbol & symbol ); - bool removeNonterminalSymbol(const alphabet::Symbol& symbol); + bool removeNonterminalSymbol ( const alphabet::Symbol & symbol ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const UnrestrictedGrammar& other) const; + virtual int compare ( const UnrestrictedGrammar & other ) const; - virtual void operator>>(std::ostream& os) const; + virtual void operator >>( std::ostream & os ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static UnrestrictedGrammar parse(std::deque<sax::Token>::iterator& input); - static void parseRule(std::deque<sax::Token>::iterator& input, UnrestrictedGrammar& grammar); + static UnrestrictedGrammar parse ( std::deque < sax::Token >::iterator & input ); + static void parseRule ( std::deque < sax::Token >::iterator & input, UnrestrictedGrammar & grammar ); - void compose(std::deque<sax::Token>& out) const; - void composeRules(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; + void composeRules ( std::deque < sax::Token > & out ) const; }; } /* namespace grammar */ namespace std { -template<> -struct compare<grammar::UnrestrictedGrammar> { - int operator()(const grammar::UnrestrictedGrammar& first, const grammar::UnrestrictedGrammar& second) const { - return first.compare(second); +template < > +struct compare < grammar::UnrestrictedGrammar > { + int operator ()( const grammar::UnrestrictedGrammar & first, const grammar::UnrestrictedGrammar & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/graph/directed/DirectedGraph.h b/alib2data/src/graph/directed/DirectedGraph.h index ed7428d241..9d16ea20c1 100644 --- a/alib2data/src/graph/directed/DirectedGraph.h +++ b/alib2data/src/graph/directed/DirectedGraph.h @@ -23,75 +23,69 @@ class IDirectedGraph; class DirectedGraph : public GraphBase { public: - explicit DirectedGraph(REPRESENTATION representation = REPRESENTATION::ADJACENCY_LIST); - ~DirectedGraph() noexcept; + explicit DirectedGraph ( REPRESENTATION representation = REPRESENTATION::ADJACENCY_LIST ); + ~DirectedGraph ( ) noexcept; - DirectedGraph(const DirectedGraph &other); - DirectedGraph(DirectedGraph &&other) noexcept; - DirectedGraph &operator=(const DirectedGraph &other); - DirectedGraph &operator=(DirectedGraph &&other) noexcept; + DirectedGraph ( const DirectedGraph & other ); + DirectedGraph ( DirectedGraph && other ) noexcept; + DirectedGraph & operator =( const DirectedGraph & other ); + DirectedGraph & operator =( DirectedGraph && other ) noexcept; - GraphBase *clone() const override; - GraphBase *plunder() && override; + GraphBase * clone ( ) const override; + GraphBase * plunder ( ) && override; - REPRESENTATION getRepresentation() const; + REPRESENTATION getRepresentation ( ) const; - std::set<Node> getNodes() const; - std::set<DirectedEdge> getEdges() const; + std::set < Node > getNodes ( ) const; + std::set < DirectedEdge > getEdges ( ) const; - bool hasNode(const Node &node) const; - bool hasEdge(const DirectedEdge &edge) const; + bool hasNode ( const Node & node ) const; + bool hasEdge ( const DirectedEdge & edge ) const; - bool hasEdge(const Node &from, const Node &to) const; - std::set<DirectedEdge> findEdges(const Node &from, const Node &to) const; + bool hasEdge ( const Node & from, const Node & to ) const; + std::set < DirectedEdge > findEdges ( const Node & from, const Node & to ) const; - std::set<Node> neighbors(const Node &node) const; - std::set<DirectedEdge> neighborEdges(const Node &node) const; + std::set < Node > neighbors ( const Node & node ) const; + std::set < DirectedEdge > neighborEdges ( const Node & node ) const; - bool addNode(const Node &node); - bool addNode(const Node &node, int value); - bool removeNode(const Node &node); + bool addNode ( const Node & node ); + bool addNode ( const Node & node, int value ); + bool removeNode ( const Node & node ); - bool addEdge(const DirectedEdge &edge); - bool addEdge(const DirectedEdge &edge, int value); - bool removeEdge(const DirectedEdge &edge); + bool addEdge ( const DirectedEdge & edge ); + bool addEdge ( const DirectedEdge & edge, int value ); + bool removeEdge ( const DirectedEdge & edge ); - int getNodeValue(const Node &node) const; - void setNodeValue(const Node &node, int value); + int getNodeValue ( const Node & node ) const; + void setNodeValue ( const Node & node, int value ); - int getEdgeValue(const DirectedEdge &edge) const; - void setEdgeValue(const DirectedEdge &edge, int value); + int getEdgeValue ( const DirectedEdge & edge ) const; + void setEdgeValue ( const DirectedEdge & edge, int value ); - int compare(const ObjectBase &other) const override - { - return ObjectBase::compare(*this, other); + int compare ( const ObjectBase & other ) const override { + return ObjectBase::compare ( * this, other ); } - int compare(const DirectedGraph &other) const; + int compare ( const DirectedGraph & other ) const; - void operator>>(std::ostream &out) const override; + void operator >>( std::ostream & out ) const override; - explicit operator std::string() const override; - - virtual long long selfTypeId() const override - { - return typeId(*this); - } + explicit operator std::string ( ) const override; const static std::string XML_TAG_NAME; - static DirectedGraph parse(std::deque<sax::Token>::iterator& input); + static DirectedGraph parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const override; + void compose ( std::deque < sax::Token > & out ) const override; private: - void init(); + void init ( ); REPRESENTATION representation; - IDirectedGraph *impl; + IDirectedGraph * impl; - std::unordered_map<Node, int> nodeValues; - std::unordered_map<DirectedEdge, int> edgeValues; + std::unordered_map < Node, int > nodeValues; + std::unordered_map < DirectedEdge, int > edgeValues; friend class GraphToXMLComposer; friend class GraphToStringComposer; @@ -99,6 +93,6 @@ private: } // namespace graph -GRAPH_DEFINE_STD_COMPARE(DirectedGraph) +GRAPH_DEFINE_STD_COMPARE ( DirectedGraph ) #endif // DIRECTED_GRAPH_H_ diff --git a/alib2data/src/graph/undirected/UndirectedGraph.h b/alib2data/src/graph/undirected/UndirectedGraph.h index c7a803a186..575c7589d2 100644 --- a/alib2data/src/graph/undirected/UndirectedGraph.h +++ b/alib2data/src/graph/undirected/UndirectedGraph.h @@ -23,75 +23,69 @@ class IUndirectedGraph; class UndirectedGraph : public GraphBase { public: - explicit UndirectedGraph(REPRESENTATION representation = REPRESENTATION::ADJACENCY_LIST); - ~UndirectedGraph() noexcept; + explicit UndirectedGraph ( REPRESENTATION representation = REPRESENTATION::ADJACENCY_LIST ); + ~UndirectedGraph ( ) noexcept; - UndirectedGraph(const UndirectedGraph &other); - UndirectedGraph(UndirectedGraph &&other) noexcept; - UndirectedGraph &operator=(const UndirectedGraph &other); - UndirectedGraph &operator=(UndirectedGraph &&other) noexcept; + UndirectedGraph ( const UndirectedGraph & other ); + UndirectedGraph ( UndirectedGraph && other ) noexcept; + UndirectedGraph & operator =( const UndirectedGraph & other ); + UndirectedGraph & operator =( UndirectedGraph && other ) noexcept; - GraphBase *clone() const override; - GraphBase *plunder() && override; + GraphBase * clone ( ) const override; + GraphBase * plunder ( ) && override; - REPRESENTATION getRepresentation() const; + REPRESENTATION getRepresentation ( ) const; - std::set<Node> getNodes() const; - std::set<UndirectedEdge> getEdges() const; + std::set < Node > getNodes ( ) const; + std::set < UndirectedEdge > getEdges ( ) const; - bool hasNode(const Node &node) const; - bool hasEdge(const UndirectedEdge &edge) const; + bool hasNode ( const Node & node ) const; + bool hasEdge ( const UndirectedEdge & edge ) const; - bool hasEdge(const Node &from, const Node &to) const; - std::set<UndirectedEdge> findEdges(const Node &from, const Node &to) const; + bool hasEdge ( const Node & from, const Node & to ) const; + std::set < UndirectedEdge > findEdges ( const Node & from, const Node & to ) const; - std::set<Node> neighbors(const Node &node) const; - std::set<UndirectedEdge> neighborEdges(const Node &node) const; + std::set < Node > neighbors ( const Node & node ) const; + std::set < UndirectedEdge > neighborEdges ( const Node & node ) const; - bool addNode(const Node &node); - bool addNode(const Node &node, int value); - bool removeNode(const Node &node); + bool addNode ( const Node & node ); + bool addNode ( const Node & node, int value ); + bool removeNode ( const Node & node ); - bool addEdge(const UndirectedEdge &edge); - bool addEdge(const UndirectedEdge &edge, int value); - bool removeEdge(const UndirectedEdge &edge); + bool addEdge ( const UndirectedEdge & edge ); + bool addEdge ( const UndirectedEdge & edge, int value ); + bool removeEdge ( const UndirectedEdge & edge ); - int getNodeValue(const Node &node) const; - void setNodeValue(const Node &node, int value); + int getNodeValue ( const Node & node ) const; + void setNodeValue ( const Node & node, int value ); - int getEdgeValue(const UndirectedEdge &edge) const; - void setEdgeValue(const UndirectedEdge &edge, int value); + int getEdgeValue ( const UndirectedEdge & edge ) const; + void setEdgeValue ( const UndirectedEdge & edge, int value ); - int compare(const ObjectBase &other) const override - { - return ObjectBase::compare(*this, other); + int compare ( const ObjectBase & other ) const override { + return ObjectBase::compare ( * this, other ); } - int compare(const UndirectedGraph &other) const; + int compare ( const UndirectedGraph & other ) const; - void operator>>(std::ostream &out) const override; + void operator >>( std::ostream & out ) const override; - explicit operator std::string() const override; - - virtual long long selfTypeId() const override - { - return typeId(*this); - } + explicit operator std::string ( ) const override; const static std::string XML_TAG_NAME; - static UndirectedGraph parse(std::deque<sax::Token>::iterator& input); + static UndirectedGraph parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const override; + void compose ( std::deque < sax::Token > & out ) const override; private: - void init(); + void init ( ); REPRESENTATION representation; - IUndirectedGraph *impl; + IUndirectedGraph * impl; - std::unordered_map<Node, int> nodeValues; - std::unordered_map<UndirectedEdge, int> edgeValues; + std::unordered_map < Node, int > nodeValues; + std::unordered_map < UndirectedEdge, int > edgeValues; friend class GraphToXMLComposer; friend class GraphToStringComposer; @@ -99,6 +93,6 @@ private: } // namespace graph -GRAPH_DEFINE_STD_COMPARE(UndirectedGraph) +GRAPH_DEFINE_STD_COMPARE ( UndirectedGraph ) #endif // UNDIRECTED_GRAPH_H_ diff --git a/alib2data/src/label/HexavigesimalLabel.h b/alib2data/src/label/HexavigesimalLabel.h index 4f84514721..bbb8a5d01d 100644 --- a/alib2data/src/label/HexavigesimalLabel.h +++ b/alib2data/src/label/HexavigesimalLabel.h @@ -26,55 +26,51 @@ public: * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit HexavigesimalLabel(int hexavigesimal); + explicit HexavigesimalLabel ( int hexavigesimal ); - virtual LabelBase* clone() const; + virtual LabelBase * clone ( ) const; - virtual LabelBase* plunder() &&; + virtual LabelBase * plunder ( ) &&; /** * @return name of the symbol */ - int getData() const; + int getData ( ) const; - void setData(int data); + void setData ( int data ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const HexavigesimalLabel& other) const; + virtual int compare ( const HexavigesimalLabel & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static HexavigesimalLabel parse(std::deque<sax::Token>::iterator& input); + static HexavigesimalLabel parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual LabelBase* next() const; - virtual LabelBase* inc() &&; + virtual LabelBase * next ( ) const; + virtual LabelBase * inc ( ) &&; }; } /* namespace label */ namespace std { -template<> -struct compare<label::HexavigesimalLabel> { - int operator()(const label::HexavigesimalLabel& first, const label::HexavigesimalLabel& second) const { - return first.compare(second); +template < > +struct compare < label::HexavigesimalLabel > { + int operator ()( const label::HexavigesimalLabel & first, const label::HexavigesimalLabel & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* HEXAVIGESIMAL_LABEL_H_ */ - diff --git a/alib2data/src/label/LabelPairLabel.h b/alib2data/src/label/LabelPairLabel.h index cbace15664..43be641a6e 100644 --- a/alib2data/src/label/LabelPairLabel.h +++ b/alib2data/src/label/LabelPairLabel.h @@ -18,60 +18,56 @@ namespace label { */ class LabelPairLabel : public LabelBase { protected: - std::pair<Label, Label> label; + std::pair < Label, Label > label; public: /** * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit LabelPairLabel(std::pair<Label, Label> label); + explicit LabelPairLabel ( std::pair < Label, Label > label ); - virtual LabelBase* clone() const; + virtual LabelBase * clone ( ) const; - virtual LabelBase* plunder() &&; + virtual LabelBase * plunder ( ) &&; /** * @return name of the symbol */ - const std::pair<Label, Label>& getData() const; + const std::pair < Label, Label > & getData ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const LabelPairLabel& other) const; + virtual int compare ( const LabelPairLabel & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static LabelPairLabel parse(std::deque<sax::Token>::iterator& input); + static LabelPairLabel parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual LabelBase* next() const; - virtual LabelBase* inc() &&; + virtual LabelBase * next ( ) const; + virtual LabelBase * inc ( ) &&; }; } /* namespace label */ namespace std { -template<> -struct compare<label::LabelPairLabel> { - int operator()(const label::LabelPairLabel& first, const label::LabelPairLabel& second) const { - return first.compare(second); +template < > +struct compare < label::LabelPairLabel > { + int operator ()( const label::LabelPairLabel & first, const label::LabelPairLabel & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* LABEL_PAIR_LABEL_H_ */ - diff --git a/alib2data/src/label/LabelSetLabel.h b/alib2data/src/label/LabelSetLabel.h index 9f1ebed6ee..e97d33be0f 100644 --- a/alib2data/src/label/LabelSetLabel.h +++ b/alib2data/src/label/LabelSetLabel.h @@ -18,60 +18,56 @@ namespace label { */ class LabelSetLabel : public LabelBase { protected: - std::set<Label> label; + std::set < Label > label; public: /** * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit LabelSetLabel(std::set<Label> label); + explicit LabelSetLabel ( std::set < Label > label ); - virtual LabelBase* clone() const; + virtual LabelBase * clone ( ) const; - virtual LabelBase* plunder() &&; + virtual LabelBase * plunder ( ) &&; /** * @return name of the symbol */ - const std::set<Label>& getData() const; + const std::set < Label > & getData ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const LabelSetLabel& other) const; + virtual int compare ( const LabelSetLabel & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static LabelSetLabel parse(std::deque<sax::Token>::iterator& input); + static LabelSetLabel parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual LabelBase* next() const; - virtual LabelBase* inc() &&; + virtual LabelBase * next ( ) const; + virtual LabelBase * inc ( ) &&; }; } /* namespace label */ namespace std { -template<> -struct compare<label::LabelSetLabel> { - int operator()(const label::LabelSetLabel& first, const label::LabelSetLabel& second) const { - return first.compare(second); +template < > +struct compare < label::LabelSetLabel > { + int operator ()( const label::LabelSetLabel & first, const label::LabelSetLabel & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* LABEL_SET_LABEL_H_ */ - diff --git a/alib2data/src/label/ObjectLabel.h b/alib2data/src/label/ObjectLabel.h index daccedf3b3..dac4c7f921 100644 --- a/alib2data/src/label/ObjectLabel.h +++ b/alib2data/src/label/ObjectLabel.h @@ -26,50 +26,47 @@ public: * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit ObjectLabel(alib::Object label); + explicit ObjectLabel ( alib::Object label ); - virtual LabelBase* clone() const; + virtual LabelBase * clone ( ) const; - virtual LabelBase* plunder() &&; + virtual LabelBase * plunder ( ) &&; /** * @return name of the symbol */ - const alib::Object& getData() const; + const alib::Object & getData ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const ObjectLabel& other) const; - - virtual void operator>>(std::ostream&) const; + virtual int compare ( const ObjectLabel & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static ObjectLabel parse(std::deque<sax::Token>::iterator& input); + static ObjectLabel parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual LabelBase* next() const; - virtual LabelBase* inc() &&; + virtual LabelBase * next ( ) const; + virtual LabelBase * inc ( ) &&; }; } /* namespace label */ namespace std { -template<> -struct compare<label::ObjectLabel> { - int operator()(const label::ObjectLabel& first, const label::ObjectLabel& second) const { - return first.compare(second); +template < > +struct compare < label::ObjectLabel > { + int operator ()( const label::ObjectLabel & first, const label::ObjectLabel & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/label/PrimitiveLabel.h b/alib2data/src/label/PrimitiveLabel.h index 63ab2adf92..26397e4b40 100644 --- a/alib2data/src/label/PrimitiveLabel.h +++ b/alib2data/src/label/PrimitiveLabel.h @@ -26,55 +26,51 @@ public: * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit PrimitiveLabel(primitive::Primitive primitive); + explicit PrimitiveLabel ( primitive::Primitive primitive ); - virtual LabelBase* clone() const; + virtual LabelBase * clone ( ) const; - virtual LabelBase* plunder() &&; + virtual LabelBase * plunder ( ) &&; /** * @return name of the symbol */ - const primitive::Primitive& getData() const; + const primitive::Primitive & getData ( ) const; - primitive::Primitive& getData(); + primitive::Primitive & getData ( ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const PrimitiveLabel& other) const; + virtual int compare ( const PrimitiveLabel & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static PrimitiveLabel parse(std::deque<sax::Token>::iterator& input); + static PrimitiveLabel parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual LabelBase* next() const; - virtual LabelBase* inc() &&; + virtual LabelBase * next ( ) const; + virtual LabelBase * inc ( ) &&; }; } /* namespace label */ namespace std { -template<> -struct compare<label::PrimitiveLabel> { - int operator()(const label::PrimitiveLabel& first, const label::PrimitiveLabel& second) const { - return first.compare(second); +template < > +struct compare < label::PrimitiveLabel > { + int operator ()( const label::PrimitiveLabel & first, const label::PrimitiveLabel & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* PRIMITIVE_LABEL_H_ */ - diff --git a/alib2data/src/label/UniqueLabel.h b/alib2data/src/label/UniqueLabel.h index c1382e5df4..3832c97a85 100644 --- a/alib2data/src/label/UniqueLabel.h +++ b/alib2data/src/label/UniqueLabel.h @@ -26,57 +26,53 @@ public: * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit UniqueLabel(Label label, primitive::Integer id); + explicit UniqueLabel ( Label label, primitive::Integer id ); - virtual LabelBase* clone() const; + virtual LabelBase * clone ( ) const; - virtual LabelBase* plunder() &&; + virtual LabelBase * plunder ( ) &&; /** * @return name of the symbol */ - const Label& getLabel() const; + const Label & getLabel ( ) const; - const primitive::Integer& getId() const; + const primitive::Integer & getId ( ) const; - primitive::Integer& getId(); + primitive::Integer & getId ( ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const UniqueLabel& other) const; + virtual int compare ( const UniqueLabel & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static UniqueLabel parse(std::deque<sax::Token>::iterator& input); + static UniqueLabel parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; - virtual LabelBase* next() const; - virtual LabelBase* inc() &&; + virtual LabelBase * next ( ) const; + virtual LabelBase * inc ( ) &&; }; } /* namespace label */ namespace std { -template<> -struct compare<label::UniqueLabel> { - int operator()(const label::UniqueLabel& first, const label::UniqueLabel& second) const { - return first.compare(second); +template < > +struct compare < label::UniqueLabel > { + int operator ()( const label::UniqueLabel & first, const label::UniqueLabel & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* LABEL_ID_LABEL_H_ */ - diff --git a/alib2data/src/object/Void.h b/alib2data/src/object/Void.h index 4979d3f0cf..7b624ae1e3 100644 --- a/alib2data/src/object/Void.h +++ b/alib2data/src/object/Void.h @@ -23,43 +23,40 @@ public: * Creates a blank symbol. * @param symbol name of the symbol */ - explicit Void(); + explicit Void ( ); - virtual ObjectBase* clone() const; - virtual ObjectBase* plunder() &&; + virtual ObjectBase * clone ( ) const; + virtual ObjectBase * plunder ( ) &&; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const Void& other) const; + virtual int compare ( const Void & other ) const; - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; static Void VOID; const static std::string XML_TAG_NAME; - static Void parse(std::deque<sax::Token>::iterator& input); + static Void parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace alib */ namespace std { -template<> -struct compare<alib::Void> { - int operator()(const alib::Void& first, const alib::Void& second) const { - return first.compare(second); +template < > +struct compare < alib::Void > { + int operator ()( const alib::Void & first, const alib::Void & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/primitive/Bool.h b/alib2data/src/primitive/Bool.h index 966a021152..73033ce898 100644 --- a/alib2data/src/primitive/Bool.h +++ b/alib2data/src/primitive/Bool.h @@ -25,68 +25,65 @@ public: * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit Bool(bool data); + explicit Bool ( bool data ); - virtual PrimitiveBase* clone() const; + virtual PrimitiveBase * clone ( ) const; - virtual PrimitiveBase* plunder() &&; + virtual PrimitiveBase * plunder ( ) &&; /** * @return name of the symbol */ - bool getData() const; + bool getData ( ) const; /** * sets new content of primitive */ - void setData(bool data); + void setData ( bool data ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const Bool& other) const; + virtual int compare ( const Bool & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static Bool parse(std::deque<sax::Token>::iterator& input); - static bool parseRaw(std::deque<sax::Token>::iterator& input); + static Bool parse ( std::deque < sax::Token >::iterator & input ); + static bool parseRaw ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; - static void compose(std::deque<sax::Token>& out, bool primitive); + void compose ( std::deque < sax::Token > & out ) const; + static void compose ( std::deque < sax::Token > & out, bool primitive ); - Bool next() const; - virtual void inc(); + Bool next ( ) const; + virtual void inc ( ); }; } /* namespace primitive */ namespace std { -template<> -struct compare<primitive::Bool> { - int operator()(const primitive::Bool& first, const primitive::Bool& second) const { - return first.compare(second); +template < > +struct compare < primitive::Bool > { + int operator ()( const primitive::Bool & first, const primitive::Bool & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ namespace alib { -template<> -struct xmlApi<bool> { - static bool parse(std::deque<sax::Token>::iterator& input); - static bool first(const std::deque<sax::Token>::const_iterator& input); - static void compose(std::deque<sax::Token>& output, bool data); +template < > +struct xmlApi < bool > { + static bool parse ( std::deque < sax::Token >::iterator & input ); + static bool first ( const std::deque < sax::Token >::const_iterator & input ); + static void compose ( std::deque < sax::Token > & output, bool data ); }; } /* namespace alib */ diff --git a/alib2data/src/primitive/Character.h b/alib2data/src/primitive/Character.h index 2966b10d85..56207ed374 100644 --- a/alib2data/src/primitive/Character.h +++ b/alib2data/src/primitive/Character.h @@ -25,71 +25,67 @@ public: * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit Character(char data); + explicit Character ( char data ); - virtual PrimitiveBase* clone() const; + virtual PrimitiveBase * clone ( ) const; - virtual PrimitiveBase* plunder() &&; + virtual PrimitiveBase * plunder ( ) &&; /** * @return name of the symbol */ - char getData() const; + char getData ( ) const; /** * sets new content of primitive */ - void setData(char data); + void setData ( char data ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const Character& other) const; + virtual int compare ( const Character & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static Character parse(std::deque<sax::Token>::iterator& input); - static char parseRaw(std::deque<sax::Token>::iterator& input); + static Character parse ( std::deque < sax::Token >::iterator & input ); + static char parseRaw ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; - static void compose(std::deque<sax::Token>& out, char primitive); + void compose ( std::deque < sax::Token > & out ) const; + static void compose ( std::deque < sax::Token > & out, char primitive ); - Character next() const; - virtual void inc(); + Character next ( ) const; + virtual void inc ( ); }; } /* namespace primitive */ namespace std { -template<> -struct compare<primitive::Character> { - int operator()(const primitive::Character& first, const primitive::Character& second) const { - return first.compare(second); +template < > +struct compare < primitive::Character > { + int operator ()( const primitive::Character & first, const primitive::Character & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ namespace alib { -template<> -struct xmlApi<char> { - static char parse(std::deque<sax::Token>::iterator& input); - static bool first(const std::deque<sax::Token>::const_iterator& input); - static void compose(std::deque<sax::Token>& output, char data); +template < > +struct xmlApi < char > { + static char parse ( std::deque < sax::Token >::iterator & input ); + static bool first ( const std::deque < sax::Token >::const_iterator & input ); + static void compose ( std::deque < sax::Token > & output, char data ); }; } /* namespace alib */ #endif /* PRIMITIVE_CHARACTER_H_ */ - diff --git a/alib2data/src/primitive/Integer.h b/alib2data/src/primitive/Integer.h index 8f9ce18bf7..0b618eaa11 100644 --- a/alib2data/src/primitive/Integer.h +++ b/alib2data/src/primitive/Integer.h @@ -25,68 +25,65 @@ public: * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit Integer(int data); + explicit Integer ( int data ); - virtual PrimitiveBase* clone() const; + virtual PrimitiveBase * clone ( ) const; - virtual PrimitiveBase* plunder() &&; + virtual PrimitiveBase * plunder ( ) &&; /** * @return name of the symbol */ - int getData() const; + int getData ( ) const; /** * sets new content of primitive */ - void setData(int data); + void setData ( int data ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const Integer& other) const; + virtual int compare ( const Integer & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static Integer parse(std::deque<sax::Token>::iterator& input); - static int parseRaw(std::deque<sax::Token>::iterator& input); + static Integer parse ( std::deque < sax::Token >::iterator & input ); + static int parseRaw ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; - static void compose(std::deque<sax::Token>& out, int primitive); + void compose ( std::deque < sax::Token > & out ) const; + static void compose ( std::deque < sax::Token > & out, int primitive ); - Integer next() const; - virtual void inc(); + Integer next ( ) const; + virtual void inc ( ); }; } /* namespace primitive */ namespace std { -template<> -struct compare<primitive::Integer> { - int operator()(const primitive::Integer& first, const primitive::Integer& second) const { - return first.compare(second); +template < > +struct compare < primitive::Integer > { + int operator ()( const primitive::Integer & first, const primitive::Integer & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ -namespace alib{ +namespace alib { -template<> -struct xmlApi<int> { - static int parse(std::deque<sax::Token>::iterator& input); - static bool first(const std::deque<sax::Token>::const_iterator& input); - static void compose(std::deque<sax::Token>& output, int data); +template < > +struct xmlApi < int > { + static int parse ( std::deque < sax::Token >::iterator & input ); + static bool first ( const std::deque < sax::Token >::const_iterator & input ); + static void compose ( std::deque < sax::Token > & output, int data ); }; } /* namespace alib */ diff --git a/alib2data/src/primitive/String.h b/alib2data/src/primitive/String.h index d9b02f7e44..5f0b74207e 100644 --- a/alib2data/src/primitive/String.h +++ b/alib2data/src/primitive/String.h @@ -26,73 +26,69 @@ public: * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit String(std::string data); + explicit String ( std::string data ); - explicit String(const char* data); + explicit String ( const char * data ); - virtual PrimitiveBase* clone() const; + virtual PrimitiveBase * clone ( ) const; - virtual PrimitiveBase* plunder() &&; + virtual PrimitiveBase * plunder ( ) &&; /** * @return name of the symbol */ - const std::string& getData() const; + const std::string & getData ( ) const; /** * @return name of the symbol */ - std::string& getData(); + std::string & getData ( ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const String& other) const; + virtual int compare ( const String & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string () const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static String parse(std::deque<sax::Token>::iterator& input); - static std::string parseRaw(std::deque<sax::Token>::iterator& input); + static String parse ( std::deque < sax::Token >::iterator & input ); + static std::string parseRaw ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; - static void compose(std::deque<sax::Token>& out, std::string primitive); + void compose ( std::deque < sax::Token > & out ) const; + static void compose ( std::deque < sax::Token > & out, std::string primitive ); - String next() const; - virtual void inc(); + String next ( ) const; + virtual void inc ( ); }; } /* namespace primitive */ namespace std { -template<> -struct compare<primitive::String> { - int operator()(const primitive::String& first, const primitive::String& second) const { - return first.compare(second); +template < > +struct compare < primitive::String > { + int operator ()( const primitive::String & first, const primitive::String & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ -namespace alib{ +namespace alib { -template<> -struct xmlApi<std::string> { - static std::string parse(std::deque<sax::Token>::iterator& input); - static bool first(const std::deque<sax::Token>::const_iterator& input); - static void compose(std::deque<sax::Token>& output, std::string data); +template < > +struct xmlApi < std::string > { + static std::string parse ( std::deque < sax::Token >::iterator & input ); + static bool first ( const std::deque < sax::Token >::const_iterator & input ); + static void compose ( std::deque < sax::Token > & output, std::string data ); }; } /* namespace alib */ #endif /* PRIMITIVE_STRING_H_ */ - diff --git a/alib2data/src/primitive/Unsigned.h b/alib2data/src/primitive/Unsigned.h index 27d4ffd6c6..84bc44bd51 100644 --- a/alib2data/src/primitive/Unsigned.h +++ b/alib2data/src/primitive/Unsigned.h @@ -25,68 +25,65 @@ public: * Creates new symbol with given name. * @param symbol name of the symbol */ - explicit Unsigned(unsigned data); + explicit Unsigned ( unsigned data ); - virtual PrimitiveBase* clone() const; + virtual PrimitiveBase * clone ( ) const; - virtual PrimitiveBase* plunder() &&; + virtual PrimitiveBase * plunder ( ) &&; /** * @return name of the symbol */ - unsigned getData() const; + unsigned getData ( ) const; /** * sets new content of primitive */ - void setData(unsigned data); + void setData ( unsigned data ); - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const Unsigned& other) const; + virtual int compare ( const Unsigned & other ) const; - virtual void operator>>(std::ostream&) const; + virtual void operator >>( std::ostream & ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static Unsigned parse(std::deque<sax::Token>::iterator& input); - static unsigned parseRaw(std::deque<sax::Token>::iterator& input); + static Unsigned parse ( std::deque < sax::Token >::iterator & input ); + static unsigned parseRaw ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; - static void compose(std::deque<sax::Token>& out, unsigned primitive); + void compose ( std::deque < sax::Token > & out ) const; + static void compose ( std::deque < sax::Token > & out, unsigned primitive ); - Unsigned next() const; - virtual void inc(); + Unsigned next ( ) const; + virtual void inc ( ); }; } /* namespace primitive */ namespace std { -template<> -struct compare<primitive::Unsigned> { - int operator()(const primitive::Unsigned& first, const primitive::Unsigned& second) const { - return first.compare(second); +template < > +struct compare < primitive::Unsigned > { + int operator ()( const primitive::Unsigned & first, const primitive::Unsigned & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ -namespace alib{ +namespace alib { -template<> -struct xmlApi<unsigned> { - static unsigned parse(std::deque<sax::Token>::iterator& input); - static bool first(const std::deque<sax::Token>::const_iterator& input); - static void compose(std::deque<sax::Token>& output, unsigned data); +template < > +struct xmlApi < unsigned > { + static unsigned parse ( std::deque < sax::Token >::iterator & input ); + static bool first ( const std::deque < sax::Token >::const_iterator & input ); + static void compose ( std::deque < sax::Token > & output, unsigned data ); }; } /* namespace alib */ diff --git a/alib2data/src/regexp/formal/FormalRegExp.h b/alib2data/src/regexp/formal/FormalRegExp.h index 617e12cd70..ac2cf82806 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.h +++ b/alib2data/src/regexp/formal/FormalRegExp.h @@ -27,103 +27,100 @@ class UnboundedRegExp; */ class FormalRegExp : public RegExpBase, public RegExpAlphabet { protected: - FormalRegExpElement* regExp; + FormalRegExpElement * regExp; public: /** * @copydoc FormalRegExpElement::clone() const */ - virtual RegExpBase* clone() const; + virtual RegExpBase * clone ( ) const; /** * @copydoc FormalRegExpElement::plunder() const */ - virtual RegExpBase* plunder() &&; + virtual RegExpBase * plunder ( ) &&; - explicit FormalRegExp(); - explicit FormalRegExp(const UnboundedRegExp& other); - explicit FormalRegExp(std::set<alphabet::Symbol> alphabet, const FormalRegExpElement& regExp); - explicit FormalRegExp(std::set<alphabet::Symbol> alphabet, FormalRegExpElement&& regExp); - explicit FormalRegExp(const FormalRegExpElement& regExp); - explicit FormalRegExp(FormalRegExpElement&& regExp); + explicit FormalRegExp ( ); + explicit FormalRegExp ( const UnboundedRegExp & other ); + explicit FormalRegExp ( std::set < alphabet::Symbol > alphabet, const FormalRegExpElement & regExp ); + explicit FormalRegExp ( std::set < alphabet::Symbol > alphabet, FormalRegExpElement && regExp ); + explicit FormalRegExp ( const FormalRegExpElement & regExp ); + explicit FormalRegExp ( FormalRegExpElement && regExp ); /** * Copy constructor. * @param other RegExp to copy */ - FormalRegExp(const FormalRegExp& other); - FormalRegExp(FormalRegExp&& other) noexcept; - FormalRegExp& operator =(const FormalRegExp& other); - FormalRegExp& operator =(FormalRegExp&& other) noexcept; - ~FormalRegExp() noexcept; + FormalRegExp ( const FormalRegExp & other ); + FormalRegExp ( FormalRegExp && other ) noexcept; + FormalRegExp & operator =( const FormalRegExp & other ); + FormalRegExp & operator =( FormalRegExp && other ) noexcept; + ~FormalRegExp ( ) noexcept; /** * @return Root node of the regular expression tree */ - const FormalRegExpElement& getRegExp() const; + const FormalRegExpElement & getRegExp ( ) const; /** * @return Root node of the regular expression tree */ - FormalRegExpElement& getRegExp(); + FormalRegExpElement & getRegExp ( ); /** * Sets the root node of the regular expression tree * @param regExp root node to set */ - void setRegExp(const FormalRegExpElement& regExp); + void setRegExp ( const FormalRegExpElement & regExp ); /** * Sets the root node of the regular expression tree * @param regExp root node to set */ - void setRegExp(FormalRegExpElement&& regExp); + void setRegExp ( FormalRegExpElement && regExp ); - virtual const std::set<alphabet::Symbol>& getAlphabet() const { - return RegExpAlphabet::getAlphabet(); + virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const { + return RegExpAlphabet::getAlphabet ( ); } /** * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet(const alphabet::Symbol & symbol); + bool removeSymbolFromAlphabet ( const alphabet::Symbol & symbol ); /** * Prints XML representation of the RegExp to the output stream. * @param out output stream to which print the RegExp * @param regexp RegExp to print */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const FormalRegExp& other) const; + virtual int compare ( const FormalRegExp & other ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static FormalRegExp parse(std::deque<sax::Token>::iterator& input); + static FormalRegExp parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace regexp */ namespace std { -template<> -struct compare<regexp::FormalRegExp> { - int operator()(const regexp::FormalRegExp& first, const regexp::FormalRegExp& second) const { - return first.compare(second); +template < > +struct compare < regexp::FormalRegExp > { + int operator ()( const regexp::FormalRegExp & first, const regexp::FormalRegExp & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/regexp/formal/FormalRegExpAlternation.h b/alib2data/src/regexp/formal/FormalRegExpAlternation.h index 8fef555d35..31ce6bdf44 100644 --- a/alib2data/src/regexp/formal/FormalRegExpAlternation.h +++ b/alib2data/src/regexp/formal/FormalRegExpAlternation.h @@ -23,20 +23,20 @@ class RegExpOptimize; * Represents alternation operator in the regular expression. Contains list of FormalRegExpElement * as operands of the operator. */ -class FormalRegExpAlternation: public std::acceptor<FormalRegExpAlternation, FormalRegExpElement, FormalRegExpElement> { +class FormalRegExpAlternation : public std::acceptor < FormalRegExpAlternation, FormalRegExpElement, FormalRegExpElement > { protected: /** * @copydoc FormalRegExpElement::clone() const */ - virtual UnboundedRegExpElement* cloneAsUnbounded() const; + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; - FormalRegExpElement* left; - FormalRegExpElement* right; + FormalRegExpElement * left; + FormalRegExpElement * right; /** * @copydoc FormalRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc FormalRegExpElement::attachRegExp() @@ -46,70 +46,67 @@ protected: /** * @copydoc FormalRegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; public: - explicit FormalRegExpAlternation(FormalRegExpElement&& left, FormalRegExpElement&& right); - explicit FormalRegExpAlternation(const FormalRegExpElement& left, const FormalRegExpElement& right); + explicit FormalRegExpAlternation ( FormalRegExpElement && left, FormalRegExpElement && right ); + explicit FormalRegExpAlternation ( const FormalRegExpElement & left, const FormalRegExpElement & right ); - FormalRegExpAlternation(const FormalRegExpAlternation& other); - FormalRegExpAlternation(FormalRegExpAlternation&& other) noexcept; - FormalRegExpAlternation& operator =(const FormalRegExpAlternation& other); - FormalRegExpAlternation& operator =(FormalRegExpAlternation&& other) noexcept; + FormalRegExpAlternation ( const FormalRegExpAlternation & other ); + FormalRegExpAlternation ( FormalRegExpAlternation && other ) noexcept; + FormalRegExpAlternation & operator =( const FormalRegExpAlternation & other ); + FormalRegExpAlternation & operator =( FormalRegExpAlternation && other ) noexcept; + + virtual ~FormalRegExpAlternation ( ) noexcept; - virtual ~FormalRegExpAlternation() noexcept; /** * @copydoc FormalRegExpElement::clone() const */ - virtual FormalRegExpElement* clone() const; + virtual FormalRegExpElement * clone ( ) const; /** * @copydoc FormalRegExpElement::plunder() const */ - virtual FormalRegExpElement* plunder() &&; + virtual FormalRegExpElement * plunder ( ) &&; /** * @return elements */ - const FormalRegExpElement & getLeftElement() const; - const FormalRegExpElement & getRightElement() const; + const FormalRegExpElement & getLeftElement ( ) const; + const FormalRegExpElement & getRightElement ( ) const; /** * @return elements */ - FormalRegExpElement & getLeftElement(); - FormalRegExpElement & getRightElement(); + FormalRegExpElement & getLeftElement ( ); + FormalRegExpElement & getRightElement ( ); /** * @param element to append */ - void setLeftElement(const FormalRegExpElement& element); - void setLeftElement(FormalRegExpElement&& element); + void setLeftElement ( const FormalRegExpElement & element ); + void setLeftElement ( FormalRegExpElement && element ); /** * @param element to append */ - void setRightElement(const FormalRegExpElement& element); - void setRightElement(FormalRegExpElement&& element); + void setRightElement ( const FormalRegExpElement & element ); + void setRightElement ( FormalRegExpElement && element ); - virtual int compare(const FormalRegExpElement& other) const { - return FormalRegExpElement::compare(*this, other); + virtual int compare ( const FormalRegExpElement & other ) const { + return FormalRegExpElement::compare ( * this, other ); } - virtual int compare(const FormalRegExpAlternation&) const; + virtual int compare ( const FormalRegExpAlternation & ) const; /** * @copydoc FormalRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; friend class simplify::RegExpOptimize; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ diff --git a/alib2data/src/regexp/formal/FormalRegExpConcatenation.h b/alib2data/src/regexp/formal/FormalRegExpConcatenation.h index 91ae9b1c28..5f810727da 100644 --- a/alib2data/src/regexp/formal/FormalRegExpConcatenation.h +++ b/alib2data/src/regexp/formal/FormalRegExpConcatenation.h @@ -24,20 +24,20 @@ class RegExpOptimize; * Represents concatenation operator in the regular expression. Contains list of FormalRegExpElement * as operands of the operator. */ -class FormalRegExpConcatenation: public std::acceptor<FormalRegExpConcatenation, FormalRegExpElement, FormalRegExpElement> { +class FormalRegExpConcatenation : public std::acceptor < FormalRegExpConcatenation, FormalRegExpElement, FormalRegExpElement > { protected: /** * @copydoc FormalRegExpElement::clone() const */ - virtual UnboundedRegExpElement* cloneAsUnbounded() const; + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; - FormalRegExpElement* left; - FormalRegExpElement* right; + FormalRegExpElement * left; + FormalRegExpElement * right; /** * @copydoc FormalRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc FormalRegExpElement::attachRegExp() @@ -47,67 +47,63 @@ protected: /** * @copydoc FormalRegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; public: - explicit FormalRegExpConcatenation(FormalRegExpElement&& left, FormalRegExpElement&& right); - explicit FormalRegExpConcatenation(const FormalRegExpElement& left, const FormalRegExpElement& right); + explicit FormalRegExpConcatenation ( FormalRegExpElement && left, FormalRegExpElement && right ); + explicit FormalRegExpConcatenation ( const FormalRegExpElement & left, const FormalRegExpElement & right ); - FormalRegExpConcatenation(const FormalRegExpConcatenation& other); - FormalRegExpConcatenation(FormalRegExpConcatenation&& other) noexcept; - FormalRegExpConcatenation& operator =(const FormalRegExpConcatenation& other); - FormalRegExpConcatenation& operator =(FormalRegExpConcatenation&& other) noexcept; - virtual ~FormalRegExpConcatenation() noexcept; + FormalRegExpConcatenation ( const FormalRegExpConcatenation & other ); + FormalRegExpConcatenation ( FormalRegExpConcatenation && other ) noexcept; + FormalRegExpConcatenation & operator =( const FormalRegExpConcatenation & other ); + FormalRegExpConcatenation & operator =( FormalRegExpConcatenation && other ) noexcept; + virtual ~FormalRegExpConcatenation ( ) noexcept; /** * @copydoc FormalRegExpElement::clone() const */ - virtual FormalRegExpElement* clone() const; + virtual FormalRegExpElement * clone ( ) const; /** * @copydoc FormalRegExpElement::plunder() const */ - virtual FormalRegExpElement* plunder() &&; + virtual FormalRegExpElement * plunder ( ) &&; /** * @return elements */ - const FormalRegExpElement & getLeftElement() const; - const FormalRegExpElement & getRightElement() const; + const FormalRegExpElement & getLeftElement ( ) const; + const FormalRegExpElement & getRightElement ( ) const; /** * @return elements */ - FormalRegExpElement& getLeftElement(); - FormalRegExpElement& getRightElement(); + FormalRegExpElement & getLeftElement ( ); + FormalRegExpElement & getRightElement ( ); /** * @param element to append */ - void setLeftElement(const FormalRegExpElement& element); - void setLeftElement(FormalRegExpElement&& element); + void setLeftElement ( const FormalRegExpElement & element ); + void setLeftElement ( FormalRegExpElement && element ); - void setRightElement(const FormalRegExpElement& element); - void setRightElement(FormalRegExpElement&& element); + void setRightElement ( const FormalRegExpElement & element ); + void setRightElement ( FormalRegExpElement && element ); - virtual int compare(const FormalRegExpElement& other) const { - return FormalRegExpElement::compare(*this, other); + virtual int compare ( const FormalRegExpElement & other ) const { + return FormalRegExpElement::compare ( * this, other ); } - virtual int compare(const FormalRegExpConcatenation&) const; + virtual int compare ( const FormalRegExpConcatenation & ) const; /** * @copydoc FormalRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; friend class simplify::RegExpOptimize; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ diff --git a/alib2data/src/regexp/formal/FormalRegExpEmpty.h b/alib2data/src/regexp/formal/FormalRegExpEmpty.h index ad125beb62..4d6f365941 100644 --- a/alib2data/src/regexp/formal/FormalRegExpEmpty.h +++ b/alib2data/src/regexp/formal/FormalRegExpEmpty.h @@ -16,17 +16,17 @@ namespace regexp { /** * Represents empty regular expression in the regular expression. */ -class FormalRegExpEmpty: public std::acceptor<FormalRegExpEmpty, FormalRegExpElement, FormalRegExpElement> { +class FormalRegExpEmpty : public std::acceptor < FormalRegExpEmpty, FormalRegExpElement, FormalRegExpElement > { protected: /** * @copydoc FormalRegExpElement::clone() const */ - virtual UnboundedRegExpElement* cloneAsUnbounded() const; + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; /** * @copydoc FormalRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc FormalRegExpElement::attachRegExp() @@ -36,41 +36,37 @@ protected: /** * @copydoc RegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; public: - explicit FormalRegExpEmpty(); - FormalRegExpEmpty(const FormalRegExpEmpty& other); - FormalRegExpEmpty(FormalRegExpEmpty&& other) noexcept; - FormalRegExpEmpty& operator =(const FormalRegExpEmpty& other); - FormalRegExpEmpty& operator =(FormalRegExpEmpty&& other) noexcept; + explicit FormalRegExpEmpty ( ); + FormalRegExpEmpty ( const FormalRegExpEmpty & other ); + FormalRegExpEmpty ( FormalRegExpEmpty && other ) noexcept; + FormalRegExpEmpty & operator =( const FormalRegExpEmpty & other ); + FormalRegExpEmpty & operator =( FormalRegExpEmpty && other ) noexcept; /** * @copydoc FormalRegExpElement::clone() const */ - virtual FormalRegExpElement* clone() const; + virtual FormalRegExpElement * clone ( ) const; /** * @copydoc FormalRegExpElement::plunder() const */ - virtual FormalRegExpElement* plunder() &&; + virtual FormalRegExpElement * plunder ( ) &&; - virtual int compare(const FormalRegExpElement& other) const { - return FormalRegExpElement::compare(*this, other); + virtual int compare ( const FormalRegExpElement & other ) const { + return FormalRegExpElement::compare ( * this, other ); } - virtual int compare(const FormalRegExpEmpty&) const; + virtual int compare ( const FormalRegExpEmpty & ) const; /** * @copydoc FormalRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ diff --git a/alib2data/src/regexp/formal/FormalRegExpEpsilon.h b/alib2data/src/regexp/formal/FormalRegExpEpsilon.h index 94e662f493..fcb377cde1 100644 --- a/alib2data/src/regexp/formal/FormalRegExpEpsilon.h +++ b/alib2data/src/regexp/formal/FormalRegExpEpsilon.h @@ -16,17 +16,17 @@ namespace regexp { /** * Represents epsilon in the regular expression. */ -class FormalRegExpEpsilon: public std::acceptor<FormalRegExpEpsilon, FormalRegExpElement, FormalRegExpElement> { +class FormalRegExpEpsilon : public std::acceptor < FormalRegExpEpsilon, FormalRegExpElement, FormalRegExpElement > { protected: /** * @copydoc FormalRegExpElement::clone() const */ - virtual UnboundedRegExpElement* cloneAsUnbounded() const; + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; /** * @copydoc FormalRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc FormalRegExpElement::attachRegExp() @@ -36,42 +36,37 @@ protected: /** * @copydoc FormalRegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; public: - - explicit FormalRegExpEpsilon(); - FormalRegExpEpsilon(const FormalRegExpEpsilon& other); - FormalRegExpEpsilon(FormalRegExpEpsilon&& other) noexcept; - FormalRegExpEpsilon& operator=(const FormalRegExpEpsilon& other); - FormalRegExpEpsilon& operator=(FormalRegExpEpsilon&& other) noexcept; + explicit FormalRegExpEpsilon ( ); + FormalRegExpEpsilon ( const FormalRegExpEpsilon & other ); + FormalRegExpEpsilon ( FormalRegExpEpsilon && other ) noexcept; + FormalRegExpEpsilon & operator =( const FormalRegExpEpsilon & other ); + FormalRegExpEpsilon & operator =( FormalRegExpEpsilon && other ) noexcept; /** * @copydoc FormalRegExpElement::clone() const */ - virtual FormalRegExpElement* clone() const; + virtual FormalRegExpElement * clone ( ) const; /** * @copydoc FormalRegExpElement::plunder() const */ - virtual FormalRegExpElement* plunder() &&; + virtual FormalRegExpElement * plunder ( ) &&; - virtual int compare(const FormalRegExpElement& other) const { - return FormalRegExpElement::compare(*this, other); + virtual int compare ( const FormalRegExpElement & other ) const { + return FormalRegExpElement::compare ( * this, other ); } - virtual int compare(const FormalRegExpEpsilon&) const; + virtual int compare ( const FormalRegExpEpsilon & ) const; /** * @copydoc FormalRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; - - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & out ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ diff --git a/alib2data/src/regexp/formal/FormalRegExpIteration.h b/alib2data/src/regexp/formal/FormalRegExpIteration.h index accfe1e67b..5982116539 100644 --- a/alib2data/src/regexp/formal/FormalRegExpIteration.h +++ b/alib2data/src/regexp/formal/FormalRegExpIteration.h @@ -23,19 +23,19 @@ class RegExpOptimize; * Represents iteration operator in the regular expression. Contains one FormalRegExpElement * as operand. */ -class FormalRegExpIteration: public std::acceptor<FormalRegExpIteration, FormalRegExpElement, FormalRegExpElement> { +class FormalRegExpIteration : public std::acceptor < FormalRegExpIteration, FormalRegExpElement, FormalRegExpElement > { protected: - FormalRegExpElement* element; + FormalRegExpElement * element; /** * @copydoc FormalRegExpElement::clone() const */ - virtual UnboundedRegExpElement* cloneAsUnbounded() const; + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; /** * @copydoc FormalRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc FormalRegExpElement::attachRegExp() @@ -45,64 +45,59 @@ protected: /** * @copydoc FormalRegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; public: - explicit FormalRegExpIteration(FormalRegExpElement&&); - explicit FormalRegExpIteration(const FormalRegExpElement&); + explicit FormalRegExpIteration ( FormalRegExpElement && ); + explicit FormalRegExpIteration ( const FormalRegExpElement & ); - FormalRegExpIteration(const FormalRegExpIteration& other); - FormalRegExpIteration(FormalRegExpIteration&& other) noexcept; - FormalRegExpIteration& operator =(const FormalRegExpIteration& other); - FormalRegExpIteration& operator =(FormalRegExpIteration&& other) noexcept; - virtual ~FormalRegExpIteration() noexcept; + FormalRegExpIteration ( const FormalRegExpIteration & other ); + FormalRegExpIteration ( FormalRegExpIteration && other ) noexcept; + FormalRegExpIteration & operator =( const FormalRegExpIteration & other ); + FormalRegExpIteration & operator =( FormalRegExpIteration && other ) noexcept; + virtual ~FormalRegExpIteration ( ) noexcept; /** * @copydoc FormalRegExpElement::clone() const */ - virtual FormalRegExpElement* clone() const; + virtual FormalRegExpElement * clone ( ) const; /** * @copydoc FormalRegExpElement::plunder() const */ - virtual FormalRegExpElement* plunder() &&; - + virtual FormalRegExpElement * plunder ( ) &&; /** * @return element */ - const FormalRegExpElement & getElement() const; + const FormalRegExpElement & getElement ( ) const; /** * @return element */ - FormalRegExpElement & getElement(); + FormalRegExpElement & getElement ( ); /** * @param element to iterate */ - void setElement(const FormalRegExpElement& element); + void setElement ( const FormalRegExpElement & element ); - void setElement(FormalRegExpElement&& element); + void setElement ( FormalRegExpElement && element ); - virtual int compare(const FormalRegExpElement& other) const { - return FormalRegExpElement::compare(*this, other); + virtual int compare ( const FormalRegExpElement & other ) const { + return FormalRegExpElement::compare ( * this, other ); } - virtual int compare(const FormalRegExpIteration&) const; + virtual int compare ( const FormalRegExpIteration & ) const; /** * @copydoc FormalRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; friend class simplify::RegExpOptimize; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ diff --git a/alib2data/src/regexp/formal/FormalRegExpSymbol.h b/alib2data/src/regexp/formal/FormalRegExpSymbol.h index 16db376dc6..147048d47d 100644 --- a/alib2data/src/regexp/formal/FormalRegExpSymbol.h +++ b/alib2data/src/regexp/formal/FormalRegExpSymbol.h @@ -17,19 +17,19 @@ namespace regexp { /** * Represents symbol in the regular expression. Contains name of the symbol. */ -class FormalRegExpSymbol : public std::acceptor<FormalRegExpSymbol, FormalRegExpElement, FormalRegExpElement> { +class FormalRegExpSymbol : public std::acceptor < FormalRegExpSymbol, FormalRegExpElement, FormalRegExpElement > { protected: alphabet::Symbol symbol; /** * @copydoc FormalRegExpElement::clone() const */ - virtual UnboundedRegExpElement* cloneAsUnbounded() const; + virtual UnboundedRegExpElement * cloneAsUnbounded ( ) const; /** * @copydoc FormalRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc FormalRegExpElement::attachRegExp() @@ -39,58 +39,53 @@ protected: /** * @copydoc FormalRegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + public: - explicit FormalRegExpSymbol(int number); - explicit FormalRegExpSymbol(char character); - explicit FormalRegExpSymbol(const std::string& label); + explicit FormalRegExpSymbol ( int number ); + explicit FormalRegExpSymbol ( char character ); + explicit FormalRegExpSymbol ( const std::string & label ); - explicit FormalRegExpSymbol(const alphabet::Symbol& symbol); - explicit FormalRegExpSymbol(alphabet::Symbol&& symbol); + explicit FormalRegExpSymbol ( const alphabet::Symbol & symbol ); + explicit FormalRegExpSymbol ( alphabet::Symbol && symbol ); - FormalRegExpSymbol(const FormalRegExpSymbol& other); - FormalRegExpSymbol(FormalRegExpSymbol&& other) noexcept; - FormalRegExpSymbol& operator=(const FormalRegExpSymbol& other); - FormalRegExpSymbol& operator=(FormalRegExpSymbol&& other) noexcept; + FormalRegExpSymbol ( const FormalRegExpSymbol & other ); + FormalRegExpSymbol ( FormalRegExpSymbol && other ) noexcept; + FormalRegExpSymbol & operator =( const FormalRegExpSymbol & other ); + FormalRegExpSymbol & operator =( FormalRegExpSymbol && other ) noexcept; /** * @copydoc FormalRegExpElement::clone() const */ - virtual FormalRegExpElement* clone() const; + virtual FormalRegExpElement * clone ( ) const; /** * @copydoc FormalRegExpElement::plunder() const */ - virtual FormalRegExpElement* plunder() &&; - + virtual FormalRegExpElement * plunder ( ) &&; - bool operator==(const alphabet::Symbol&) const; - friend bool operator==(const alphabet::Symbol&, const FormalRegExpSymbol&); + bool operator ==( const alphabet::Symbol & ) const; + friend bool operator ==( const alphabet::Symbol &, const FormalRegExpSymbol & ); - virtual int compare(const FormalRegExpElement& other) const { - return FormalRegExpElement::compare(*this, other); + virtual int compare ( const FormalRegExpElement & other ) const { + return FormalRegExpElement::compare ( * this, other ); } - virtual int compare(const FormalRegExpSymbol&) const; + virtual int compare ( const FormalRegExpSymbol & ) const; /** * @copydoc FormalRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; /** * Returns the string representation of RegExp Symbol. */ - const alphabet::Symbol& getSymbol() const; - - virtual explicit operator std::string() const; + const alphabet::Symbol & getSymbol ( ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ #endif /* FORMAL_REG_EXP_SYMBOL_H_ */ - diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.h b/alib2data/src/regexp/unbounded/UnboundedRegExp.h index 4b005b4fce..8ad0e6978c 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.h @@ -27,104 +27,101 @@ class FormalRegExp; */ class UnboundedRegExp : public RegExpBase, public RegExpAlphabet { protected: - UnboundedRegExpElement* regExp; + UnboundedRegExpElement * regExp; public: /** * @copydoc UnboundedRegExpElement::clone() const */ - virtual RegExpBase* clone() const; + virtual RegExpBase * clone ( ) const; /** * @copydoc UnboundedRegExpElement::plunder() const */ - virtual RegExpBase* plunder() &&; + virtual RegExpBase * plunder ( ) &&; - explicit UnboundedRegExp(); - explicit UnboundedRegExp(const FormalRegExp& other); - explicit UnboundedRegExp(std::set<alphabet::Symbol> alphabet, const UnboundedRegExpElement& regExp); - explicit UnboundedRegExp(std::set<alphabet::Symbol> alphabet, UnboundedRegExpElement&& regExp); - explicit UnboundedRegExp(const UnboundedRegExpElement& regExp); - explicit UnboundedRegExp(UnboundedRegExpElement&& regExp); + explicit UnboundedRegExp ( ); + explicit UnboundedRegExp ( const FormalRegExp & other ); + explicit UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, const UnboundedRegExpElement & regExp ); + explicit UnboundedRegExp ( std::set < alphabet::Symbol > alphabet, UnboundedRegExpElement && regExp ); + explicit UnboundedRegExp ( const UnboundedRegExpElement & regExp ); + explicit UnboundedRegExp ( UnboundedRegExpElement && regExp ); /** * Copy constructor. * @param other RegExp to copy */ - UnboundedRegExp(const UnboundedRegExp& other); - UnboundedRegExp(UnboundedRegExp&& other) noexcept; - UnboundedRegExp& operator =(const UnboundedRegExp& other); - UnboundedRegExp& operator =(UnboundedRegExp&& other) noexcept; - ~UnboundedRegExp() noexcept; + UnboundedRegExp ( const UnboundedRegExp & other ); + UnboundedRegExp ( UnboundedRegExp && other ) noexcept; + UnboundedRegExp & operator =( const UnboundedRegExp & other ); + UnboundedRegExp & operator =( UnboundedRegExp && other ) noexcept; + ~UnboundedRegExp ( ) noexcept; /** * @return Root node of the regular expression tree */ - const UnboundedRegExpElement& getRegExp() const; + const UnboundedRegExpElement & getRegExp ( ) const; /** * @return Root node of the regular expression tree */ - UnboundedRegExpElement& getRegExp(); + UnboundedRegExpElement & getRegExp ( ); /** * Sets the root node of the regular expression tree. Doesn't perform copy of the regExp param, * just stores it! * @param regExp root node to set */ - void setRegExp(const UnboundedRegExpElement& regExp); + void setRegExp ( const UnboundedRegExpElement & regExp ); /** * Sets the root node of the regular expression tree * @param regExp root node to set */ - void setRegExp(UnboundedRegExpElement&& regExp); + void setRegExp ( UnboundedRegExpElement && regExp ); - virtual const std::set<alphabet::Symbol>& getAlphabet() const { - return RegExpAlphabet::getAlphabet(); + virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const { + return RegExpAlphabet::getAlphabet ( ); } /** * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet(const alphabet::Symbol & symbol); + bool removeSymbolFromAlphabet ( const alphabet::Symbol & symbol ); /** * Prints XML representation of the RegExp to the output stream. * @param out output stream to which print the RegExp * @param regexp RegExp to print */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const UnboundedRegExp& other) const; + virtual int compare ( const UnboundedRegExp & other ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static UnboundedRegExp parse(std::deque<sax::Token>::iterator& input); + static UnboundedRegExp parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace regexp */ namespace std { -template<> -struct compare<regexp::UnboundedRegExp> { - int operator()(const regexp::UnboundedRegExp& first, const regexp::UnboundedRegExp& second) const { - return first.compare(second); +template < > +struct compare < regexp::UnboundedRegExp > { + int operator ()( const regexp::UnboundedRegExp & first, const regexp::UnboundedRegExp & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h b/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h index 72e29dd86f..80d8ca068a 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h @@ -23,19 +23,19 @@ class RegExpOptimize; * Represents alternation operator in the regular expression. Contains list of UnboundedRegExpElement * as operands of the operator. */ -class UnboundedRegExpAlternation: public std::acceptor<UnboundedRegExpAlternation, UnboundedRegExpElement, UnboundedRegExpElement> { +class UnboundedRegExpAlternation : public std::acceptor < UnboundedRegExpAlternation, UnboundedRegExpElement, UnboundedRegExpElement > { protected: /** * @copydoc UnboundedRegExpElement::cloneAsFormal() const */ - virtual FormalRegExpElement* cloneAsFormal() const; + virtual FormalRegExpElement * cloneAsFormal ( ) const; - std::vector<UnboundedRegExpElement*> elements; + std::vector < UnboundedRegExpElement * > elements; /** * @copydoc UnboundedRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc UnboundedRegExpElement::attachRegExp() @@ -45,65 +45,61 @@ protected: /** * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; public: - explicit UnboundedRegExpAlternation(); + explicit UnboundedRegExpAlternation ( ); - UnboundedRegExpAlternation(const UnboundedRegExpAlternation& other); - UnboundedRegExpAlternation(UnboundedRegExpAlternation&& other) noexcept; - UnboundedRegExpAlternation& operator =(const UnboundedRegExpAlternation& other); - UnboundedRegExpAlternation& operator =(UnboundedRegExpAlternation&& other) noexcept; - virtual ~UnboundedRegExpAlternation() noexcept; + UnboundedRegExpAlternation ( const UnboundedRegExpAlternation & other ); + UnboundedRegExpAlternation ( UnboundedRegExpAlternation && other ) noexcept; + UnboundedRegExpAlternation & operator =( const UnboundedRegExpAlternation & other ); + UnboundedRegExpAlternation & operator =( UnboundedRegExpAlternation && other ) noexcept; + virtual ~UnboundedRegExpAlternation ( ) noexcept; /** * @copydoc UnboundedRegExpElement::clone() const */ - virtual UnboundedRegExpElement* clone() const; + virtual UnboundedRegExpElement * clone ( ) const; /** * @copydoc UnboundedRegExpElement::plunder() const */ - virtual UnboundedRegExpElement* plunder() &&; + virtual UnboundedRegExpElement * plunder ( ) &&; /** * @return elements */ - const std::vector<const UnboundedRegExpElement*> & getElements() const; + const std::vector < const UnboundedRegExpElement * > & getElements ( ) const; /** * @return elements */ - const std::vector<UnboundedRegExpElement*> & getElements(); + const std::vector < UnboundedRegExpElement * > & getElements ( ); /** * @param element to append */ - void appendElement(const UnboundedRegExpElement& element); + void appendElement ( const UnboundedRegExpElement & element ); /** * @param element to append */ - void appendElement(UnboundedRegExpElement&& element); + void appendElement ( UnboundedRegExpElement && element ); - virtual int compare(const UnboundedRegExpElement& other) const { - return UnboundedRegExpElement::compare(*this, other); + virtual int compare ( const UnboundedRegExpElement & other ) const { + return UnboundedRegExpElement::compare ( * this, other ); } - virtual int compare(const UnboundedRegExpAlternation&) const; + virtual int compare ( const UnboundedRegExpAlternation & ) const; /** * @copydoc UnboundedRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; friend class simplify::RegExpOptimize; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h b/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h index 5d5069fb0b..31ffa7e6e3 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h @@ -23,20 +23,19 @@ class RegExpOptimize; * Represents concatenation operator in the regular expression. Contains list of UnboundedRegExpElement * as operands of the operator. */ -class UnboundedRegExpConcatenation: public std::acceptor<UnboundedRegExpConcatenation, UnboundedRegExpElement, UnboundedRegExpElement> { +class UnboundedRegExpConcatenation : public std::acceptor < UnboundedRegExpConcatenation, UnboundedRegExpElement, UnboundedRegExpElement > { protected: /** * @copydoc UnboundedRegExpElement::cloneAsFormal() const */ - virtual FormalRegExpElement* cloneAsFormal() const; + virtual FormalRegExpElement * cloneAsFormal ( ) const; - - std::vector<UnboundedRegExpElement*> elements; + std::vector < UnboundedRegExpElement * > elements; /** * @copydoc UnboundedRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc UnboundedRegExpElement::attachRegExp() @@ -46,63 +45,58 @@ protected: /** * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; public: - explicit UnboundedRegExpConcatenation(); + explicit UnboundedRegExpConcatenation ( ); - UnboundedRegExpConcatenation(const UnboundedRegExpConcatenation& other); - UnboundedRegExpConcatenation(UnboundedRegExpConcatenation&& other) noexcept; - UnboundedRegExpConcatenation& operator =(const UnboundedRegExpConcatenation& other); - UnboundedRegExpConcatenation& operator =(UnboundedRegExpConcatenation&& other) noexcept; - virtual ~UnboundedRegExpConcatenation() noexcept; + UnboundedRegExpConcatenation ( const UnboundedRegExpConcatenation & other ); + UnboundedRegExpConcatenation ( UnboundedRegExpConcatenation && other ) noexcept; + UnboundedRegExpConcatenation & operator =( const UnboundedRegExpConcatenation & other ); + UnboundedRegExpConcatenation & operator =( UnboundedRegExpConcatenation && other ) noexcept; + virtual ~UnboundedRegExpConcatenation ( ) noexcept; /** * @copydoc UnboundedRegExpElement::clone() const */ - virtual UnboundedRegExpElement* clone() const; + virtual UnboundedRegExpElement * clone ( ) const; /** * @copydoc UnboundedRegExpElement::plunder() const */ - virtual UnboundedRegExpElement* plunder() &&; - + virtual UnboundedRegExpElement * plunder ( ) &&; /** * @return elements */ - const std::vector<const UnboundedRegExpElement*> & getElements() const; + const std::vector < const UnboundedRegExpElement * > & getElements ( ) const; /** * @return elements */ - const std::vector<UnboundedRegExpElement*> & getElements(); + const std::vector < UnboundedRegExpElement * > & getElements ( ); /** * @param element to append */ - void appendElement(const UnboundedRegExpElement& element); + void appendElement ( const UnboundedRegExpElement & element ); - void appendElement(UnboundedRegExpElement&& element); + void appendElement ( UnboundedRegExpElement && element ); - virtual int compare(const UnboundedRegExpElement& other) const { - return UnboundedRegExpElement::compare(*this, other); + virtual int compare ( const UnboundedRegExpElement & other ) const { + return UnboundedRegExpElement::compare ( * this, other ); } - virtual int compare(const UnboundedRegExpConcatenation&) const; + virtual int compare ( const UnboundedRegExpConcatenation & ) const; /** * @copydoc UnboundedRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; friend class simplify::RegExpOptimize; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h b/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h index 76d0f614df..d24dcc032c 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h @@ -15,17 +15,17 @@ namespace regexp { /** * Represents empty regular expression in the regular expression. */ -class UnboundedRegExpEmpty: public std::acceptor<UnboundedRegExpEmpty, UnboundedRegExpElement, UnboundedRegExpElement> { +class UnboundedRegExpEmpty : public std::acceptor < UnboundedRegExpEmpty, UnboundedRegExpElement, UnboundedRegExpElement > { protected: /** * @copydoc UnboundedRegExpElement::cloneAsFormal() const */ - virtual FormalRegExpElement* cloneAsFormal() const; + virtual FormalRegExpElement * cloneAsFormal ( ) const; /** * @copydoc UnboundedRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc UnboundedRegExpElement::attachRegExp() @@ -35,41 +35,37 @@ protected: /** * @copydoc RegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; public: - explicit UnboundedRegExpEmpty(); - UnboundedRegExpEmpty(const UnboundedRegExpEmpty& other); - UnboundedRegExpEmpty(UnboundedRegExpEmpty&& other) noexcept; - UnboundedRegExpEmpty& operator =(const UnboundedRegExpEmpty& other); - UnboundedRegExpEmpty& operator =(UnboundedRegExpEmpty&& other) noexcept; + explicit UnboundedRegExpEmpty ( ); + UnboundedRegExpEmpty ( const UnboundedRegExpEmpty & other ); + UnboundedRegExpEmpty ( UnboundedRegExpEmpty && other ) noexcept; + UnboundedRegExpEmpty & operator =( const UnboundedRegExpEmpty & other ); + UnboundedRegExpEmpty & operator =( UnboundedRegExpEmpty && other ) noexcept; /** * @copydoc UnboundedRegExpElement::clone() const */ - virtual UnboundedRegExpElement* clone() const; + virtual UnboundedRegExpElement * clone ( ) const; /** * @copydoc UnboundedRegExpElement::plunder() const */ - virtual UnboundedRegExpElement* plunder() &&; + virtual UnboundedRegExpElement * plunder ( ) &&; - virtual int compare(const UnboundedRegExpElement& other) const { - return UnboundedRegExpElement::compare(*this, other); + virtual int compare ( const UnboundedRegExpElement & other ) const { + return UnboundedRegExpElement::compare ( * this, other ); } - virtual int compare(const UnboundedRegExpEmpty&) const; + virtual int compare ( const UnboundedRegExpEmpty & ) const; /** * @copydoc UnboundedRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h b/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h index 4b96f95c74..bd0cfefee1 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h @@ -15,17 +15,17 @@ namespace regexp { /** * Represents epsilon in the regular expression. */ -class UnboundedRegExpEpsilon: public std::acceptor<UnboundedRegExpEpsilon, UnboundedRegExpElement, UnboundedRegExpElement> { +class UnboundedRegExpEpsilon : public std::acceptor < UnboundedRegExpEpsilon, UnboundedRegExpElement, UnboundedRegExpElement > { protected: /** * @copydoc UnboundedRegExpElement::cloneAsFormal() const */ - virtual FormalRegExpElement* cloneAsFormal() const; + virtual FormalRegExpElement * cloneAsFormal ( ) const; /** * @copydoc UnboundedRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc UnboundedRegExpElement::attachRegExp() @@ -35,42 +35,37 @@ protected: /** * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; public: - - explicit UnboundedRegExpEpsilon(); - UnboundedRegExpEpsilon(const UnboundedRegExpEpsilon& other); - UnboundedRegExpEpsilon(UnboundedRegExpEpsilon&& other) noexcept; - UnboundedRegExpEpsilon& operator=(const UnboundedRegExpEpsilon& other); - UnboundedRegExpEpsilon& operator=(UnboundedRegExpEpsilon&& other) noexcept; + explicit UnboundedRegExpEpsilon ( ); + UnboundedRegExpEpsilon ( const UnboundedRegExpEpsilon & other ); + UnboundedRegExpEpsilon ( UnboundedRegExpEpsilon && other ) noexcept; + UnboundedRegExpEpsilon & operator =( const UnboundedRegExpEpsilon & other ); + UnboundedRegExpEpsilon & operator =( UnboundedRegExpEpsilon && other ) noexcept; /** * @copydoc UnboundedRegExpElement::clone() const */ - virtual UnboundedRegExpElement* clone() const; + virtual UnboundedRegExpElement * clone ( ) const; /** * @copydoc UnboundedRegExpElement::plunder() const */ - virtual UnboundedRegExpElement* plunder() &&; + virtual UnboundedRegExpElement * plunder ( ) &&; - virtual int compare(const UnboundedRegExpElement& other) const { - return UnboundedRegExpElement::compare(*this, other); + virtual int compare ( const UnboundedRegExpElement & other ) const { + return UnboundedRegExpElement::compare ( * this, other ); } - virtual int compare(const UnboundedRegExpEpsilon&) const; + virtual int compare ( const UnboundedRegExpEpsilon & ) const; /** * @copydoc UnboundedRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; - - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & out ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h b/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h index fe069d0e47..565635aaa0 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h @@ -23,19 +23,19 @@ class RegExpOptimize; * Represents iteration operator in the regular expression. Contains one UnboundedRegExpElement * as operand. */ -class UnboundedRegExpIteration: public std::acceptor<UnboundedRegExpIteration, UnboundedRegExpElement, UnboundedRegExpElement> { +class UnboundedRegExpIteration : public std::acceptor < UnboundedRegExpIteration, UnboundedRegExpElement, UnboundedRegExpElement > { protected: - UnboundedRegExpElement* element; + UnboundedRegExpElement * element; /** * @copydoc UnboundedRegExpElement::cloneAsFormal() const */ - virtual FormalRegExpElement* cloneAsFormal() const; + virtual FormalRegExpElement * cloneAsFormal ( ) const; /** * @copydoc UnboundedRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc UnboundedRegExpElement::attachRegExp() @@ -45,63 +45,59 @@ protected: /** * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; public: - explicit UnboundedRegExpIteration(UnboundedRegExpElement&&); - explicit UnboundedRegExpIteration(const UnboundedRegExpElement&); + explicit UnboundedRegExpIteration ( UnboundedRegExpElement && ); + explicit UnboundedRegExpIteration ( const UnboundedRegExpElement & ); - UnboundedRegExpIteration(const UnboundedRegExpIteration& other); - UnboundedRegExpIteration(UnboundedRegExpIteration&& other) noexcept; - UnboundedRegExpIteration& operator =(const UnboundedRegExpIteration& other); - UnboundedRegExpIteration& operator =(UnboundedRegExpIteration&& other) noexcept; - virtual ~UnboundedRegExpIteration() noexcept; + UnboundedRegExpIteration ( const UnboundedRegExpIteration & other ); + UnboundedRegExpIteration ( UnboundedRegExpIteration && other ) noexcept; + UnboundedRegExpIteration & operator =( const UnboundedRegExpIteration & other ); + UnboundedRegExpIteration & operator =( UnboundedRegExpIteration && other ) noexcept; + virtual ~UnboundedRegExpIteration ( ) noexcept; /** * @copydoc UnboundedRegExpElement::clone() const */ - virtual UnboundedRegExpElement* clone() const; + virtual UnboundedRegExpElement * clone ( ) const; /** * @copydoc UnboundedRegExpElement::plunder() const */ - virtual UnboundedRegExpElement* plunder() &&; + virtual UnboundedRegExpElement * plunder ( ) &&; /** * @return element */ - const UnboundedRegExpElement & getElement() const; + const UnboundedRegExpElement & getElement ( ) const; /** * @return element */ - UnboundedRegExpElement & getElement(); + UnboundedRegExpElement & getElement ( ); /** * @param element to iterate */ - void setElement(const UnboundedRegExpElement& element); + void setElement ( const UnboundedRegExpElement & element ); - void setElement(UnboundedRegExpElement&& element); + void setElement ( UnboundedRegExpElement && element ); - virtual int compare(const UnboundedRegExpElement& other) const { - return UnboundedRegExpElement::compare(*this, other); + virtual int compare ( const UnboundedRegExpElement & other ) const { + return UnboundedRegExpElement::compare ( * this, other ); } - virtual int compare(const UnboundedRegExpIteration&) const; + virtual int compare ( const UnboundedRegExpIteration & ) const; /** * @copydoc UnboundedRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; friend class simplify::RegExpOptimize; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h b/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h index 75023a7c9a..94e4ae15b3 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h @@ -17,19 +17,19 @@ namespace regexp { /** * Represents symbol in the regular expression. Contains name of the symbol. */ -class UnboundedRegExpSymbol : public std::acceptor<UnboundedRegExpSymbol, UnboundedRegExpElement, UnboundedRegExpElement> { +class UnboundedRegExpSymbol : public std::acceptor < UnboundedRegExpSymbol, UnboundedRegExpElement, UnboundedRegExpElement > { protected: alphabet::Symbol symbol; /** * @copydoc UnboundedRegExpElement::cloneAsFormal() const */ - virtual FormalRegExpElement* cloneAsFormal() const; + virtual FormalRegExpElement * cloneAsFormal ( ) const; /** * @copydoc UnboundedRegExpElement::testSymbol() const */ - virtual bool testSymbol( const alphabet::Symbol & symbol ) const; + virtual bool testSymbol ( const alphabet::Symbol & symbol ) const; /** * @copydoc UnboundedRegExpElement::attachRegExp() @@ -39,57 +39,53 @@ protected: /** * @copydoc UnboundedRegExpElement::computeMinimalAlphabet() */ - virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const; + virtual void computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const; + public: - explicit UnboundedRegExpSymbol(int number); - explicit UnboundedRegExpSymbol(char character); - explicit UnboundedRegExpSymbol(const std::string& label); + explicit UnboundedRegExpSymbol ( int number ); + explicit UnboundedRegExpSymbol ( char character ); + explicit UnboundedRegExpSymbol ( const std::string & label ); - explicit UnboundedRegExpSymbol(const alphabet::Symbol& symbol); - explicit UnboundedRegExpSymbol(alphabet::Symbol&& symbol); + explicit UnboundedRegExpSymbol ( const alphabet::Symbol & symbol ); + explicit UnboundedRegExpSymbol ( alphabet::Symbol && symbol ); - UnboundedRegExpSymbol(const UnboundedRegExpSymbol& other); - UnboundedRegExpSymbol(UnboundedRegExpSymbol&& other) noexcept; - UnboundedRegExpSymbol& operator=(const UnboundedRegExpSymbol& other); - UnboundedRegExpSymbol& operator=(UnboundedRegExpSymbol&& other) noexcept; + UnboundedRegExpSymbol ( const UnboundedRegExpSymbol & other ); + UnboundedRegExpSymbol ( UnboundedRegExpSymbol && other ) noexcept; + UnboundedRegExpSymbol & operator =( const UnboundedRegExpSymbol & other ); + UnboundedRegExpSymbol & operator =( UnboundedRegExpSymbol && other ) noexcept; /** * @copydoc UnboundedRegExpElement::clone() const */ - virtual UnboundedRegExpElement* clone() const; + virtual UnboundedRegExpElement * clone ( ) const; /** * @copydoc UnboundedRegExpElement::plunder() const */ - virtual UnboundedRegExpElement* plunder() &&; + virtual UnboundedRegExpElement * plunder ( ) &&; - bool operator==(const alphabet::Symbol&) const; - friend bool operator==(const alphabet::Symbol&, const UnboundedRegExpSymbol&); + bool operator ==( const alphabet::Symbol & ) const; + friend bool operator ==( const alphabet::Symbol &, const UnboundedRegExpSymbol & ); - virtual int compare(const UnboundedRegExpElement& other) const { - return UnboundedRegExpElement::compare(*this, other); + virtual int compare ( const UnboundedRegExpElement & other ) const { + return UnboundedRegExpElement::compare ( * this, other ); } - virtual int compare(const UnboundedRegExpSymbol&) const; + virtual int compare ( const UnboundedRegExpSymbol & ) const; /** * @copydoc UnboundedRegExpElement::operator>>() const */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; /** * Returns the string representation of RegExp Symbol. */ - const alphabet::Symbol& getSymbol() const; - - virtual explicit operator std::string() const; + const alphabet::Symbol & getSymbol ( ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; }; } /* namespace regexp */ #endif /* UNBOUNDED_REG_EXP_SYMBOL_H_ */ - diff --git a/alib2data/src/string/CyclicString.h b/alib2data/src/string/CyclicString.h index a491125a3c..89f7bb52d9 100644 --- a/alib2data/src/string/CyclicString.h +++ b/alib2data/src/string/CyclicString.h @@ -24,69 +24,66 @@ namespace string { * as a tree of CyclicStringElement. */ class CyclicString : public StringBase, public StringAlphabet { - std::vector<alphabet::Symbol> m_Data; + std::vector < alphabet::Symbol > m_Data; + public: - explicit CyclicString(); - explicit CyclicString(std::set<alphabet::Symbol> alphabet, std::vector<alphabet::Symbol> data); - explicit CyclicString(std::vector<alphabet::Symbol> data); - explicit CyclicString(const std::string& string); - explicit CyclicString(const char* string); - explicit CyclicString(const Epsilon& epsilon); - - virtual StringBase* clone() const; - virtual StringBase* plunder() &&; - - virtual const std::set<alphabet::Symbol>& getAlphabet() const { - return StringAlphabet::getAlphabet(); + explicit CyclicString ( ); + explicit CyclicString ( std::set < alphabet::Symbol > alphabet, std::vector < alphabet::Symbol > data ); + explicit CyclicString ( std::vector < alphabet::Symbol > data ); + explicit CyclicString ( const std::string & string ); + explicit CyclicString ( const char * string ); + explicit CyclicString ( const Epsilon & epsilon ); + + virtual StringBase * clone ( ) const; + virtual StringBase * plunder ( ) &&; + + virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const { + return StringAlphabet::getAlphabet ( ); } - virtual bool removeSymbolFromAlphabet(const alphabet::Symbol & symbol); + virtual bool removeSymbolFromAlphabet ( const alphabet::Symbol & symbol ); /** * @return List of symbols forming string (const version). */ - const std::vector<alphabet::Symbol>& getContent() const; + const std::vector < alphabet::Symbol > & getContent ( ) const; - void setContent(std::vector<alphabet::Symbol> data); + void setContent ( std::vector < alphabet::Symbol > data ); /** * @return true if string is an empty word (vector length is 0) */ - bool isEmpty() const; + bool isEmpty ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const CyclicString& other) const; - - virtual void operator >>(std::ostream& out) const; + virtual int compare ( const CyclicString & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & out ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static CyclicString parse(std::deque<sax::Token>::iterator& input); + static CyclicString parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace string */ namespace std { -template<> -struct compare<::string::CyclicString> { - int operator()(const ::string::CyclicString& first, const ::string::CyclicString& second) const { - return first.compare(second); +template < > +struct compare < ::string::CyclicString > { + int operator ()( const::string::CyclicString & first, const::string::CyclicString & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* CYCLIC_STRING_H_ */ - diff --git a/alib2data/src/string/Epsilon.h b/alib2data/src/string/Epsilon.h index 9ed52e012d..127b170572 100644 --- a/alib2data/src/string/Epsilon.h +++ b/alib2data/src/string/Epsilon.h @@ -24,64 +24,60 @@ namespace string { */ class Epsilon : public StringBase, public StringAlphabet { public: - Epsilon(); + Epsilon ( ); - Epsilon(std::set<alphabet::Symbol> alphabet); + Epsilon ( std::set < alphabet::Symbol > alphabet ); - virtual StringBase* clone() const; - virtual StringBase* plunder() &&; + virtual StringBase * clone ( ) const; + virtual StringBase * plunder ( ) &&; - virtual const std::set<alphabet::Symbol>& getAlphabet() const { - return StringAlphabet::getAlphabet(); + virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const { + return StringAlphabet::getAlphabet ( ); } - virtual bool removeSymbolFromAlphabet(const alphabet::Symbol & symbol); + virtual bool removeSymbolFromAlphabet ( const alphabet::Symbol & symbol ); /** * @return List of symbols forming string (const version). */ - std::vector<alphabet::Symbol> getContent() const; + std::vector < alphabet::Symbol > getContent ( ) const; /** * @return true */ - bool isEmpty() const; + bool isEmpty ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const Epsilon& other) const; + virtual int compare ( const Epsilon & other ) const; - virtual void operator >>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string() const; + virtual explicit operator std::string ( ) const; static Epsilon EPSILON; - virtual long long selfTypeId() const { - return typeId(*this); - } - const static std::string XML_TAG_NAME; - static Epsilon parse(std::deque<sax::Token>::iterator& input); + static Epsilon parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace string */ namespace std { -template<> -struct compare<::string::Epsilon> { - int operator()(const ::string::Epsilon& first, const ::string::Epsilon& second) const { - return first.compare(second); +template < > +struct compare < ::string::Epsilon > { + int operator ()( const::string::Epsilon & first, const::string::Epsilon & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* EPSILON_H_ */ - diff --git a/alib2data/src/string/LinearString.h b/alib2data/src/string/LinearString.h index 2c1e6a4da7..54b80e9af2 100644 --- a/alib2data/src/string/LinearString.h +++ b/alib2data/src/string/LinearString.h @@ -26,76 +26,72 @@ namespace string { * as a tree of LinearStringElement. */ class LinearString : public StringBase, public StringAlphabet { - std::vector<alphabet::Symbol> m_Data; + std::vector < alphabet::Symbol > m_Data; public: - explicit LinearString(); - explicit LinearString(const tree::PrefixRankedTree& tree); - explicit LinearString(std::set<alphabet::Symbol> alphabet, std::vector<alphabet::Symbol> data); - explicit LinearString(std::vector<alphabet::Symbol> data); - explicit LinearString(const std::string& string); - explicit LinearString(const char* string); - explicit LinearString(const Epsilon& epsilon); - - virtual StringBase* clone() const; - virtual StringBase* plunder() &&; - - virtual const std::set<alphabet::Symbol>& getAlphabet() const { - return StringAlphabet::getAlphabet(); + explicit LinearString ( ); + explicit LinearString ( const tree::PrefixRankedTree & tree ); + explicit LinearString ( std::set < alphabet::Symbol > alphabet, std::vector < alphabet::Symbol > data ); + explicit LinearString ( std::vector < alphabet::Symbol > data ); + explicit LinearString ( const std::string & string ); + explicit LinearString ( const char * string ); + explicit LinearString ( const Epsilon & epsilon ); + + virtual StringBase * clone ( ) const; + virtual StringBase * plunder ( ) &&; + + virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const { + return StringAlphabet::getAlphabet ( ); } - virtual bool removeSymbolFromAlphabet(const alphabet::Symbol & symbol); + virtual bool removeSymbolFromAlphabet ( const alphabet::Symbol & symbol ); /** * @param element to append */ - void appendSymbol(alphabet::Symbol symbol); + void appendSymbol ( alphabet::Symbol symbol ); /** * @return List of symbols forming string (const version). */ - const std::vector<alphabet::Symbol>& getContent() const; + const std::vector < alphabet::Symbol > & getContent ( ) const; - void setContent(std::vector<alphabet::Symbol> data); + void setContent ( std::vector < alphabet::Symbol > data ); /** * @return true if string is an empty word (vector length is 0) */ - bool isEmpty() const; + bool isEmpty ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const LinearString& other) const; + virtual int compare ( const LinearString & other ) const; - virtual void operator >>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static LinearString parse(std::deque<sax::Token>::iterator& input); + static LinearString parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace string */ namespace std { -template<> -struct compare<::string::LinearString> { - int operator()(const ::string::LinearString& first, const ::string::LinearString& second) const { - return first.compare(second); +template < > +struct compare < ::string::LinearString > { + int operator ()( const::string::LinearString & first, const::string::LinearString & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* LINEAR_STRING_H_ */ - diff --git a/alib2data/src/tree/ranked/PrefixRankedBarPattern.h b/alib2data/src/tree/ranked/PrefixRankedBarPattern.h index 65edc24798..436effaad7 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedBarPattern.h @@ -25,73 +25,70 @@ class RankedPattern; * as a tree of LinearStringElement. */ class PrefixRankedBarPattern : public TreeBase, public RankedPatternAlphabet { - std::vector<alphabet::RankedSymbol> m_Data; + std::vector < alphabet::RankedSymbol > m_Data; alphabet::Symbol bar; alphabet::Symbol variablesBar; public: - explicit PrefixRankedBarPattern(alphabet::Symbol bar, alphabet::Symbol variablesBar, alphabet::RankedSymbol subtreeWildcard, std::set<alphabet::RankedSymbol> alphabet, std::vector<alphabet::RankedSymbol> data); - explicit PrefixRankedBarPattern(alphabet::Symbol bar, alphabet::Symbol variablesBar, alphabet::RankedSymbol subtreeWildcard, std::vector<alphabet::RankedSymbol> data); - explicit PrefixRankedBarPattern(alphabet::Symbol bar, alphabet::Symbol variablesBar, const RankedPattern& tree); + explicit PrefixRankedBarPattern ( alphabet::Symbol bar, alphabet::Symbol variablesBar, alphabet::RankedSymbol subtreeWildcard, std::set < alphabet::RankedSymbol > alphabet, std::vector < alphabet::RankedSymbol > data ); + explicit PrefixRankedBarPattern ( alphabet::Symbol bar, alphabet::Symbol variablesBar, alphabet::RankedSymbol subtreeWildcard, std::vector < alphabet::RankedSymbol > data ); + explicit PrefixRankedBarPattern ( alphabet::Symbol bar, alphabet::Symbol variablesBar, const RankedPattern & tree ); - void toPrefixRankedBar(const RankedNode& node); + void toPrefixRankedBar ( const RankedNode & node ); - virtual TreeBase* clone() const; - virtual TreeBase* plunder() &&; + virtual TreeBase * clone ( ) const; + virtual TreeBase * plunder ( ) &&; - virtual bool removeSymbolFromAlphabet(const alphabet::RankedSymbol & symbol); + virtual bool removeSymbolFromAlphabet ( const alphabet::RankedSymbol & symbol ); /** * @return List of symbols forming tree (const version). */ - const std::vector<alphabet::RankedSymbol>& getContent() const; + const std::vector < alphabet::RankedSymbol > & getContent ( ) const; - void setContent(std::vector<alphabet::RankedSymbol> data); + void setContent ( std::vector < alphabet::RankedSymbol > data ); - const alphabet::Symbol& getBarSymbol() const; + const alphabet::Symbol & getBarSymbol ( ) const; - const alphabet::Symbol& getVariablesBarSymbol() const; + const alphabet::Symbol & getVariablesBarSymbol ( ) const; + + void arityChecksum ( const std::vector < alphabet::RankedSymbol > & data ); - void arityChecksum(const std::vector<alphabet::RankedSymbol>& data); /** * @return true if tree is an empty word (vector length is 0) */ - bool isEmpty() const; + bool isEmpty ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const PrefixRankedBarPattern& other) const; - - virtual void operator >>(std::ostream& out) const; + virtual int compare ( const PrefixRankedBarPattern & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & out ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static PrefixRankedBarPattern parse(std::deque<sax::Token>::iterator& input); + static PrefixRankedBarPattern parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace tree */ namespace std { -template<> -struct compare<::tree::PrefixRankedBarPattern> { - int operator()(const ::tree::PrefixRankedBarPattern& first, const ::tree::PrefixRankedBarPattern& second) const { - return first.compare(second); +template < > +struct compare < ::tree::PrefixRankedBarPattern > { + int operator ()( const::tree::PrefixRankedBarPattern & first, const::tree::PrefixRankedBarPattern & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* PREFIX_RANKED_BAR_PATTERN_H_ */ - diff --git a/alib2data/src/tree/ranked/PrefixRankedBarTree.h b/alib2data/src/tree/ranked/PrefixRankedBarTree.h index c8b5891a64..2939998975 100644 --- a/alib2data/src/tree/ranked/PrefixRankedBarTree.h +++ b/alib2data/src/tree/ranked/PrefixRankedBarTree.h @@ -25,70 +25,67 @@ class RankedTree; * as a tree of LinearStringElement. */ class PrefixRankedBarTree : public TreeBase, public RankedAlphabet { - std::vector<alphabet::RankedSymbol> m_Data; + std::vector < alphabet::RankedSymbol > m_Data; alphabet::Symbol bar; public: - explicit PrefixRankedBarTree(alphabet::Symbol bar, std::set<alphabet::RankedSymbol> alphabet, std::vector<alphabet::RankedSymbol> data); - explicit PrefixRankedBarTree(alphabet::Symbol bar, std::vector<alphabet::RankedSymbol> data); - explicit PrefixRankedBarTree(alphabet::Symbol bar, const RankedTree& tree); + explicit PrefixRankedBarTree ( alphabet::Symbol bar, std::set < alphabet::RankedSymbol > alphabet, std::vector < alphabet::RankedSymbol > data ); + explicit PrefixRankedBarTree ( alphabet::Symbol bar, std::vector < alphabet::RankedSymbol > data ); + explicit PrefixRankedBarTree ( alphabet::Symbol bar, const RankedTree & tree ); - void toPrefixRankedBar(const RankedNode& node); + void toPrefixRankedBar ( const RankedNode & node ); - virtual TreeBase* clone() const; - virtual TreeBase* plunder() &&; + virtual TreeBase * clone ( ) const; + virtual TreeBase * plunder ( ) &&; - virtual bool removeSymbolFromAlphabet(const alphabet::RankedSymbol & symbol); + virtual bool removeSymbolFromAlphabet ( const alphabet::RankedSymbol & symbol ); /** * @return List of symbols forming tree (const version). */ - const std::vector<alphabet::RankedSymbol>& getContent() const; + const std::vector < alphabet::RankedSymbol > & getContent ( ) const; - const alphabet::Symbol& getBarSymbol() const; + const alphabet::Symbol & getBarSymbol ( ) const; - void setContent(std::vector<alphabet::RankedSymbol> data); + void setContent ( std::vector < alphabet::RankedSymbol > data ); + + void arityChecksum ( const std::vector < alphabet::RankedSymbol > & data ); - void arityChecksum(const std::vector<alphabet::RankedSymbol>& data); /** * @return true if tree is an empty word (vector length is 0) */ - bool isEmpty() const; + bool isEmpty ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const PrefixRankedBarTree& other) const; - - virtual void operator >>(std::ostream& out) const; + virtual int compare ( const PrefixRankedBarTree & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & out ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static PrefixRankedBarTree parse(std::deque<sax::Token>::iterator& input); + static PrefixRankedBarTree parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace tree */ namespace std { -template<> -struct compare<::tree::PrefixRankedBarTree> { - int operator()(const ::tree::PrefixRankedBarTree& first, const ::tree::PrefixRankedBarTree& second) const { - return first.compare(second); +template < > +struct compare < ::tree::PrefixRankedBarTree > { + int operator ()( const::tree::PrefixRankedBarTree & first, const::tree::PrefixRankedBarTree & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* PREFIX_RANKED_BAR_TREE_H_ */ - diff --git a/alib2data/src/tree/ranked/PrefixRankedPattern.h b/alib2data/src/tree/ranked/PrefixRankedPattern.h index 969bb9edd1..5483b15930 100644 --- a/alib2data/src/tree/ranked/PrefixRankedPattern.h +++ b/alib2data/src/tree/ranked/PrefixRankedPattern.h @@ -24,64 +24,61 @@ class RankedPattern; * as a tree of LinearStringElement. */ class PrefixRankedPattern : public TreeBase, public RankedPatternAlphabet { - std::vector<alphabet::RankedSymbol> m_Data; + std::vector < alphabet::RankedSymbol > m_Data; public: - explicit PrefixRankedPattern(alphabet::RankedSymbol subtreeWildcard, std::set<alphabet::RankedSymbol> alphabet, std::vector<alphabet::RankedSymbol> data); - explicit PrefixRankedPattern(alphabet::RankedSymbol subtreeWildcard, std::vector<alphabet::RankedSymbol> data); - explicit PrefixRankedPattern(const RankedPattern& tree); + explicit PrefixRankedPattern ( alphabet::RankedSymbol subtreeWildcard, std::set < alphabet::RankedSymbol > alphabet, std::vector < alphabet::RankedSymbol > data ); + explicit PrefixRankedPattern ( alphabet::RankedSymbol subtreeWildcard, std::vector < alphabet::RankedSymbol > data ); + explicit PrefixRankedPattern ( const RankedPattern & tree ); - virtual TreeBase* clone() const; - virtual TreeBase* plunder() &&; + virtual TreeBase * clone ( ) const; + virtual TreeBase * plunder ( ) &&; - virtual bool removeSymbolFromAlphabet(const alphabet::RankedSymbol & symbol); + virtual bool removeSymbolFromAlphabet ( const alphabet::RankedSymbol & symbol ); /** * @return List of symbols forming tree (const version). */ - const std::vector<alphabet::RankedSymbol>& getContent() const; + const std::vector < alphabet::RankedSymbol > & getContent ( ) const; - void setContent(std::vector<alphabet::RankedSymbol> data); + void setContent ( std::vector < alphabet::RankedSymbol > data ); + + void arityChecksum ( const std::vector < alphabet::RankedSymbol > & data ); - void arityChecksum(const std::vector<alphabet::RankedSymbol>& data); /** * @return true if tree is an empty word (vector length is 0) */ - bool isEmpty() const; + bool isEmpty ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const PrefixRankedPattern& other) const; - - virtual void operator >>(std::ostream& out) const; + virtual int compare ( const PrefixRankedPattern & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & out ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static PrefixRankedPattern parse(std::deque<sax::Token>::iterator& input); + static PrefixRankedPattern parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace tree */ namespace std { -template<> -struct compare<::tree::PrefixRankedPattern> { - int operator()(const ::tree::PrefixRankedPattern& first, const ::tree::PrefixRankedPattern& second) const { - return first.compare(second); +template < > +struct compare < ::tree::PrefixRankedPattern > { + int operator ()( const::tree::PrefixRankedPattern & first, const::tree::PrefixRankedPattern & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* PREFIX_RANKED_PATTERN_H_ */ - diff --git a/alib2data/src/tree/ranked/PrefixRankedTree.h b/alib2data/src/tree/ranked/PrefixRankedTree.h index 461bca8fe0..e2e6cabda8 100644 --- a/alib2data/src/tree/ranked/PrefixRankedTree.h +++ b/alib2data/src/tree/ranked/PrefixRankedTree.h @@ -24,64 +24,61 @@ class RankedTree; * as a tree of LinearStringElement. */ class PrefixRankedTree : public TreeBase, public RankedAlphabet { - std::vector<alphabet::RankedSymbol> m_Data; + std::vector < alphabet::RankedSymbol > m_Data; public: - explicit PrefixRankedTree(std::set<alphabet::RankedSymbol> alphabet, std::vector<alphabet::RankedSymbol> data); - explicit PrefixRankedTree(std::vector<alphabet::RankedSymbol> data); - explicit PrefixRankedTree(const RankedTree& tree); + explicit PrefixRankedTree ( std::set < alphabet::RankedSymbol > alphabet, std::vector < alphabet::RankedSymbol > data ); + explicit PrefixRankedTree ( std::vector < alphabet::RankedSymbol > data ); + explicit PrefixRankedTree ( const RankedTree & tree ); - virtual TreeBase* clone() const; - virtual TreeBase* plunder() &&; + virtual TreeBase * clone ( ) const; + virtual TreeBase * plunder ( ) &&; - virtual bool removeSymbolFromAlphabet(const alphabet::RankedSymbol & symbol); + virtual bool removeSymbolFromAlphabet ( const alphabet::RankedSymbol & symbol ); /** * @return List of symbols forming tree (const version). */ - const std::vector<alphabet::RankedSymbol>& getContent() const; + const std::vector < alphabet::RankedSymbol > & getContent ( ) const; - void setContent(std::vector<alphabet::RankedSymbol> data); + void setContent ( std::vector < alphabet::RankedSymbol > data ); + + void arityChecksum ( const std::vector < alphabet::RankedSymbol > & data ); - void arityChecksum(const std::vector<alphabet::RankedSymbol>& data); /** * @return true if tree is an empty word (vector length is 0) */ - bool isEmpty() const; + bool isEmpty ( ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const PrefixRankedTree& other) const; - - virtual void operator >>(std::ostream& out) const; + virtual int compare ( const PrefixRankedTree & other ) const; - virtual explicit operator std::string() const; + virtual void operator >>( std::ostream & out ) const; - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static PrefixRankedTree parse(std::deque<sax::Token>::iterator& input); + static PrefixRankedTree parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace tree */ namespace std { -template<> -struct compare<::tree::PrefixRankedTree> { - int operator()(const ::tree::PrefixRankedTree& first, const ::tree::PrefixRankedTree& second) const { - return first.compare(second); +template < > +struct compare < ::tree::PrefixRankedTree > { + int operator ()( const::tree::PrefixRankedTree & first, const::tree::PrefixRankedTree & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ #endif /* PREFIX_RANKED_TREE_H_ */ - diff --git a/alib2data/src/tree/ranked/RankedPattern.h b/alib2data/src/tree/ranked/RankedPattern.h index d19277b855..f51c45c0dd 100644 --- a/alib2data/src/tree/ranked/RankedPattern.h +++ b/alib2data/src/tree/ranked/RankedPattern.h @@ -27,92 +27,89 @@ class UnrankedPattern; */ class RankedPattern : public TreeBase, public RankedPatternAlphabet { protected: - RankedNode* pattern; + RankedNode * pattern; public: /** * @copydoc RankedNode::clone() const */ - virtual TreeBase* clone() const; + virtual TreeBase * clone ( ) const; /** * @copydoc RankedNode::plunder() const */ - virtual TreeBase* plunder() &&; + virtual TreeBase * plunder ( ) &&; - explicit RankedPattern(const UnrankedPattern& other); - explicit RankedPattern(alphabet::RankedSymbol subtreeWildcard, std::set<alphabet::RankedSymbol> alphabet, RankedNode pattern); - explicit RankedPattern(alphabet::RankedSymbol subtreeWildcard, RankedNode pattern); + explicit RankedPattern ( const UnrankedPattern & other ); + explicit RankedPattern ( alphabet::RankedSymbol subtreeWildcard, std::set < alphabet::RankedSymbol > alphabet, RankedNode pattern ); + explicit RankedPattern ( alphabet::RankedSymbol subtreeWildcard, RankedNode pattern ); /** * Copy constructor. * @param other pattern to copy */ - RankedPattern(const RankedPattern& other); - RankedPattern(RankedPattern&& other) noexcept; - RankedPattern& operator =(const RankedPattern& other); - RankedPattern& operator =(RankedPattern&& other) noexcept; - ~RankedPattern() noexcept; + RankedPattern ( const RankedPattern & other ); + RankedPattern ( RankedPattern && other ) noexcept; + RankedPattern & operator =( const RankedPattern & other ); + RankedPattern & operator =( RankedPattern && other ) noexcept; + ~RankedPattern ( ) noexcept; /** * @return Root node of the regular expression pattern */ - const RankedNode& getRoot() const; + const RankedNode & getRoot ( ) const; /** * @return Root node of the regular expression pattern */ - RankedNode& getRoot(); + RankedNode & getRoot ( ); /** * Sets the root node of the regular expression pattern * @param pattern root node to set */ - void setTree(RankedNode pattern); + void setTree ( RankedNode pattern ); /** * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet(const alphabet::RankedSymbol & symbol); + bool removeSymbolFromAlphabet ( const alphabet::RankedSymbol & symbol ); /** * Prints XML representation of the pattern to the output stream. * @param out output stream to which print the pattern * @param pattern pattern to print */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const RankedPattern& other) const; + virtual int compare ( const RankedPattern & other ) const; - void nicePrint(std::ostream & os) const; + void nicePrint ( std::ostream & os ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static RankedPattern parse(std::deque<sax::Token>::iterator& input); + static RankedPattern parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace tree */ namespace std { -template<> -struct compare<tree::RankedPattern> { - int operator()(const tree::RankedPattern& first, const tree::RankedPattern& second) const { - return first.compare(second); +template < > +struct compare < tree::RankedPattern > { + int operator ()( const tree::RankedPattern & first, const tree::RankedPattern & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/tree/ranked/RankedTree.h b/alib2data/src/tree/ranked/RankedTree.h index 9c9eeedece..3a67fe2e44 100644 --- a/alib2data/src/tree/ranked/RankedTree.h +++ b/alib2data/src/tree/ranked/RankedTree.h @@ -27,92 +27,89 @@ class UnrankedTree; */ class RankedTree : public TreeBase, public RankedAlphabet { protected: - RankedNode* tree; + RankedNode * tree; public: /** * @copydoc RankedNode::clone() const */ - virtual TreeBase* clone() const; + virtual TreeBase * clone ( ) const; /** * @copydoc RankedNode::plunder() const */ - virtual TreeBase* plunder() &&; + virtual TreeBase * plunder ( ) &&; - explicit RankedTree(const UnrankedTree& other); - explicit RankedTree(std::set<alphabet::RankedSymbol> alphabet, RankedNode tree); - explicit RankedTree(RankedNode tree); + explicit RankedTree ( const UnrankedTree & other ); + explicit RankedTree ( std::set < alphabet::RankedSymbol > alphabet, RankedNode tree ); + explicit RankedTree ( RankedNode tree ); /** * Copy constructor. * @param other tree to copy */ - RankedTree(const RankedTree& other); - RankedTree(RankedTree&& other) noexcept; - RankedTree& operator =(const RankedTree& other); - RankedTree& operator =(RankedTree&& other) noexcept; - ~RankedTree() noexcept; + RankedTree ( const RankedTree & other ); + RankedTree ( RankedTree && other ) noexcept; + RankedTree & operator =( const RankedTree & other ); + RankedTree & operator =( RankedTree && other ) noexcept; + ~RankedTree ( ) noexcept; /** * @return Root node of the regular expression tree */ - const RankedNode& getRoot() const; + const RankedNode & getRoot ( ) const; /** * @return Root node of the regular expression tree */ - RankedNode& getRoot(); + RankedNode & getRoot ( ); /** * Sets the root node of the regular expression tree * @param tree root node to set */ - void setTree(RankedNode tree); + void setTree ( RankedNode tree ); /** * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet(const alphabet::RankedSymbol & symbol); + bool removeSymbolFromAlphabet ( const alphabet::RankedSymbol & symbol ); /** * Prints XML representation of the tree to the output stream. * @param out output stream to which print the tree * @param tree tree to print */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const RankedTree& other) const; + virtual int compare ( const RankedTree & other ) const; - void nicePrint(std::ostream & os) const; + void nicePrint ( std::ostream & os ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static RankedTree parse(std::deque<sax::Token>::iterator& input); + static RankedTree parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace tree */ namespace std { -template<> -struct compare<tree::RankedTree> { - int operator()(const tree::RankedTree& first, const tree::RankedTree& second) const { - return first.compare(second); +template < > +struct compare < tree::RankedTree > { + int operator ()( const tree::RankedTree & first, const tree::RankedTree & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/tree/unranked/UnrankedPattern.h b/alib2data/src/tree/unranked/UnrankedPattern.h index bcfea83bf5..13debed747 100644 --- a/alib2data/src/tree/unranked/UnrankedPattern.h +++ b/alib2data/src/tree/unranked/UnrankedPattern.h @@ -27,92 +27,89 @@ class RankedPattern; */ class UnrankedPattern : public TreeBase, public UnrankedPatternAlphabet { protected: - UnrankedNode* pattern; + UnrankedNode * pattern; public: /** * @copydoc UnrankedNode::clone() const */ - virtual TreeBase* clone() const; + virtual TreeBase * clone ( ) const; /** * @copydoc UnrankedNode::plunder() const */ - virtual TreeBase* plunder() &&; + virtual TreeBase * plunder ( ) &&; - explicit UnrankedPattern(const RankedPattern& other); - explicit UnrankedPattern(alphabet::Symbol subtreeWildcard, std::set<alphabet::Symbol> alphabet, UnrankedNode pattern); - explicit UnrankedPattern(alphabet::Symbol subtreeWildcard, UnrankedNode pattern); + explicit UnrankedPattern ( const RankedPattern & other ); + explicit UnrankedPattern ( alphabet::Symbol subtreeWildcard, std::set < alphabet::Symbol > alphabet, UnrankedNode pattern ); + explicit UnrankedPattern ( alphabet::Symbol subtreeWildcard, UnrankedNode pattern ); /** * Copy constructor. * @param other pattern to copy */ - UnrankedPattern(const UnrankedPattern& other); - UnrankedPattern(UnrankedPattern&& other) noexcept; - UnrankedPattern& operator =(const UnrankedPattern& other); - UnrankedPattern& operator =(UnrankedPattern&& other) noexcept; - ~UnrankedPattern() noexcept; + UnrankedPattern ( const UnrankedPattern & other ); + UnrankedPattern ( UnrankedPattern && other ) noexcept; + UnrankedPattern & operator =( const UnrankedPattern & other ); + UnrankedPattern & operator =( UnrankedPattern && other ) noexcept; + ~UnrankedPattern ( ) noexcept; /** * @return Root node of the regular expression pattern */ - const UnrankedNode& getRoot() const; + const UnrankedNode & getRoot ( ) const; /** * @return Root node of the regular expression pattern */ - UnrankedNode& getRoot(); + UnrankedNode & getRoot ( ); /** * Sets the root node of the regular expression pattern * @param pattern root node to set */ - void setTree(UnrankedNode pattern); + void setTree ( UnrankedNode pattern ); /** * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet(const alphabet::Symbol & symbol); + bool removeSymbolFromAlphabet ( const alphabet::Symbol & symbol ); /** * Prints XML representation of the pattern to the output stream. * @param out output stream to which print the pattern * @param pattern pattern to print */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const UnrankedPattern& other) const; + virtual int compare ( const UnrankedPattern & other ) const; - void nicePrint(std::ostream & os) const; + void nicePrint ( std::ostream & os ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static UnrankedPattern parse(std::deque<sax::Token>::iterator& input); + static UnrankedPattern parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace tree */ namespace std { -template<> -struct compare<tree::UnrankedPattern> { - int operator()(const tree::UnrankedPattern& first, const tree::UnrankedPattern& second) const { - return first.compare(second); +template < > +struct compare < tree::UnrankedPattern > { + int operator ()( const tree::UnrankedPattern & first, const tree::UnrankedPattern & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/src/tree/unranked/UnrankedTree.h b/alib2data/src/tree/unranked/UnrankedTree.h index 732abc1dda..90dea37642 100644 --- a/alib2data/src/tree/unranked/UnrankedTree.h +++ b/alib2data/src/tree/unranked/UnrankedTree.h @@ -27,92 +27,89 @@ class RankedTree; */ class UnrankedTree : public TreeBase, public UnrankedAlphabet { protected: - UnrankedNode* tree; + UnrankedNode * tree; public: /** * @copydoc UnrankedNode::clone() const */ - virtual TreeBase* clone() const; + virtual TreeBase * clone ( ) const; /** * @copydoc UnrankedNode::plunder() const */ - virtual TreeBase* plunder() &&; + virtual TreeBase * plunder ( ) &&; - explicit UnrankedTree(const RankedTree& other); - explicit UnrankedTree(std::set<alphabet::Symbol> alphabet, UnrankedNode tree); - explicit UnrankedTree(UnrankedNode tree); + explicit UnrankedTree ( const RankedTree & other ); + explicit UnrankedTree ( std::set < alphabet::Symbol > alphabet, UnrankedNode tree ); + explicit UnrankedTree ( UnrankedNode tree ); /** * Copy constructor. * @param other tree to copy */ - UnrankedTree(const UnrankedTree& other); - UnrankedTree(UnrankedTree&& other) noexcept; - UnrankedTree& operator =(const UnrankedTree& other); - UnrankedTree& operator =(UnrankedTree&& other) noexcept; - ~UnrankedTree() noexcept; + UnrankedTree ( const UnrankedTree & other ); + UnrankedTree ( UnrankedTree && other ) noexcept; + UnrankedTree & operator =( const UnrankedTree & other ); + UnrankedTree & operator =( UnrankedTree && other ) noexcept; + ~UnrankedTree ( ) noexcept; /** * @return Root node of the regular expression tree */ - const UnrankedNode& getRoot() const; + const UnrankedNode & getRoot ( ) const; /** * @return Root node of the regular expression tree */ - UnrankedNode& getRoot(); + UnrankedNode & getRoot ( ); /** * Sets the root node of the regular expression tree * @param tree root node to set */ - void setTree(UnrankedNode tree); + void setTree ( UnrankedNode tree ); /** * Removes symbol from the alphabet of symbol available in the regular expression * @param symbol removed symbol from the alphabet */ - bool removeSymbolFromAlphabet(const alphabet::Symbol & symbol); + bool removeSymbolFromAlphabet ( const alphabet::Symbol & symbol ); /** * Prints XML representation of the tree to the output stream. * @param out output stream to which print the tree * @param tree tree to print */ - virtual void operator>>(std::ostream& out) const; + virtual void operator >>( std::ostream & out ) const; - virtual int compare(const ObjectBase& other) const { - return ObjectBase::compare(*this, other); + virtual int compare ( const ObjectBase & other ) const { + return ObjectBase::compare ( * this, other ); } - virtual int compare(const UnrankedTree& other) const; + virtual int compare ( const UnrankedTree & other ) const; - void nicePrint(std::ostream & os) const; + void nicePrint ( std::ostream & os ) const; - virtual explicit operator std::string() const; - - virtual long long selfTypeId() const { - return typeId(*this); - } + virtual explicit operator std::string ( ) const; const static std::string XML_TAG_NAME; - static UnrankedTree parse(std::deque<sax::Token>::iterator& input); + static UnrankedTree parse ( std::deque < sax::Token >::iterator & input ); - void compose(std::deque<sax::Token>& out) const; + void compose ( std::deque < sax::Token > & out ) const; }; } /* namespace tree */ namespace std { -template<> -struct compare<tree::UnrankedTree> { - int operator()(const tree::UnrankedTree& first, const tree::UnrankedTree& second) const { - return first.compare(second); +template < > +struct compare < tree::UnrankedTree > { + int operator ()( const tree::UnrankedTree & first, const tree::UnrankedTree & second ) const { + return first.compare ( second ); } + }; } /* namespace std */ diff --git a/alib2data/test-src/common/DispatchTest.cpp b/alib2data/test-src/common/DispatchTest.cpp index a95d33509a..443c9b0ad6 100644 --- a/alib2data/test-src/common/DispatchTest.cpp +++ b/alib2data/test-src/common/DispatchTest.cpp @@ -4,56 +4,52 @@ #include <set> #include <string> -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DispatchTest, "std" ); -CPPUNIT_TEST_SUITE_REGISTRATION( DispatchTest ); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( DispatchTest, "std" ); +CPPUNIT_TEST_SUITE_REGISTRATION ( DispatchTest ); -void DispatchTest::setUp() { +void DispatchTest::setUp ( ) { } -void DispatchTest::tearDown() { +void DispatchTest::tearDown ( ) { } namespace dispatch { -class TmpBase : public alib::base<TmpBase> { +class TmpBase : public alib::base < TmpBase > { }; class Tmp1 : public TmpBase { int data; + public: - Tmp1(int data) : data(data) { - + Tmp1 ( int data ) : data ( data ) { } - TmpBase* clone() const { - return new Tmp1(*this); + TmpBase * clone ( ) const { + return new Tmp1 ( * this ); } - TmpBase* plunder() && { - return new Tmp1(*this); + TmpBase * plunder ( ) && { + return new Tmp1 ( * this ); } - virtual int compare(const TmpBase& other) const { - return -other.compare(*this); + virtual int compare ( const TmpBase & other ) const { + return -other.compare ( * this ); } - virtual int compare(const Tmp1& other) const { + virtual int compare ( const Tmp1 & other ) const { return this->data - other.data; } - virtual void operator>>(std::ostream& os) const { - os << "Tmp1(" << data << ")"; - } - - virtual operator std::string() const { - return "Tmp1(" + std::to_string(data) + ")"; + virtual void operator >>( std::ostream & os ) const { + os << "Tmp1(" << data << ")"; } - virtual long long selfTypeId() const { - return typeId(*this); + virtual operator std::string ( ) const { + return "Tmp1(" + std::to_string ( data ) + ")"; } - int getData() const { + int getData ( ) const { return data; } @@ -61,44 +57,39 @@ public: class Tmp2 : public TmpBase { double data; + public: - Tmp2(double data) : data(data) { - + Tmp2 ( double data ) : data ( data ) { } - Tmp2(const Tmp1& other) : data(other.getData()) { - + Tmp2 ( const Tmp1 & other ) : data ( other.getData ( ) ) { } - TmpBase* clone() const { - return new Tmp2(*this); + TmpBase * clone ( ) const { + return new Tmp2 ( * this ); } - TmpBase* plunder() && { - return new Tmp2(*this); + TmpBase * plunder ( ) && { + return new Tmp2 ( * this ); } - virtual int compare(const TmpBase& other) const { - return -other.compare(*this); + virtual int compare ( const TmpBase & other ) const { + return -other.compare ( * this ); } - virtual int compare(const Tmp2& other) const { + virtual int compare ( const Tmp2 & other ) const { return this->data - other.data; } - virtual void operator>>(std::ostream& os) const { - os << "Tmp2(" << data << ")"; - } - - virtual operator std::string() const { - return "Tmp2(" + std::to_string(data) + ")"; + virtual void operator >>( std::ostream & os ) const { + os << "Tmp2(" << data << ")"; } - virtual long long selfTypeId() const { - return typeId(*this); + virtual operator std::string ( ) const { + return "Tmp2(" + std::to_string ( data ) + ")"; } - double getData() const { + double getData ( ) const { return data; } @@ -106,48 +97,42 @@ public: class Tmp3 : public TmpBase { std::string data; + public: - Tmp3(const std::string& data) : data(data) { - + Tmp3 ( const std::string & data ) : data ( data ) { } - Tmp3(const Tmp1& other) : data(std::to_string(other.getData())) { - + Tmp3 ( const Tmp1 & other ) : data ( std::to_string ( other.getData ( ) ) ) { } - Tmp3(const Tmp2& other) : data(std::to_string(other.getData())) { - + Tmp3 ( const Tmp2 & other ) : data ( std::to_string ( other.getData ( ) ) ) { } - TmpBase* clone() const { - return new Tmp3(*this); + TmpBase * clone ( ) const { + return new Tmp3 ( * this ); } - TmpBase* plunder() && { - return new Tmp3(*this); + TmpBase * plunder ( ) && { + return new Tmp3 ( * this ); } - virtual int compare(const TmpBase& other) const { - return -other.compare(*this); + virtual int compare ( const TmpBase & other ) const { + return -other.compare ( * this ); } - virtual int compare(const Tmp3& other) const { - return this->data.compare(other.data); + virtual int compare ( const Tmp3 & other ) const { + return this->data.compare ( other.data ); } - virtual void operator>>(std::ostream& os) const { - os << "Tmp3(" << data << ")"; + virtual void operator >>( std::ostream & os ) const { + os << "Tmp3(" << data << ")"; } - virtual operator std::string() const { + virtual operator std::string ( ) const { return "Tmp3(" + data + ")"; } - virtual long long selfTypeId() const { - return typeId(*this); - } - - const std::string& getData() const { + const std::string & getData ( ) const { return data; } @@ -155,110 +140,121 @@ public: // ------------------------------------------------------------------------------------------------------------------------------------------------------- -class TmpVisitor : public std::SingleDispatch<int, TmpBase> { +class TmpVisitor : public std::SingleDispatch < int, TmpBase > { public: - static int eval(const Tmp2& first) { + static int eval ( const Tmp2 & first ) { std::cout << first << std::endl; + return 2; } - static int eval(const Tmp3& first) { + static int eval ( const Tmp3 & first ) { std::cout << first << std::endl; + return 3; } - static int eval(const TmpBase& first) { - return getInstance().dispatch(first); + static int eval ( const TmpBase & first ) { + return getInstance ( ).dispatch ( first ); } - static TmpVisitor& getInstance() { + static TmpVisitor & getInstance ( ) { static TmpVisitor res; + return res; } + }; -int TmpVisitorExtensionTmp1(const Tmp1& first) { +int TmpVisitorExtensionTmp1 ( const Tmp1 & first ) { std::cout << first << std::endl; + return 1; } -TmpVisitor::RegistratorWrapper<int, Tmp1> TmpVisitorTmp1 = TmpVisitor::RegistratorWrapper<int, Tmp1>(TmpVisitor::getInstance(), TmpVisitorExtensionTmp1); -TmpVisitor::RegistratorWrapper<int, Tmp2> TmpVisitorTmp2 = TmpVisitor::RegistratorWrapper<int, Tmp2>(TmpVisitor::getInstance(), TmpVisitor::eval); -TmpVisitor::RegistratorWrapper<int, Tmp3> TmpVisitorTmp3 = TmpVisitor::RegistratorWrapper<int, Tmp3>(TmpVisitor::getInstance(), TmpVisitor::eval); +TmpVisitor::RegistratorWrapper < int, Tmp1 > TmpVisitorTmp1 = TmpVisitor::RegistratorWrapper < int, Tmp1 > ( TmpVisitor::getInstance ( ), TmpVisitorExtensionTmp1 ); +TmpVisitor::RegistratorWrapper < int, Tmp2 > TmpVisitorTmp2 = TmpVisitor::RegistratorWrapper < int, Tmp2 > ( TmpVisitor::getInstance ( ), TmpVisitor::eval ); +TmpVisitor::RegistratorWrapper < int, Tmp3 > TmpVisitorTmp3 = TmpVisitor::RegistratorWrapper < int, Tmp3 > ( TmpVisitor::getInstance ( ), TmpVisitor::eval ); } /* namespace dispatch */ -void DispatchTest::testDispatch() { - dispatch::Tmp1 tmp1(2); +void DispatchTest::testDispatch ( ) { + dispatch::Tmp1 tmp1 ( 2 ); + + int a = dispatch::TmpVisitor::eval ( tmp1 ); - int a = dispatch::TmpVisitor::eval(tmp1); - CPPUNIT_ASSERT(a == 1); + CPPUNIT_ASSERT ( a == 1 ); - a = dispatch::TmpVisitor::eval((dispatch::TmpBase&) tmp1); - CPPUNIT_ASSERT(a == 1); + a = dispatch::TmpVisitor::eval ( ( dispatch::TmpBase & ) tmp1 ); + CPPUNIT_ASSERT ( a == 1 ); - dispatch::Tmp2 tmp2(3.3); + dispatch::Tmp2 tmp2 ( 3.3 ); - a = dispatch::TmpVisitor::eval(tmp2); - CPPUNIT_ASSERT(a == 2); + a = dispatch::TmpVisitor::eval ( tmp2 ); + CPPUNIT_ASSERT ( a == 2 ); - a = dispatch::TmpVisitor::eval((dispatch::TmpBase&) tmp2); - CPPUNIT_ASSERT(a == 2); + a = dispatch::TmpVisitor::eval ( ( dispatch::TmpBase & ) tmp2 ); + CPPUNIT_ASSERT ( a == 2 ); } namespace dispatch { // ------------------------------------------------------------------------------------------------------------------------------------------------------- -class TmpVisitor2 : public std::SingleDispatchFirstStaticParam<void, int&, TmpBase> { +class TmpVisitor2 : public std::SingleDispatchFirstStaticParam < void, int &, TmpBase > { public: - static void eval(int& res, const Tmp2& first) { + static void eval ( int & res, const Tmp2 & first ) { std::cout << first << std::endl; + res = 2; } - static void eval(int& res, const Tmp3& first) { + static void eval ( int & res, const Tmp3 & first ) { std::cout << first << std::endl; + res = 3; } - static void eval(int& res, const TmpBase& first) { - getInstance().dispatch(res, first); + static void eval ( int & res, const TmpBase & first ) { + getInstance ( ).dispatch ( res, first ); } - static TmpVisitor2& getInstance() { + static TmpVisitor2 & getInstance ( ) { static TmpVisitor2 res; + return res; } + }; -void TmpVisitor2ExtensionTmp1(int& res, const Tmp1& first) { +void TmpVisitor2ExtensionTmp1 ( int & res, const Tmp1 & first ) { std::cout << first << std::endl; + res = 1; } -TmpVisitor2::RegistratorWrapper<void, Tmp1> TmpVisitor2Tmp1 = TmpVisitor2::RegistratorWrapper<void, Tmp1>(TmpVisitor2::getInstance(), TmpVisitor2ExtensionTmp1); -TmpVisitor2::RegistratorWrapper<void, Tmp2> TmpVisitor2Tmp2 = TmpVisitor2::RegistratorWrapper<void, Tmp2>(TmpVisitor2::getInstance(), TmpVisitor2::eval); -TmpVisitor2::RegistratorWrapper<void, Tmp3> TmpVisitor2Tmp3 = TmpVisitor2::RegistratorWrapper<void, Tmp3>(TmpVisitor2::getInstance(), TmpVisitor2::eval); +TmpVisitor2::RegistratorWrapper < void, Tmp1 > TmpVisitor2Tmp1 = TmpVisitor2::RegistratorWrapper < void, Tmp1 > ( TmpVisitor2::getInstance ( ), TmpVisitor2ExtensionTmp1 ); +TmpVisitor2::RegistratorWrapper < void, Tmp2 > TmpVisitor2Tmp2 = TmpVisitor2::RegistratorWrapper < void, Tmp2 > ( TmpVisitor2::getInstance ( ), TmpVisitor2::eval ); +TmpVisitor2::RegistratorWrapper < void, Tmp3 > TmpVisitor2Tmp3 = TmpVisitor2::RegistratorWrapper < void, Tmp3 > ( TmpVisitor2::getInstance ( ), TmpVisitor2::eval ); } /* namespace dispatch */ -void DispatchTest::testDispatch2() { - dispatch::Tmp1 tmp1(2); +void DispatchTest::testDispatch2 ( ) { + dispatch::Tmp1 tmp1 ( 2 ); int a; - dispatch::TmpVisitor2::eval(a, tmp1); - CPPUNIT_ASSERT(a == 1); + dispatch::TmpVisitor2::eval ( a, tmp1 ); - dispatch::TmpVisitor2::eval(a, (dispatch::TmpBase&) tmp1); - CPPUNIT_ASSERT(a == 1); + CPPUNIT_ASSERT ( a == 1 ); - dispatch::Tmp2 tmp2(3.3); + dispatch::TmpVisitor2::eval ( a, ( dispatch::TmpBase & ) tmp1 ); + CPPUNIT_ASSERT ( a == 1 ); - dispatch::TmpVisitor2::eval(a, tmp2); - CPPUNIT_ASSERT(a == 2); + dispatch::Tmp2 tmp2 ( 3.3 ); - dispatch::TmpVisitor2::eval(a, (dispatch::TmpBase&) tmp2); - CPPUNIT_ASSERT(a == 2); -} + dispatch::TmpVisitor2::eval ( a, tmp2 ); + CPPUNIT_ASSERT ( a == 2 ); + dispatch::TmpVisitor2::eval ( a, ( dispatch::TmpBase & ) tmp2 ); + CPPUNIT_ASSERT ( a == 2 ); +} diff --git a/alib2data/test-src/common/VisitorTest.cpp b/alib2data/test-src/common/VisitorTest.cpp index 4fa0e51b2b..603ae63d6c 100644 --- a/alib2data/test-src/common/VisitorTest.cpp +++ b/alib2data/test-src/common/VisitorTest.cpp @@ -4,13 +4,13 @@ #include <set> #include <string> -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VisitorTest, "std" ); -CPPUNIT_TEST_SUITE_REGISTRATION( VisitorTest ); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( VisitorTest, "std" ); +CPPUNIT_TEST_SUITE_REGISTRATION ( VisitorTest ); -void VisitorTest::setUp() { +void VisitorTest::setUp ( ) { } -void VisitorTest::tearDown() { +void VisitorTest::tearDown ( ) { } namespace visitor { @@ -21,246 +21,244 @@ class Tmp3; class TmpBase; -typedef std::acceptor_base<TmpBase, - Tmp1, Tmp2, Tmp3 - > VisitableTmpBase; +typedef std::acceptor_base < TmpBase, Tmp1, Tmp2, Tmp3 > VisitableTmpBase; -class TmpBase : public alib::base<TmpBase>, public VisitableTmpBase { +class TmpBase : public alib::base < TmpBase >, public VisitableTmpBase { }; -class Tmp1 : public std::acceptor<Tmp1, VisitableTmpBase, TmpBase> { +class Tmp1 : public std::acceptor < Tmp1, VisitableTmpBase, TmpBase > { int data; + public: - Tmp1(int data) : data(data) { - + Tmp1 ( int data ) : data ( data ) { } - TmpBase* clone() const { - return new Tmp1(*this); + TmpBase * clone ( ) const { + return new Tmp1 ( * this ); } - TmpBase* plunder() && { - return new Tmp1(*this); + TmpBase * plunder ( ) && { + return new Tmp1 ( * this ); } - virtual int compare(const TmpBase& other) const { - return -other.compare(*this); + virtual int compare ( const TmpBase & other ) const { + return -other.compare ( * this ); } - virtual int compare(const Tmp1& other) const { + virtual int compare ( const Tmp1 & other ) const { return this->data - other.data; } - virtual void operator>>(std::ostream& os) const { - os << "Tmp1(" << data << ")"; - } - - virtual operator std::string() const { - return "Tmp1(" + std::to_string(data) + ")"; + virtual void operator >>( std::ostream & os ) const { + os << "Tmp1(" << data << ")"; } - virtual long long selfTypeId() const { - return typeId(*this); + virtual operator std::string ( ) const { + return "Tmp1(" + std::to_string ( data ) + ")"; } - int getData() const { + int getData ( ) const { return data; } }; -class Tmp2 : public std::acceptor<Tmp2, VisitableTmpBase, TmpBase> { +class Tmp2 : public std::acceptor < Tmp2, VisitableTmpBase, TmpBase > { double data; + public: - Tmp2(double data) : data(data) { - + Tmp2 ( double data ) : data ( data ) { } - Tmp2(const Tmp1& other) : data(other.getData()) { - + Tmp2 ( const Tmp1 & other ) : data ( other.getData ( ) ) { } - TmpBase* clone() const { - return new Tmp2(*this); + TmpBase * clone ( ) const { + return new Tmp2 ( * this ); } - TmpBase* plunder() && { - return new Tmp2(*this); + TmpBase * plunder ( ) && { + return new Tmp2 ( * this ); } - virtual int compare(const TmpBase& other) const { - return -other.compare(*this); + virtual int compare ( const TmpBase & other ) const { + return -other.compare ( * this ); } - virtual int compare(const Tmp2& other) const { + virtual int compare ( const Tmp2 & other ) const { return this->data - other.data; } - virtual void operator>>(std::ostream& os) const { - os << "Tmp2(" << data << ")"; - } - - virtual operator std::string() const { - return "Tmp2(" + std::to_string(data) + ")"; + virtual void operator >>( std::ostream & os ) const { + os << "Tmp2(" << data << ")"; } - virtual long long selfTypeId() const { - return typeId(*this); + virtual operator std::string ( ) const { + return "Tmp2(" + std::to_string ( data ) + ")"; } - double getData() const { + double getData ( ) const { return data; } }; -class Tmp3 : public std::acceptor<Tmp3, VisitableTmpBase, TmpBase> { +class Tmp3 : public std::acceptor < Tmp3, VisitableTmpBase, TmpBase > { std::string data; + public: - Tmp3(const std::string& data) : data(data) { - + Tmp3 ( const std::string & data ) : data ( data ) { } - Tmp3(const Tmp1& other) : data(std::to_string(other.getData())) { - + Tmp3 ( const Tmp1 & other ) : data ( std::to_string ( other.getData ( ) ) ) { } - Tmp3(const Tmp2& other) : data(std::to_string(other.getData())) { - + Tmp3 ( const Tmp2 & other ) : data ( std::to_string ( other.getData ( ) ) ) { } - TmpBase* clone() const { - return new Tmp3(*this); + TmpBase * clone ( ) const { + return new Tmp3 ( * this ); } - TmpBase* plunder() && { - return new Tmp3(*this); + TmpBase * plunder ( ) && { + return new Tmp3 ( * this ); } - virtual int compare(const TmpBase& other) const { - return -other.compare(*this); + virtual int compare ( const TmpBase & other ) const { + return -other.compare ( * this ); } - virtual int compare(const Tmp3& other) const { - return this->data.compare(other.data); + virtual int compare ( const Tmp3 & other ) const { + return this->data.compare ( other.data ); } - virtual void operator>>(std::ostream& os) const { - os << "Tmp3(" << data << ")"; + virtual void operator >>( std::ostream & os ) const { + os << "Tmp3(" << data << ")"; } - virtual operator std::string() const { + virtual operator std::string ( ) const { return "Tmp3(" + data + ")"; } - virtual long long selfTypeId() const { - return typeId(*this); - } - - const std::string& getData() const { + const std::string & getData ( ) const { return data; } }; class TmpVisitor : public VisitableTmpBase::const_visitor_type { - void Visit(void* userData, const Tmp1& first) const { - int& data = *((int*) userData); + void Visit ( void * userData, const Tmp1 & first ) const { + int & data = * ( ( int * ) userData ); + data = 1; std::cout << first << std::endl; } - void Visit(void* userData, const Tmp2& first) const { - int& data = *((int*) userData); + void Visit ( void * userData, const Tmp2 & first ) const { + int & data = * ( ( int * ) userData ); + data = 2; std::cout << first << std::endl; } - void Visit(void* userData, const Tmp3& first) const { - int& data = *((int*) userData); + void Visit ( void * userData, const Tmp3 & first ) const { + int & data = * ( ( int * ) userData ); + data = 3; std::cout << first << std::endl; } + }; class TmpSameVisitor : public VisitableTmpBase::const_same_visitor_type { - void Visit(void* userData, const Tmp1& first, const Tmp1& second) const { - int& data = *((int*) userData); + void Visit ( void * userData, const Tmp1 & first, const Tmp1 & second ) const { + int & data = * ( ( int * ) userData ); + data = 1; std::cout << first << " " << second << std::endl; } - void Visit(void* userData, const Tmp2& first, const Tmp2& second) const { - int& data = *((int*) userData); + void Visit ( void * userData, const Tmp2 & first, const Tmp2 & second ) const { + int & data = * ( ( int * ) userData ); + data = 2; std::cout << first << " " << second << std::endl; } - void Visit(void* userData, const Tmp3& first, const Tmp3& second) const { - int& data = *((int*) userData); + void Visit ( void * userData, const Tmp3 & first, const Tmp3 & second ) const { + int & data = * ( ( int * ) userData ); + data = 3; std::cout << first << " " << second << std::endl; } + }; class TmpPromotingVisitor : public VisitableTmpBase::const_promoting_visitor_type { - void Visit(void* userData, const Tmp1& first, const Tmp1& second) const { - std::string& data = *((std::string*) userData); - data = std::to_string(first.getData()) + " " + std::to_string(second.getData()); + void Visit ( void * userData, const Tmp1 & first, const Tmp1 & second ) const { + std::string & data = * ( ( std::string * ) userData ); + + data = std::to_string ( first.getData ( ) ) + " " + std::to_string ( second.getData ( ) ); std::cout << first << " " << second << std::endl; } - void Visit(void* userData, const Tmp2& first, const Tmp2& second) const { - std::string& data = *((std::string*) userData); - data = std::to_string(first.getData()) + " " + std::to_string(second.getData()); + void Visit ( void * userData, const Tmp2 & first, const Tmp2 & second ) const { + std::string & data = * ( ( std::string * ) userData ); + + data = std::to_string ( first.getData ( ) ) + " " + std::to_string ( second.getData ( ) ); std::cout << first << " " << second << std::endl; } - void Visit(void* userData, const Tmp3& first, const Tmp3& second) const { - std::string& data = *((std::string*) userData); - data = first.getData() + " " + second.getData(); + void Visit ( void * userData, const Tmp3 & first, const Tmp3 & second ) const { + std::string & data = * ( ( std::string * ) userData ); + + data = first.getData ( ) + " " + second.getData ( ); std::cout << first << " " << second << std::endl; } + }; } /* namespace visitor */ -void VisitorTest::testVisitor() { +void VisitorTest::testVisitor ( ) { visitor::TmpVisitor visitor; - visitor::Tmp1 tmp1(2); + visitor::Tmp1 tmp1 ( 2 ); int a = 0; - tmp1.Accept((void*) &a, visitor); - CPPUNIT_ASSERT(a == 1); + tmp1.Accept ( ( void * ) & a, visitor ); + + CPPUNIT_ASSERT ( a == 1 ); } -void VisitorTest::testSameVisitor() { +void VisitorTest::testSameVisitor ( ) { visitor::TmpSameVisitor visitor; - visitor::Tmp2 tmpA(2); - visitor::Tmp2 tmpB(3); + visitor::Tmp2 tmpA ( 2 ); + visitor::Tmp2 tmpB ( 3 ); int a = 0; - Accept((void*) &a, (visitor::TmpBase&) tmpA, (visitor::TmpBase&) tmpB, visitor); - CPPUNIT_ASSERT(a == 2); + Accept ( ( void * ) & a, ( visitor::TmpBase & ) tmpA, ( visitor::TmpBase & ) tmpB, visitor ); + + CPPUNIT_ASSERT ( a == 2 ); } -void VisitorTest::testPromoteVisitor() { +void VisitorTest::testPromoteVisitor ( ) { visitor::TmpPromotingVisitor visitor; - visitor::Tmp1 tmp1(1); - visitor::Tmp3 tmp3("3"); + visitor::Tmp1 tmp1 ( 1 ); + visitor::Tmp3 tmp3 ( "3" ); std::string a = ""; - Accept((void*) &a, (visitor::TmpBase&) tmp1, (visitor::TmpBase&) tmp3, visitor); - CPPUNIT_ASSERT(a == "1 3"); + Accept ( ( void * ) & a, ( visitor::TmpBase & ) tmp1, ( visitor::TmpBase & ) tmp3, visitor ); + + CPPUNIT_ASSERT ( a == "1 3" ); std::string b = ""; - Accept((void*) &b, (visitor::TmpBase&) tmp3, (visitor::TmpBase&) tmp1, visitor); + Accept ( ( void * ) & b, ( visitor::TmpBase & ) tmp3, ( visitor::TmpBase & ) tmp1, visitor ); - CPPUNIT_ASSERT(b == "3 1"); + CPPUNIT_ASSERT ( b == "3 1" ); } -- GitLab