| 242 | inline CodePrinter::Indent CodePrinter::createIndentWithBraces (size_t size) { return createIndent (size, '{', '}'); } |
| 243 | |
| 244 | inline std::string CodePrinter::toString() const |
| 245 | { |
| 246 | std::string s; |
| 247 | auto totalLen = lines.size() * newLineString.length() + 1; |
| 248 | |
| 249 | for (auto& l : lines) |
| 250 | if (auto contentLen = getLengthWithTrimmedEnd (l.line)) |
| 251 | totalLen += l.indent + contentLen; |
| 252 | |
| 253 | s.reserve (totalLen); |
| 254 | |
| 255 | for (auto& l : lines) |
| 256 | { |
| 257 | if (auto contentLen = getLengthWithTrimmedEnd (l.line)) |
| 258 | { |
| 259 | s.append (l.indent, ' '); |
| 260 | s.append (l.line.begin(), l.line.begin() + static_cast<std::string::difference_type> (contentLen)); |
| 261 | } |
| 262 | |
| 263 | s.append (newLineString); |
| 264 | } |
| 265 | |
| 266 | return s; |
| 267 | } |
| 268 | |
| 269 | static inline size_t findLineSplitPoint (std::string_view text, size_t targetLength) |
| 270 | { |