Refactored string wrapper

- to be much more flexible (writes to vector)
- fixed a couple of bugs
This commit is contained in:
Phil Nash 2013-03-27 19:08:16 +00:00
parent dd26e889b5
commit b052bd729a
6 changed files with 806 additions and 316 deletions

View file

@ -9,11 +9,39 @@
#define TWOBLUECUBES_CATCH_LINE_WRAP_H_INCLUDED
#include <string>
#include <vector>
namespace Catch {
void wrapLongStrings( std::ostream& stream, const std::string& str, std::size_t columns, std::size_t indent = 0 );
std::string wrapLongStrings( const std::string& str, std::size_t columns, std::size_t indent = 0 );
class LineWrapper {
public:
LineWrapper( std::size_t _indent, std::size_t _right );
LineWrapper( std::size_t _right );
LineWrapper();
LineWrapper& setIndent( std::size_t _indent );
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(); }
private:
void wrapInternal( std::string const& _str );
void addLine( const std::string& _line );
std::string indent;
std::size_t right;
std::size_t nextTab;
std::size_t tab;
std::vector<std::string> lines;
};
} // end namespace Catch