diff --git a/alib2data/src/common/base.hpp b/alib2data/src/common/base.hpp index 5d52d7db9051c8dc7b8a3dd209727bb89d474be2..526d14da2079a73b3168d5edf36516fe03c69696 100644 --- a/alib2data/src/common/base.hpp +++ b/alib2data/src/common/base.hpp @@ -24,7 +24,7 @@ public: } virtual bool operator<(const T & other) const { - return typeid(*this).before(typeid(other)); + return typeid(this).before(typeid(&other)); } virtual ~base_helper() noexcept { @@ -43,7 +43,7 @@ public: } virtual bool operator<(const T & other) const { - return typeid(*this).before(typeid(other)); + return typeid(this).before(typeid(&other)); } }; @@ -57,6 +57,10 @@ public: virtual T* plunder() && = 0; + bool operator!=(const T& other) const { + return !(*this == other); + } + virtual bool operator==(const T& other) const = 0; virtual bool operator<(const T& other) const = 0; diff --git a/alib2data/src/string/StringBase.cpp b/alib2data/src/string/StringBase.cpp deleted file mode 100644 index de34c74167d00c63335d6822ce99700fdebe4e98..0000000000000000000000000000000000000000 --- a/alib2data/src/string/StringBase.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * StringBase.cpp - * - * Created on: Mar 26, 2013 - * Author: Jan Travnicek - */ - -#include "StringBase.h" -#include <typeinfo> - -#include "LinearString.h" -#include "CyclicString.h" -#include "Epsilon.h" -#include <algorithm> - -namespace string { - -StringBase::~StringBase() noexcept { - -} - -bool StringBase::operator>=(const StringBase& other) const { - return !(*this < other); -} - -bool StringBase::operator<=(const StringBase& other) const { - return !(*this > other); -} - -bool StringBase::operator !=(const StringBase& other) const { - return !(*this == other); -} - -std::ostream& operator<<(std::ostream& out, const StringBase& string) { - string >> out; - return out; -} - -} /* namespace string */ diff --git a/alib2data/src/string/StringBase.h b/alib2data/src/string/StringBase.h index 374df8863eae87df8eb2795ebf2732813e3fcc27..e608f6bdef07ee1e14e5a7604d725a5a3314ed11 100644 --- a/alib2data/src/string/StringBase.h +++ b/alib2data/src/string/StringBase.h @@ -8,10 +8,8 @@ #ifndef STRING_BASE_H_ #define STRING_BASE_H_ -#include "../label/LabelBase.h" -#include <ostream> -#include <set> -#include "../alphabet/Symbol.h" +#include "../std/visitor.hpp" +#include "../common/base.hpp" namespace string { @@ -22,40 +20,7 @@ class Epsilon; /** * Represents string in an alphabet. */ -class StringBase : public std::elementBase<Epsilon, LinearString, CyclicString> { -public: - virtual ~StringBase() noexcept; - - virtual StringBase* clone() const = 0; - virtual StringBase* plunder() && = 0; - - bool operator>=(const StringBase& other) const; - - bool operator<=(const StringBase& other) const; - - bool operator!=(const StringBase& other) const; - - virtual bool operator==(const StringBase& other) const = 0; - virtual bool operator==(const LinearString& other) const = 0; - virtual bool operator==(const CyclicString& other) const = 0; - virtual bool operator==(const Epsilon& other) const = 0; - - virtual bool operator<(const StringBase& other) const = 0; - virtual bool operator<(const LinearString& other) const = 0; - virtual bool operator<(const CyclicString& other) const = 0; - virtual bool operator<(const Epsilon& other) const = 0; - virtual bool operator>(const StringBase& other) const = 0; - - /** - * Prints XML representation of the String to the output stream. - * @param out output stream to which print the String - * @param string String to print - */ - friend std::ostream& operator<<(std::ostream&, const StringBase&); - - virtual void operator>>(std::ostream& out) const = 0; - - virtual operator std::string () const = 0; +class StringBase : public alib::base<StringBase, Epsilon, LinearString, CyclicString>, public std::elementBase<Epsilon, LinearString, CyclicString> { }; } /* namespace string */