catch2/include/internal/catch_line_wrap.h

59 lines
1.8 KiB
C
Raw Normal View History

/*
* Created by Phil on 11/1/2013.
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef TWOBLUECUBES_CATCH_LINE_WRAP_H_INCLUDED
#define TWOBLUECUBES_CATCH_LINE_WRAP_H_INCLUDED
#include <string>
#include <vector>
namespace Catch {
class LineWrapper {
public:
LineWrapper();
LineWrapper& setIndent( std::size_t _indent );
LineWrapper& setInitialIndent( std::size_t _initalIndent );
LineWrapper& setRight( std::size_t _right );
LineWrapper& setTabChar( char _tabChar );
LineWrapper& wrap( std::string const& _str );
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(); }
std::string const& last() const { return lines.back(); }
std::size_t size() const { return lines.size(); }
std::string const& operator[]( std::size_t _index ) const { return lines[_index]; }
friend std::ostream& operator << ( std::ostream& _stream, LineWrapper const& _lineWrapper );
private:
void wrapInternal( std::string const& _str );
void addLine( const std::string& _line );
bool isWrapPoint( char c );
std::size_t getCurrentIndent() const;
std::size_t right;
std::size_t nextTab;
std::size_t tab;
std::size_t indent;
std::size_t initialIndent;
std::string wrappableChars;
char tabChar;
int recursionCount;
std::vector<std::string> lines;
};
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_LINE_WRAP_H_INCLUDED