5
5
//
6
6
// See https://github.com/philsquared/Clara for more details
7
7
8
- // Clara v1.1.4
8
+ // Clara v1.1.5
9
9
10
10
#ifndef CLARA_HPP_INCLUDED
11
11
#define CLARA_HPP_INCLUDED
34
34
//
35
35
// A single-header library for wrapping and laying out basic text, by Phil Nash
36
36
//
37
- // This work is licensed under the BSD 2-Clause license.
38
- // See the accompanying LICENSE file, or the one at https ://opensource. org/licenses/BSD-2-Clause
37
+ // Distributed under the Boost Software License, Version 1.0. (See accompanying
38
+ // file LICENSE.txt or copy at http ://www.boost. org/LICENSE_1_0.txt)
39
39
//
40
40
// This project is hosted at https://github.com/philsquared/textflowcpp
41
41
48
48
#include < vector>
49
49
50
50
#ifndef CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH
51
- #define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80
51
+ #define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH
52
52
#endif
53
53
54
54
@@ -71,7 +71,7 @@ namespace clara { namespace TextFlow {
71
71
72
72
class Column {
73
73
std::vector<std::string> m_strings;
74
- size_t m_width = CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH ;
74
+ size_t m_width = TEXTFLOW_CONFIG_CONSOLE_WIDTH ;
75
75
size_t m_indent = 0 ;
76
76
size_t m_initialIndent = std::string::npos;
77
77
@@ -142,6 +142,12 @@ namespace clara { namespace TextFlow {
142
142
}
143
143
144
144
public:
145
+ using difference_type = std::ptrdiff_t ;
146
+ using value_type = std::string;
147
+ using pointer = value_type*;
148
+ using reference = value_type&;
149
+ using iterator_category = std::forward_iterator_tag;
150
+
145
151
explicit iterator ( Column const & column ) : m_column( column ) {
146
152
assert ( m_column.m_width > m_column.m_indent );
147
153
assert ( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent );
@@ -153,10 +159,7 @@ namespace clara { namespace TextFlow {
153
159
auto operator *() const -> std::string {
154
160
assert ( m_stringIndex < m_column.m_strings .size () );
155
161
assert ( m_pos <= m_end );
156
- if ( m_pos + m_column.m_width < m_end )
157
- return addIndentAndSuffix (line ().substr (m_pos, m_len));
158
- else
159
- return addIndentAndSuffix (line ().substr (m_pos, m_end - m_pos));
162
+ return addIndentAndSuffix (line ().substr (m_pos, m_len));
160
163
}
161
164
162
165
auto operator ++() -> iterator& {
@@ -266,6 +269,12 @@ namespace clara { namespace TextFlow {
266
269
}
267
270
268
271
public:
272
+ using difference_type = std::ptrdiff_t ;
273
+ using value_type = std::string;
274
+ using pointer = value_type*;
275
+ using reference = value_type&;
276
+ using iterator_category = std::forward_iterator_tag;
277
+
269
278
explicit iterator ( Columns const & columns )
270
279
: m_columns( columns.m_columns ),
271
280
m_activeIterators( m_columns.size() )
@@ -355,7 +364,7 @@ namespace clara { namespace TextFlow {
355
364
cols += other;
356
365
return cols;
357
366
}
358
- }} // namespace clara::TextFlow
367
+ }
359
368
360
369
#endif // CLARA_TEXTFLOW_HPP_INCLUDED
361
370
0 commit comments