Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
clara::TextFlow::Columns::iterator Class Reference

#include <clara.hpp>

Public Types

using difference_type = std::ptrdiff_t
 
using value_type = std::string
 
using pointer = value_type*
 
using reference = value_type&
 
using iterator_category = std::forward_iterator_tag
 

Public Member Functions

 iterator (Columns const &columns)
 
auto operator== (iterator const &other) const -> bool
 
auto operator!= (iterator const &other) const -> bool
 
auto operator* () const -> std::string
 
auto operator++ () -> iterator &
 
auto operator++ (int) -> iterator
 

Detailed Description

Definition at line 256 of file clara.hpp.

Member Typedef Documentation

◆ difference_type

Definition at line 275 of file clara.hpp.

◆ iterator_category

using clara::TextFlow::Columns::iterator::iterator_category = std::forward_iterator_tag

Definition at line 279 of file clara.hpp.

◆ pointer

◆ reference

◆ value_type

Definition at line 276 of file clara.hpp.

Constructor & Destructor Documentation

◆ iterator()

clara::TextFlow::Columns::iterator::iterator ( Columns const & columns)
inlineexplicit

Definition at line 281 of file clara.hpp.

282 : m_columns( columns.m_columns ),
283 m_activeIterators( m_columns.size() )
284 {
285 m_iterators.reserve( m_columns.size() );
286
287 for( auto const& col : m_columns )
288 m_iterators.push_back( col.begin() );
289 }

Member Function Documentation

◆ operator!=()

auto clara::TextFlow::Columns::iterator::operator!= ( iterator const & other) const -> bool
inline

Definition at line 294 of file clara.hpp.

294 {
295 return m_iterators != other.m_iterators;
296 }

◆ operator*()

auto clara::TextFlow::Columns::iterator::operator* ( ) const -> std::string
inline

Definition at line 297 of file clara.hpp.

297 {
298 std::string row, padding;
299
300 for( size_t i = 0; i < m_columns.size(); ++i ) {
301 auto width = m_columns[i].width();
302 if( m_iterators[i] != m_columns[i].end() ) {
303 std::string col = *m_iterators[i];
304 row += padding + col;
305 if( col.size() < width )
306 padding = std::string( width - col.size(), ' ' );
307 else
308 padding = "";
309 }
310 else {
311 padding += std::string( width, ' ' );
312 }
313 }
314 return row;
315 }
auto end() const -> iterator
Definition clara.hpp:332
Here is the call graph for this function:

◆ operator++() [1/2]

auto clara::TextFlow::Columns::iterator::operator++ ( ) -> iterator&
inline

Definition at line 316 of file clara.hpp.

316 {
317 for( size_t i = 0; i < m_columns.size(); ++i ) {
318 if (m_iterators[i] != m_columns[i].end())
319 ++m_iterators[i];
320 }
321 return *this;
322 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator++() [2/2]

auto clara::TextFlow::Columns::iterator::operator++ ( int ) -> iterator
inline

Definition at line 323 of file clara.hpp.

323 {
324 iterator prev( *this );
325 operator++();
326 return prev;
327 }
auto operator++() -> iterator &
Definition clara.hpp:316
Here is the call graph for this function:

◆ operator==()

auto clara::TextFlow::Columns::iterator::operator== ( iterator const & other) const -> bool
inline

Definition at line 291 of file clara.hpp.

291 {
292 return m_iterators == other.m_iterators;
293 }

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