Skip to content
Snippets Groups Projects
Commit a36055e1 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

to string for strings

parent 827cdb75
No related branches found
No related tags found
No related merge requests found
......@@ -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 */
......@@ -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();
......
......@@ -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 */
......
......@@ -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);
}
......
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment