From a36055e1dc8dd08e634b189688c16773debc6a6f Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Sat, 9 Aug 2014 20:48:13 +0200
Subject: [PATCH] to string for strings

---
 alib2data/src/string/CyclicString.cpp | 11 +++++++++--
 alib2data/src/string/Epsilon.cpp      |  4 +---
 alib2data/src/string/LinearString.cpp | 11 +++++++++--
 alib2data/src/string/StringBase.cpp   |  8 ++++++++
 alib2data/src/string/StringBase.h     | 11 +++++++----
 5 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/alib2data/src/string/CyclicString.cpp b/alib2data/src/string/CyclicString.cpp
index 0985c6c2f3..7c7533a55b 100644
--- a/alib2data/src/string/CyclicString.cpp
+++ b/alib2data/src/string/CyclicString.cpp
@@ -154,8 +154,15 @@ void CyclicString::operator >>(std::ostream& out) const {
 
 CyclicString::operator std::string () const {
 	std::stringstream ss;
-	ss << *this;
-	return ss.str(); 
+	if( this->isEmpty() ) {
+		ss << "E";
+	} else {
+		ss << "<";
+		for(const alphabet::Symbol& symbol : this->m_Data)
+			ss << (std::string) symbol;
+		ss << ">";
+	}
+	return std::move(ss).str();
 }
 
 } /* namespace string */
diff --git a/alib2data/src/string/Epsilon.cpp b/alib2data/src/string/Epsilon.cpp
index 9fd1af518c..954afcc1b9 100644
--- a/alib2data/src/string/Epsilon.cpp
+++ b/alib2data/src/string/Epsilon.cpp
@@ -90,9 +90,7 @@ void Epsilon::operator>>(std::ostream& out) const {
 }
 
 Epsilon::operator std::string() const {
-	std::stringstream ss;
-	ss << *this;
-	return ss.str();
+	return "E";
 }
 
 Epsilon Epsilon::EPSILON = Epsilon();
diff --git a/alib2data/src/string/LinearString.cpp b/alib2data/src/string/LinearString.cpp
index 989e0cf81e..155407c1a6 100644
--- a/alib2data/src/string/LinearString.cpp
+++ b/alib2data/src/string/LinearString.cpp
@@ -166,8 +166,15 @@ void LinearString::operator >>(std::ostream& out) const {
 
 LinearString::operator std::string () const {
 	std::stringstream ss;
-	ss << *this;
-	return ss.str(); 
+	if( this->isEmpty() ) {
+		ss << "E";
+	} else {
+		ss << "\"";
+		for(const alphabet::Symbol& symbol : this->m_Data)
+			ss << (std::string) symbol;
+		ss << "\"";
+	}
+	return std::move(ss).str();
 }
 
 } /* namespace string */
diff --git a/alib2data/src/string/StringBase.cpp b/alib2data/src/string/StringBase.cpp
index c9c36fe787..de34c74167 100644
--- a/alib2data/src/string/StringBase.cpp
+++ b/alib2data/src/string/StringBase.cpp
@@ -19,6 +19,14 @@ 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);
 }
diff --git a/alib2data/src/string/StringBase.h b/alib2data/src/string/StringBase.h
index d998caba35..fc8edb5e45 100644
--- a/alib2data/src/string/StringBase.h
+++ b/alib2data/src/string/StringBase.h
@@ -30,19 +30,22 @@ public:
 	virtual StringBase* clone() const = 0;
 	virtual StringBase* plunder() && = 0; 
 
-	virtual bool operator <(const StringBase& other) const = 0;
-	virtual bool operator ==(const StringBase& other) const = 0;
-	virtual bool operator >(const StringBase& other) const = 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.
-- 
GitLab