diff --git a/src/textstream/textstream.h b/src/textstream/textstream.h index 9b17b32..7b48818 100644 --- a/src/textstream/textstream.h +++ b/src/textstream/textstream.h @@ -198,6 +198,12 @@ public: TextStreamBase & operator<<(const TextStreamBase & arg); + template + bool operator==(const TextStreamBase & stream) const; + + template + bool operator!=(const TextStreamBase & stream) const; + // min width for integer output // if the output value has less digits then first zeroes are added @@ -1206,6 +1212,46 @@ return *this; } +template +template +bool TextStreamBase::operator==(const TextStreamBase & stream) const +{ + bool are_the_same = false; + + /* + * at the moment we do not make any conversions for == and != operators + * this may change in the future + */ + if( sizeof(char_type) == sizeof(arg_char_type) && size() == stream.size() ) + { + are_the_same = true; + const_iterator i1 = begin(); + const_iterator i2 = stream.begin(); + const_iterator i1_end = end(); + + while( i1 != i1_end ) + { + if( *i1 != *i2 ) + { + are_the_same = false; + break; + } + + ++i1; + ++i2; + } + } + + return are_the_same; +} + + +template +template +bool TextStreamBase::operator!=(const TextStreamBase & stream) const +{ + return !operator==(stream); +}