1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-04 03:40:07 +00:00

Added method String::clear(), and used it to replace a few uses of String::empty.

This commit is contained in:
jules 2013-12-01 11:32:39 +00:00
parent 488fe56ffe
commit 2623f4d1e1
30 changed files with 51 additions and 42 deletions

View file

@ -152,7 +152,7 @@ String BinaryResources::browseForResource (const String& title,
TRANS("Adding Resource"),
TRANS("Failed to load the file!"));
name = String::empty;
name.clear();
}
return name;

View file

@ -469,7 +469,7 @@ void JucerDocument::fillInGeneratedCode (GeneratedCode& code) const
String baseClassToAdd (baseClasses[i]);
if (baseClassToAdd == "Component" || baseClassToAdd == "Button")
baseClassToAdd = String::empty;
baseClassToAdd.clear();
String& s = code.getCallbackCode (baseClassToAdd, returnValues[i], methods[i], false);

View file

@ -329,7 +329,7 @@ private:
gradPos2 = RelativePositionedRectangle();
gradPos2.rect = PositionedRectangle ("100 100");
imageResourceName = String::empty;
imageResourceName.clear();
imageOpacity = 1.0;
imageAnchor = RelativePositionedRectangle();
imageAnchor.rect = PositionedRectangle ("0 0");

View file

@ -361,8 +361,8 @@ void AudioDeviceManager::getAudioDeviceSetup (AudioDeviceSetup& setup)
void AudioDeviceManager::deleteCurrentDevice()
{
currentAudioDevice = nullptr;
currentSetup.inputDeviceName = String::empty;
currentSetup.outputDeviceName = String::empty;
currentSetup.inputDeviceName.clear();
currentSetup.outputDeviceName.clear();
}
void AudioDeviceManager::setCurrentAudioDeviceType (const String& type,

View file

@ -190,7 +190,7 @@ public:
int numOutputChannelsNeeded,
const XmlElement* savedState,
bool selectDefaultDeviceOnFailure,
const String& preferredDefaultDeviceName = String::empty,
const String& preferredDefaultDeviceName = String(),
const AudioDeviceSetup* preferredSetupOptions = 0);
/** Returns some XML representing the current state of the manager.

View file

@ -159,7 +159,7 @@ public:
if (sampleRate != (int) requestedSampleRate)
return "Sample rate not allowed";
lastError = String::empty;
lastError.clear();
int preferredBufferSize = (bufferSize <= 0) ? getDefaultBufferSize() : bufferSize;
numDeviceInputChannels = 0;

View file

@ -105,7 +105,7 @@ public:
{
close();
lastError = String::empty;
lastError.clear();
sampleRate = (int) requestedSampleRate;
int preferredBufferSize = (bufferSize <= 0) ? getDefaultBufferSize() : bufferSize;

View file

@ -80,7 +80,7 @@ public:
{
close();
lastError = String::empty;
lastError.clear();
preferredBufferSize = (bufferSize <= 0) ? getDefaultBufferSize() : bufferSize;
// xxx set up channel mapping

View file

@ -482,7 +482,7 @@ public:
{
close();
error = String::empty;
error.clear();
sampleRate = newSampleRate;
bufferSize = newBufferSize;

View file

@ -235,7 +235,7 @@ public:
return lastError;
}
lastError = String::empty;
lastError.clear();
close();
juce::jack_set_process_callback (client, processCallback, this);

View file

@ -456,7 +456,7 @@ public:
updateClockSources();
currentSampleRate = getSampleRate();
error = String::empty;
error.clear();
buffersCreated = false;
setSampleRate (sampleRate);
@ -617,7 +617,7 @@ public:
void close()
{
error = String::empty;
error.clear();
stopTimer();
stop();
@ -1181,7 +1181,7 @@ private:
numActiveOutputChans = 0;
currentCallback = nullptr;
error = String::empty;
error.clear();
if (getName().isEmpty())
return error;

View file

@ -924,7 +924,7 @@ public:
double sampleRate, int bufferSizeSamples)
{
close();
lastError = String::empty;
lastError.clear();
if (sampleRates.size() == 0 && inputDevice != nullptr && outputDevice != nullptr)
{

View file

@ -803,7 +803,7 @@ extern "C" BOOL WINAPI DllMain (HANDLE instance, DWORD reason, LPVOID)
case DLL_PROCESS_DETACH:
log ("DLL_PROCESS_DETACH");
browserVersionDesc = String::empty;
browserVersionDesc.clear();
// IE has a tendency to leak our objects, so although none of this should be
// necessary, it's best to make sure..

View file

@ -1031,7 +1031,7 @@ NPError NPP_Destroy (NPP npp, NPSavedData** save)
{
log ("shutdownJuce_GUI()");
shutdownJuce_GUI();
browserVersionDesc = String::empty;
browserVersionDesc.clear();
}
}

View file

@ -741,7 +741,7 @@ public:
@see revealToUser
*/
bool startAsProcess (const String& parameters = String::empty) const;
bool startAsProcess (const String& parameters = String()) const;
/** Opens Finder, Explorer, or whatever the OS uses, to show the user this file's location.
@see startAsProcess

View file

@ -386,7 +386,7 @@ void StreamingSocket::close()
::close (handle);
#endif
hostName = String::empty;
hostName.clear();
portNumber = 0;
handle = -1;
isListener = false;
@ -506,7 +506,7 @@ void DatagramSocket::close()
::close (handle);
#endif
hostName = String::empty;
hostName.clear();
portNumber = 0;
handle = -1;
}

View file

@ -259,6 +259,12 @@ void String::swapWith (String& other) noexcept
std::swap (text, other.text);
}
void String::clear() noexcept
{
StringHolder::release (text);
text = &(emptyString.text);
}
String& String::operator= (const String& other) noexcept
{
StringHolder::retain (other.text);

View file

@ -307,6 +307,9 @@ public:
*/
inline bool isNotEmpty() const noexcept { return text[0] != 0; }
/** Resets this string to be empty. */
void clear() noexcept;
/** Case-insensitive comparison with another string. */
bool equalsIgnoreCase (const String& other) const noexcept;

View file

@ -210,7 +210,7 @@ XmlElement* XmlDocument::parseDocumentElement (String::CharPointerType textToPar
}
else
{
lastError = String::empty;
lastError.clear();
ScopedPointer<XmlElement> result (readNextElement (! onlyReadOuterDocumentElement));

View file

@ -166,7 +166,7 @@ void AttributedString::append (const AttributedString& other)
void AttributedString::clear()
{
text = String::empty;
text.clear();
attributes.clear();
}

View file

@ -58,7 +58,7 @@ void ImagePreviewComponent::timerCallback()
stopTimer();
currentThumbnail = Image::null;
currentDetails = String::empty;
currentDetails.clear();
repaint();
ScopedPointer<FileInputStream> in (fileToLoad.createInputStream());

View file

@ -1452,7 +1452,7 @@ private:
if (target != nullptr)
[(NSView*) self interpretKeyEvents: [NSArray arrayWithObject: ev]];
else
owner->stringBeingComposed = String::empty;
owner->stringBeingComposed.clear();
if ((! owner->textWasInserted) && (owner == nullptr || ! owner->redirectKeyDown (ev)))
{
@ -1490,7 +1490,7 @@ private:
}
}
owner->stringBeingComposed = String::empty;
owner->stringBeingComposed.clear();
}
}
@ -1525,7 +1525,7 @@ private:
owner->textWasInserted = true;
}
owner->stringBeingComposed = String::empty;
owner->stringBeingComposed.clear();
}
}
}

View file

@ -183,7 +183,7 @@ void FileChooser::showPlatformDialog (Array<File>& results, const String& title_
if (! SHGetPathFromIDListW (list, files))
{
files[0] = 0;
info.returnedString = String::empty;
info.returnedString.clear();
}
LPMALLOC al;

View file

@ -310,7 +310,7 @@ public:
Point<int> position;
bool isEmpty() const noexcept { return files.size() == 0 && text.isEmpty(); }
void clear() noexcept { files.clear(); text = String::empty; }
void clear() noexcept { files.clear(); text.clear(); }
};
bool handleDragMove (const DragInfo&);

View file

@ -115,7 +115,7 @@ String TooltipWindow::getTipFor (Component* const c)
void TooltipWindow::hideTip()
{
tipShowing = String::empty;
tipShowing.clear();
removeFromDesktop();
setVisible (false);
}

View file

@ -60,14 +60,14 @@ void WebBrowserComponent::stop()
void WebBrowserComponent::goBack()
{
lastURL = String::empty;
lastURL.clear();
blankPageShown = false;
}
void WebBrowserComponent::goForward()
{
lastURL = String::empty;
lastURL.clear();
}
@ -90,7 +90,7 @@ void WebBrowserComponent::reloadLastURL()
if (lastURL.isNotEmpty())
{
goToURL (lastURL, &lastHeaders, &lastPostData);
lastURL = String::empty;
lastURL.clear();
}
}

View file

@ -65,14 +65,14 @@ void WebBrowserComponent::stop()
void WebBrowserComponent::goBack()
{
lastURL = String::empty;
lastURL.clear();
blankPageShown = false;
}
void WebBrowserComponent::goForward()
{
lastURL = String::empty;
lastURL.clear();
}
@ -95,7 +95,7 @@ void WebBrowserComponent::reloadLastURL()
if (lastURL.isNotEmpty())
{
goToURL (lastURL, &lastHeaders, &lastPostData);
lastURL = String::empty;
lastURL.clear();
}
}

View file

@ -279,14 +279,14 @@ void WebBrowserComponent::stop()
void WebBrowserComponent::goBack()
{
lastURL = String::empty;
lastURL.clear();
blankPageShown = false;
browser->goBack();
}
void WebBrowserComponent::goForward()
{
lastURL = String::empty;
lastURL.clear();
browser->goForward();
}
@ -328,7 +328,7 @@ void WebBrowserComponent::reloadLastURL()
if (lastURL.isNotEmpty())
{
goToURL (lastURL, &lastHeaders, &lastPostData);
lastURL = String::empty;
lastURL.clear();
}
}

View file

@ -225,7 +225,7 @@ void WebBrowserComponent::stop()
void WebBrowserComponent::goBack()
{
lastURL = String::empty;
lastURL.clear();
blankPageShown = false;
if (browser->browser != nullptr)
@ -234,7 +234,7 @@ void WebBrowserComponent::goBack()
void WebBrowserComponent::goForward()
{
lastURL = String::empty;
lastURL.clear();
if (browser->browser != nullptr)
browser->browser->GoForward();
@ -287,7 +287,7 @@ void WebBrowserComponent::reloadLastURL()
if (lastURL.isNotEmpty())
{
goToURL (lastURL, &lastHeaders, &lastPostData);
lastURL = String::empty;
lastURL.clear();
}
}

View file

@ -840,7 +840,7 @@ void DirectShowComponent::closeMovie()
context->release();
videoLoaded = false;
videoPath = String::empty;
videoPath.clear();
}
//======================================================================