mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-20 01:14:20 +00:00
Couple of new methods for String. Cleaned up some component code to use SafePointers.
This commit is contained in:
parent
c9c8824294
commit
b974203d0f
22 changed files with 328 additions and 326 deletions
|
|
@ -1157,7 +1157,7 @@ void String::vprintf (const tchar* const pf, va_list& args) throw()
|
|||
|
||||
//==============================================================================
|
||||
const String String::repeatedString (const tchar* const stringToRepeat,
|
||||
int numberOfTimesToRepeat) throw()
|
||||
int numberOfTimesToRepeat)
|
||||
{
|
||||
const int len = CharacterFunctions::length (stringToRepeat);
|
||||
String result ((int) (len * numberOfTimesToRepeat + 1), (int) 0);
|
||||
|
|
@ -1174,6 +1174,48 @@ const String String::repeatedString (const tchar* const stringToRepeat,
|
|||
return result;
|
||||
}
|
||||
|
||||
const String String::paddedLeft (const juce_wchar padCharacter, int minimumLength) const
|
||||
{
|
||||
if (padCharacter == 0)
|
||||
{
|
||||
jassertfalse;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const int len = length();
|
||||
|
||||
if (len >= minimumLength)
|
||||
return *this;
|
||||
|
||||
String result ((int) minimumLength + 1, (int) 0);
|
||||
|
||||
tchar* n = result.text->text;
|
||||
|
||||
minimumLength -= len;
|
||||
while (--minimumLength >= 0)
|
||||
*n++ = padCharacter;
|
||||
|
||||
*n = 0;
|
||||
CharacterFunctions::append (n, text->text);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const String String::paddedRight (const juce_wchar padCharacter, int minimumLength) const
|
||||
{
|
||||
if (padCharacter == 0)
|
||||
{
|
||||
jassertfalse;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const int paddingNeeded = minimumLength - length();
|
||||
if (paddingNeeded <= 0)
|
||||
return *this;
|
||||
|
||||
return *this + String::empty.paddedLeft (padCharacter, paddingNeeded);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
const String String::replaceSection (int index,
|
||||
int numCharsToReplace,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue