mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Simplified StringWrapper
- by changing intoStream to << overload - and removing redundant ctor
This commit is contained in:
@@ -15,7 +15,6 @@ namespace Catch {
|
||||
|
||||
class LineWrapper {
|
||||
public:
|
||||
LineWrapper( std::size_t _indent, std::size_t _right );
|
||||
LineWrapper( std::size_t _right );
|
||||
LineWrapper();
|
||||
|
||||
@@ -23,14 +22,15 @@ namespace Catch {
|
||||
LineWrapper& setRight( std::size_t _right );
|
||||
|
||||
LineWrapper& wrap( std::string const& _str );
|
||||
|
||||
std::ostream& intoStream( std::ostream& stream ) const;
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
typedef std::vector<std::string>::const_iterator const_iterator;
|
||||
|
||||
const_iterator begin() const { return lines.begin(); }
|
||||
const_iterator end() const { return lines.end(); }
|
||||
|
||||
friend std::ostream& operator << ( std::ostream& _stream, LineWrapper const& _lineWrapper );
|
||||
|
||||
private:
|
||||
void wrapInternal( std::string const& _str );
|
||||
|
@@ -12,13 +12,6 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
|
||||
LineWrapper::LineWrapper( std::size_t _indent, std::size_t _right )
|
||||
: indent( _indent, ' ' ),
|
||||
right( _right ),
|
||||
nextTab( 0 ),
|
||||
tab( 0 )
|
||||
{}
|
||||
LineWrapper::LineWrapper( std::size_t _right )
|
||||
: right( _right ),
|
||||
nextTab( 0 ),
|
||||
@@ -75,18 +68,18 @@ namespace Catch {
|
||||
addLine( _str );
|
||||
}
|
||||
|
||||
std::ostream& LineWrapper::intoStream( std::ostream& stream ) const {
|
||||
for( const_iterator it = begin(), itEnd = end();
|
||||
std::ostream& operator << ( std::ostream& _stream, LineWrapper const& _lineWrapper ) {
|
||||
for( LineWrapper::const_iterator it = _lineWrapper.begin(), itEnd = _lineWrapper.end();
|
||||
it != itEnd; ++it ) {
|
||||
if( it != begin() )
|
||||
stream << "\n";
|
||||
stream << *it;
|
||||
if( it != _lineWrapper.begin() )
|
||||
_stream << "\n";
|
||||
_stream << *it;
|
||||
}
|
||||
return stream;
|
||||
return _stream;
|
||||
}
|
||||
std::string LineWrapper::toString() const {
|
||||
std::ostringstream oss;
|
||||
intoStream( oss );
|
||||
oss << *this;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user