MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / Column

Class Column

unittests/catch.hpp:5281–5444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5279 class Columns;
5280
5281 class Column {
5282 std::vector<std::string> m_strings;
5283 size_t m_width = CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH;
5284 size_t m_indent = 0;
5285 size_t m_initialIndent = std::string::npos;
5286
5287 public:
5288 class iterator {
5289 friend Column;
5290
5291 Column const& m_column;
5292 size_t m_stringIndex = 0;
5293 size_t m_pos = 0;
5294
5295 size_t m_len = 0;
5296 size_t m_end = 0;
5297 bool m_suffix = false;
5298
5299 iterator( Column const& column, size_t stringIndex )
5300 : m_column( column ),
5301 m_stringIndex( stringIndex )
5302 {}
5303
5304 auto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; }
5305
5306 auto isBoundary( size_t at ) const -> bool {
5307 assert( at > 0 );
5308 assert( at <= line().size() );
5309
5310 return at == line().size() ||
5311 ( isWhitespace( line()[at] ) && !isWhitespace( line()[at-1] ) ) ||
5312 isBreakableBefore( line()[at] ) ||
5313 isBreakableAfter( line()[at-1] );
5314 }
5315
5316 void calcLength() {
5317 assert( m_stringIndex < m_column.m_strings.size() );
5318
5319 m_suffix = false;
5320 auto width = m_column.m_width-indent();
5321 m_end = m_pos;
5322 while( m_end < line().size() && line()[m_end] != '\n' )
5323 ++m_end;
5324
5325 if( m_end < m_pos + width ) {
5326 m_len = m_end - m_pos;
5327 }
5328 else {
5329 size_t len = width;
5330 while (len > 0 && !isBoundary(m_pos + len))
5331 --len;
5332 while (len > 0 && isWhitespace( line()[m_pos + len - 1] ))
5333 --len;
5334
5335 if (len > 0) {
5336 m_len = len;
5337 } else {
5338 m_suffix = true;

Callers 10

writeToStreamMethod · 0.85
listTestsFunction · 0.85
listTagsFunction · 0.85
listReportersFunction · 0.85
SessionMethod · 0.85
applyCommandLineMethod · 0.85
printMessageMethod · 0.85
benchmarkStartingMethod · 0.85
printHeaderStringMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected