Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
Catch::TablePrinter Class Reference

Public Member Functions

 TablePrinter (std::ostream &os, std::vector< ColumnInfo > columnInfos)
 
auto columnInfos () const -> std::vector< ColumnInfo > const &
 
void open ()
 
void close ()
 

Friends

template<typename T >
TablePrinteroperator<< (TablePrinter &tp, T const &value)
 
TablePrinteroperator<< (TablePrinter &tp, ColumnBreak)
 
TablePrinteroperator<< (TablePrinter &tp, RowBreak)
 

Detailed Description

Definition at line 266 of file catch_reporter_console.cpp.

Constructor & Destructor Documentation

◆ TablePrinter()

Catch::TablePrinter::TablePrinter ( std::ostream & os,
std::vector< ColumnInfo > columnInfos )
inline

Definition at line 274 of file catch_reporter_console.cpp.

275 : m_os( os ),
276 m_columnInfos( std::move( columnInfos ) ) {}
auto columnInfos() const -> std::vector< ColumnInfo > const &
os_t os

Member Function Documentation

◆ close()

void Catch::TablePrinter::close ( )
inline

Definition at line 292 of file catch_reporter_console.cpp.

292 {
293 if (m_isOpen) {
294 *this << RowBreak();
295 m_os << std::endl;
296 m_isOpen = false;
297 }
298 }

◆ columnInfos()

auto Catch::TablePrinter::columnInfos ( ) const -> std::vector<ColumnInfo> const&
inline

Definition at line 278 of file catch_reporter_console.cpp.

278 {
279 return m_columnInfos;
280 }

◆ open()

void Catch::TablePrinter::open ( )
inline

Definition at line 282 of file catch_reporter_console.cpp.

282 {
283 if (!m_isOpen) {
284 m_isOpen = true;
285 *this << RowBreak();
286 for (auto const& info : m_columnInfos)
287 *this << info.name << ColumnBreak();
288 *this << RowBreak();
289 m_os << Catch::getLineOfChars<'-'>() << "\n";
290 }
291 }
char const * getLineOfChars()
Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ operator<< [1/3]

TablePrinter & operator<< ( TablePrinter & tp,
ColumnBreak  )
friend

Definition at line 306 of file catch_reporter_console.cpp.

306 {
307 auto colStr = tp.m_oss.str();
308 // This takes account of utf8 encodings
309 auto strSize = Catch::StringRef(colStr).numberOfCharacters();
310 tp.m_oss.str("");
311 tp.open();
312 if (tp.m_currentColumn == static_cast<int>(tp.m_columnInfos.size() - 1)) {
313 tp.m_currentColumn = -1;
314 tp.m_os << "\n";
315 }
316 tp.m_currentColumn++;
317
318 auto colInfo = tp.m_columnInfos[tp.m_currentColumn];
319 auto padding = (strSize + 2 < static_cast<std::size_t>(colInfo.width))
320 ? std::string(colInfo.width - (strSize + 2), ' ')
321 : std::string();
322 if (colInfo.justification == ColumnInfo::Left)
323 tp.m_os << colStr << padding << " ";
324 else
325 tp.m_os << padding << colStr << " ";
326 return tp;
327 }
auto numberOfCharacters() const noexcept -> size_type

◆ operator<< [2/3]

TablePrinter & operator<< ( TablePrinter & tp,
RowBreak  )
friend

Definition at line 329 of file catch_reporter_console.cpp.

329 {
330 if (tp.m_currentColumn > 0) {
331 tp.m_os << "\n";
332 tp.m_currentColumn = -1;
333 }
334 return tp;
335 }

◆ operator<< [3/3]

template<typename T >
TablePrinter & operator<< ( TablePrinter & tp,
T const & value )
friend

Definition at line 301 of file catch_reporter_console.cpp.

301 {
302 tp.m_oss << value;
303 return tp;
304 }
#define value
Definition pkcs11.h:157

The documentation for this class was generated from the following file: