22//
33// A single-header library for wrapping and laying out basic text, by Phil Nash
44//
5- // This work is licensed under the BSD 2-Clause license.
6- // See the accompanying LICENSE file, or the one at https ://opensource. org/licenses/BSD-2-Clause
5+ // Distributed under the Boost Software License, Version 1.0. (See accompanying
6+ // file LICENSE.txt or copy at http ://www.boost. org/LICENSE_1_0.txt)
77//
88// This project is hosted at https://github.com/philsquared/textflowcpp
99
1616#include < vector>
1717
1818#ifndef CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH
19- #define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80
19+ #define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH
2020#endif
2121
2222
@@ -39,7 +39,7 @@ namespace clara { namespace TextFlow {
3939
4040 class Column {
4141 std::vector<std::string> m_strings;
42- size_t m_width = CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH ;
42+ size_t m_width = TEXTFLOW_CONFIG_CONSOLE_WIDTH ;
4343 size_t m_indent = 0 ;
4444 size_t m_initialIndent = std::string::npos;
4545
@@ -110,6 +110,12 @@ namespace clara { namespace TextFlow {
110110 }
111111
112112 public:
113+ using difference_type = std::ptrdiff_t ;
114+ using value_type = std::string;
115+ using pointer = value_type*;
116+ using reference = value_type&;
117+ using iterator_category = std::forward_iterator_tag;
118+
113119 explicit iterator ( Column const & column ) : m_column( column ) {
114120 assert ( m_column.m_width > m_column.m_indent );
115121 assert ( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent );
@@ -121,10 +127,7 @@ namespace clara { namespace TextFlow {
121127 auto operator *() const -> std::string {
122128 assert ( m_stringIndex < m_column.m_strings .size () );
123129 assert ( m_pos <= m_end );
124- if ( m_pos + m_column.m_width < m_end )
125- return addIndentAndSuffix (line ().substr (m_pos, m_len));
126- else
127- return addIndentAndSuffix (line ().substr (m_pos, m_end - m_pos));
130+ return addIndentAndSuffix (line ().substr (m_pos, m_len));
128131 }
129132
130133 auto operator ++() -> iterator& {
@@ -234,6 +237,12 @@ namespace clara { namespace TextFlow {
234237 }
235238
236239 public:
240+ using difference_type = std::ptrdiff_t ;
241+ using value_type = std::string;
242+ using pointer = value_type*;
243+ using reference = value_type&;
244+ using iterator_category = std::forward_iterator_tag;
245+
237246 explicit iterator ( Columns const & columns )
238247 : m_columns( columns.m_columns ),
239248 m_activeIterators( m_columns.size() )
@@ -323,6 +332,6 @@ namespace clara { namespace TextFlow {
323332 cols += other;
324333 return cols;
325334 }
326- }} // namespace clara::TextFlow
335+ }
327336
328337#endif // CLARA_TEXTFLOW_HPP_INCLUDED
0 commit comments