| 1168 | } |
| 1169 | |
| 1170 | String String::paddedLeft (const juce_wchar padCharacter, int minimumLength) const |
| 1171 | { |
| 1172 | jassert (padCharacter != 0); |
| 1173 | |
| 1174 | auto extraChars = minimumLength; |
| 1175 | auto end = text; |
| 1176 | |
| 1177 | while (! end.isEmpty()) |
| 1178 | { |
| 1179 | --extraChars; |
| 1180 | ++end; |
| 1181 | } |
| 1182 | |
| 1183 | if (extraChars <= 0 || padCharacter == 0) |
| 1184 | return *this; |
| 1185 | |
| 1186 | auto currentByteSize = (size_t) (((char*) end.getAddress()) - (char*) text.getAddress()); |
| 1187 | String result (PreallocationBytes (currentByteSize + (size_t) extraChars * CharPointerType::getBytesRequiredFor (padCharacter))); |
| 1188 | auto n = result.text; |
| 1189 | |
| 1190 | while (--extraChars >= 0) |
| 1191 | n.write (padCharacter); |
| 1192 | |
| 1193 | n.writeAll (text); |
| 1194 | return result; |
| 1195 | } |
| 1196 | |
| 1197 | String String::paddedRight (const juce_wchar padCharacter, int minimumLength) const |
| 1198 | { |
no test coverage detected