MCPcopy Create free account
hub / github.com/Tracktion/choc / toString

Method toString

choc/text/choc_CodePrinter.h:244–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242inline CodePrinter::Indent CodePrinter::createIndentWithBraces (size_t size) { return createIndent (size, '{', '}'); }
243
244inline 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
269static inline size_t findLineSplitPoint (std::string_view text, size_t targetLength)
270{

Callers

nothing calls this directly

Calls 6

getLengthWithTrimmedEndFunction · 0.85
appendMethod · 0.80
sizeMethod · 0.45
lengthMethod · 0.45
reserveMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected