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

Method paddedLeft

JUCE/modules/juce_core/text/juce_String.cpp:1170–1195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1168}
1169
1170String 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
1197String String::paddedRight (const juce_wchar padCharacter, int minimumLength) const
1198{

Callers 8

toDisplayStringMethod · 0.80
getAsCodeFunction · 0.80
getTextFromValueMethod · 0.80
getOpDisassemblyMethod · 0.80
toStringMethod · 0.80
toStringMethod · 0.80
writeEscapedCharMethod · 0.80
hexString8DigitsFunction · 0.80

Calls 5

PreallocationBytesClass · 0.85
isEmptyMethod · 0.45
getAddressMethod · 0.45
writeMethod · 0.45
writeAllMethod · 0.45

Tested by

no test coverage detected