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

Function findLineSplitPoint

choc/text/choc_CodePrinter.h:269–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267}
268
269static inline size_t findLineSplitPoint (std::string_view text, size_t targetLength)
270{
271 size_t pos = 0;
272 char currentQuote = 0;
273 auto canBreakAfterChar = [] (char c) { return c == ' ' || c == '\t' || c == ',' || c == ';' || c == '\n'; };
274
275 for (;;)
276 {
277 if (pos == text.length())
278 return pos;
279
280 auto c = text[pos++];
281
282 if (pos >= targetLength && currentQuote == 0 && canBreakAfterChar (c))
283 return pos;
284
285 if (c == '"' || c == '\'')
286 {
287 if (currentQuote == 0) currentQuote = c;
288 else if (currentQuote == c) currentQuote = 0;
289 }
290 }
291}
292
293inline void CodePrinter::append (std::string s)
294{

Callers 1

appendMethod · 0.85

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected