MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / joinIntoString

Method joinIntoString

JUCE/modules/juce_core/text/juce_StringArray.cpp:293–331  ·  view source on GitHub ↗

==============================================================================

Source from the content-addressed store, hash-verified

291
292//==============================================================================
293String StringArray::joinIntoString (StringRef separator, int start, int numberToJoin) const
294{
295 auto last = (numberToJoin < 0) ? size()
296 : jmin (size(), start + numberToJoin);
297
298 if (start < 0)
299 start = 0;
300
301 if (start >= last)
302 return {};
303
304 if (start == last - 1)
305 return strings.getReference (start);
306
307 auto separatorBytes = separator.text.sizeInBytes() - sizeof (String::CharPointerType::CharType);
308 auto bytesNeeded = (size_t) (last - start - 1) * separatorBytes;
309
310 for (int i = start; i < last; ++i)
311 bytesNeeded += strings.getReference(i).getCharPointer().sizeInBytes() - sizeof (String::CharPointerType::CharType);
312
313 String result;
314 result.preallocateBytes (bytesNeeded);
315
316 auto dest = result.getCharPointer();
317
318 while (start < last)
319 {
320 auto& s = strings.getReference (start);
321
322 if (! s.isEmpty())
323 dest.writeAll (s.getCharPointer());
324
325 if (++start < last && separatorBytes > 0)
326 dest.writeAll (separator.text);
327 }
328
329 dest.writeNull();
330 return result;
331}
332
333int StringArray::addTokens (StringRef text, const bool preserveQuotedStrings)
334{

Callers 15

buttonClickedMethod · 0.80
labelTextChangedMethod · 0.80
snipsItemClickedMethod · 0.80
menuItemSelectedMethod · 0.80
saveSettingsMethod · 0.80
getStringFromFontMethod · 0.80
panelFileOpenedMethod · 0.80
getPluginDescriptionMethod · 0.80
ScanJobClass · 0.80
setDeadMansPedalFileMethod · 0.80
readFunction · 0.80
convertToMP3Method · 0.80

Calls 8

jminFunction · 0.85
getReferenceMethod · 0.80
preallocateBytesMethod · 0.80
sizeFunction · 0.70
sizeInBytesMethod · 0.45
isEmptyMethod · 0.45
writeAllMethod · 0.45
writeNullMethod · 0.45

Tested by

no test coverage detected