| 100 | //! Converts a range of items into strings. |
| 101 | template <std::forward_iterator TIter, class TFormatter> |
| 102 | std::vector<TString> ConvertToStrings( |
| 103 | const TIter& begin, |
| 104 | const TIter& end, |
| 105 | const TFormatter& formatter, |
| 106 | size_t maxSize) |
| 107 | { |
| 108 | std::vector<TString> result; |
| 109 | for (auto it = begin; it != end; ++it) { |
| 110 | TStringBuilder builder; |
| 111 | formatter(&builder, *it); |
| 112 | result.push_back(builder.Flush()); |
| 113 | if (result.size() == maxSize) { |
| 114 | break; |
| 115 | } |
| 116 | } |
| 117 | return result; |
| 118 | } |
| 119 | |
| 120 | //! A handy shortcut with the default formatter. |
| 121 | template <std::forward_iterator TIter> |