//============================================================================== String StringArray::joinIntoString (const String& separator, int start, int numberToJoin) const { const int last = (numberToJoin < 0) ? size() : jmin (size(), start + numberToJoin); if (start < 0) start = 0; if (start >= last) return String::empty; if (start == last - 1) return strings.getReference (start); const size_t separatorBytes = separator.getCharPointer().sizeInBytes() - sizeof (String::CharPointerType::CharType); size_t bytesNeeded = separatorBytes * (last - start - 1); for (int i = start; i < last; ++i) bytesNeeded += strings.getReference(i).getCharPointer().sizeInBytes() - sizeof (String::CharPointerType::CharType); String result; result.preallocateBytes (bytesNeeded); String::CharPointerType dest (result.getCharPointer()); while (start < last) { const String& s = strings.getReference (start); if (! s.isEmpty()) dest.writeAll (s.getCharPointer()); if (++start < last && separatorBytes > 0) dest.writeAll (separator.getCharPointer()); } dest.writeNull(); return result; }