Browse Source

Tidied up a few bits of messy String concatenation

tags/2021-05-28
jules 8 years ago
parent
commit
51f6c5d01c
12 changed files with 49 additions and 56 deletions
  1. +7
    -6
      extras/Projucer/Source/ProjectSaving/jucer_ProjectSaver.cpp
  2. +6
    -6
      modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp
  3. +8
    -15
      modules/juce_audio_processors/processors/juce_AudioProcessor.cpp
  4. +1
    -1
      modules/juce_core/native/juce_android_Files.cpp
  5. +4
    -5
      modules/juce_core/native/juce_curl_Network.cpp
  6. +11
    -10
      modules/juce_core/network/juce_IPAddress.cpp
  7. +1
    -1
      modules/juce_core/time/juce_PerformanceCounter.h
  8. +4
    -4
      modules/juce_dsp/frequency/juce_FFT.cpp
  9. +1
    -1
      modules/juce_gui_basics/native/juce_ios_FileChooser.mm
  10. +2
    -3
      modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm
  11. +1
    -1
      modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp
  12. +3
    -3
      modules/juce_osc/osc/juce_OSCSender.cpp

+ 7
- 6
extras/Projucer/Source/ProjectSaving/jucer_ProjectSaver.cpp View File

@@ -41,6 +41,7 @@ namespace
jassert ((configs.size() & 1) == 0); // looks like a syntax error in the configs?
int maxVal = 0;
for (int i = (isInput ? 0 : 1); i < configs.size(); i += 2)
maxVal = jmax (maxVal, configs[i].getIntValue());
@@ -59,16 +60,16 @@ namespace
inline String valueToCharLiteral (const var& v)
{
String fourCharCode = v.toString().trim().substring (0, 4);
auto fourCharCode = v.toString().trim().substring (0, 4);
uint32 hexRepresentation = 0;
for (int i = 0; i < 4; ++i)
hexRepresentation = (hexRepresentation << 8U)
| (static_cast<unsigned int> (fourCharCode[i]) & 0xffU);
hexRepresentation = (hexRepresentation << 8u)
| (static_cast<unsigned int> (fourCharCode[i]) & 0xffu);
return String ("0x") + String::toHexString (static_cast<int> (hexRepresentation))
+ String (" // ")
+ CppTokeniserFunctions::addEscapeChars (fourCharCode).quoted ('\'');
return "0x" + String::toHexString (static_cast<int> (hexRepresentation))
+ " // "
+ CppTokeniserFunctions::addEscapeChars (fourCharCode).quoted ('\'');
}
}


+ 6
- 6
modules/juce_audio_formats/codecs/juce_CoreAudioFormat.cpp View File

@@ -630,7 +630,7 @@ public:
{
auto labels = CoreAudioLayouts::fromCoreAudio (tagEntry.tag);
expect (! labels.isDiscreteLayout(), String ("Tag \"") + String (tagEntry.name) + "\" is not handled by JUCE");
expect (! labels.isDiscreteLayout(), "Tag \"" + String (tagEntry.name) + "\" is not handled by JUCE");
}
}
@@ -641,7 +641,7 @@ public:
{
auto labels = CoreAudioLayouts::getSpeakerLayoutForCoreAudioTag (tagEntry.tag);
expect (labels.size() == (tagEntry.tag & 0xffff), String ("Tag \"") + String (tagEntry.name) + "\" has incorrect channel count");
expect (labels.size() == (tagEntry.tag & 0xffff), "Tag \"" + String (tagEntry.name) + "\" has incorrect channel count");
}
}
@@ -655,7 +655,7 @@ public:
for (int i = 0; i < (labels.size() - 1); ++i)
expect (labels.getReference (i) != labels.getReference (i + 1),
String ("Tag \"") + String (tagEntry.name) + "\" has the same speaker twice");
"Tag \"" + String (tagEntry.name) + "\" has the same speaker twice");
}
}
@@ -665,7 +665,7 @@ public:
for (auto tagEntry : knownTags)
expect (AudioChannelSet::channelSetWithChannels (CoreAudioLayouts::getSpeakerLayoutForCoreAudioTag (tagEntry.tag))
== CoreAudioLayouts::fromCoreAudio (tagEntry.tag),
String ("Tag \"") + String (tagEntry.name) + "\" is not converted consistantly by JUCE");
"Tag \"" + String (tagEntry.name) + "\" is not converted consistantly by JUCE");
}
{
@@ -677,7 +677,7 @@ public:
continue;
expect (CoreAudioLayouts::fromCoreAudio (tagEntry.tag) == tagEntry.equivalentChannelSet,
String ("Documentation for tag \"") + String (tagEntry.name) + "\" is incorrect");
"Documentation for tag \"" + String (tagEntry.name) + "\" is incorrect");
}
}
@@ -690,7 +690,7 @@ public:
continue;
expect (CoreAudioLayouts::toCoreAudio (tagEntry.equivalentChannelSet) == tagEntry.tag,
String ("Incorrect reverse conversion for tag \"") + String (tagEntry.name) + "\"");
"Incorrect reverse conversion for tag \"" + String (tagEntry.name) + "\"");
}
}
}


+ 8
- 15
modules/juce_audio_processors/processors/juce_AudioProcessor.cpp View File

@@ -293,15 +293,8 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL
// try setting all other buses to the identical layout
BusesLayout allTheSame;
for (int oDir = 0; oDir < 2; ++oDir)
{
bool oIsInput = (oDir == 0);
auto oBusNum = getBusCount (oIsInput);
for (int oBusIndex = 0; oBusIndex < oBusNum; ++oBusIndex)
(oIsInput ? allTheSame.inputBuses : allTheSame.outputBuses).add (requested);
}
allTheSame.inputBuses.insertMultiple (-1, requested, getBusCount (true));
allTheSame.outputBuses.insertMultiple (-1, requested, getBusCount (false));
if (checkBusesLayoutSupported (allTheSame))
{
@@ -327,18 +320,18 @@ void AudioProcessor::getNextBestLayout (const BusesLayout& desiredLayout, BusesL
}
//==============================================================================
void AudioProcessor::setPlayHead (AudioPlayHead* const newPlayHead)
void AudioProcessor::setPlayHead (AudioPlayHead* newPlayHead)
{
playHead = newPlayHead;
}
void AudioProcessor::addListener (AudioProcessorListener* const newListener)
void AudioProcessor::addListener (AudioProcessorListener* newListener)
{
const ScopedLock sl (listenerLock);
listeners.addIfNotAlreadyThere (newListener);
}
void AudioProcessor::removeListener (AudioProcessorListener* const listenerToRemove)
void AudioProcessor::removeListener (AudioProcessorListener* listenerToRemove)
{
const ScopedLock sl (listenerLock);
listeners.removeFirstMatchingValue (listenerToRemove);
@@ -348,7 +341,7 @@ void AudioProcessor::setPlayConfigDetails (int newNumIns, int newNumOuts, double
{
bool success = true;
if (getTotalNumInputChannels() != newNumIns)
if (getTotalNumInputChannels() != newNumIns)
success &= setChannelLayoutOfBus (true, 0, AudioChannelSet::canonicalChannelSet (newNumIns));
// failed to find a compatible input configuration
@@ -740,10 +733,10 @@ AudioProcessor::BusesProperties AudioProcessor::busesPropertiesFromLayoutArray (
BusesProperties ioProps;
if (config[0].inChannels > 0)
ioProps.addBus (true, String ("Input"), AudioChannelSet::canonicalChannelSet (config[0].inChannels));
ioProps.addBus (true, "Input", AudioChannelSet::canonicalChannelSet (config[0].inChannels));
if (config[0].outChannels > 0)
ioProps.addBus (false, String ("Output"), AudioChannelSet::canonicalChannelSet (config[0].outChannels));
ioProps.addBus (false, "Output", AudioChannelSet::canonicalChannelSet (config[0].outChannels));
return ioProps;
}


+ 1
- 1
modules/juce_core/native/juce_android_Files.cpp View File

@@ -143,7 +143,7 @@ public:
if (type == "image")
type = "images";
return getCursorDataColumn (URL (String ("content://media/external/") + type + "/media"),
return getCursorDataColumn (URL ("content://media/external/" + type + "/media"),
"_id=?", StringArray {mediaId});
}


+ 4
- 5
modules/juce_core/native/juce_curl_Network.cpp View File

@@ -130,7 +130,7 @@ public:
//==============================================================================
bool setOptions()
{
const String address = url.toString (! isPost);
auto address = url.toString (! isPost);
curl_version_info_data* data = curl_version_info (CURLVERSION_NOW);
jassert (data != nullptr);
@@ -144,7 +144,7 @@ public:
if (! requestHeaders.endsWithChar ('\n'))
requestHeaders << "\r\n";
String userAgent = String ("curl/") + data->version;
auto userAgent = String ("curl/") + data->version;
if (curl_easy_setopt (curl, CURLOPT_URL, address.toRawUTF8()) == CURLE_OK
&& curl_easy_setopt (curl, CURLOPT_WRITEDATA, this) == CURLE_OK
@@ -166,11 +166,10 @@ public:
// handle special http request commands
bool hasSpecialRequestCmd = isPost ? (httpRequest != "POST") : (httpRequest != "GET");
if (hasSpecialRequestCmd)
{
if (curl_easy_setopt (curl, CURLOPT_CUSTOMREQUEST, httpRequest.toRawUTF8()) != CURLE_OK)
return false;
}
if (curl_easy_setopt (curl, CURLOPT_HEADERDATA, this) != CURLE_OK
|| curl_easy_setopt (curl, CURLOPT_HEADERFUNCTION, StaticCurlHeader) != CURLE_OK)
@@ -178,7 +177,7 @@ public:
if (timeOutMs > 0)
{
long timeOutSecs = ((long) timeOutMs + 999) / 1000;
auto timeOutSecs = ((long) timeOutMs + 999) / 1000;
if (curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, timeOutSecs) != CURLE_OK
|| curl_easy_setopt (curl, CURLOPT_LOW_SPEED_LIMIT, 100) != CURLE_OK


+ 11
- 10
modules/juce_core/network/juce_IPAddress.cpp View File

@@ -162,11 +162,10 @@ String IPAddress::getFormattedAddress (const String& unformattedAddress)
{
jassert (unformattedAddress.contains (":") && ! unformattedAddress.contains ("::")); // needs to be an unformatted IPv6 address!
String portString = unformattedAddress.fromFirstOccurrenceOf ("]", false, true);
String addressString = unformattedAddress.dropLastCharacters (portString.length()).removeCharacters ("[]");
auto portString = unformattedAddress.fromFirstOccurrenceOf ("]", false, true);
auto addressString = unformattedAddress.dropLastCharacters (portString.length()).removeCharacters ("[]");
StringArray tokens;
tokens.addTokens (addressString, ":", String());
auto tokens = StringArray::fromTokens (addressString, ":", {});
int numZeros = 0;
int numZerosTemp = 0;
@@ -175,7 +174,7 @@ String IPAddress::getFormattedAddress (const String& unformattedAddress)
for (int i = 0; i < tokens.size(); ++i)
{
String t = tokens.getReference (i);
const auto& t = tokens.getReference (i);
if (t.getHexValue32() == 0x0000)
{
@@ -212,21 +211,23 @@ String IPAddress::getFormattedAddress (const String& unformattedAddress)
if (numZeros > 1)
{
if (numZeros == tokens.size())
{
addressString = "::,";
}
else
{
String zeroString = isFirst ? String ("0") + String::repeatedString (":0", numZeros - 1)
: String::repeatedString (":0", numZeros);
auto zeroString = isFirst ? "0" + String::repeatedString (":0", numZeros - 1)
: String::repeatedString (":0", numZeros);
addressString = addressString.replaceFirstOccurrenceOf (zeroString, ":");
if (isLast)
addressString += String (":");
addressString << ':';
}
}
if (portString.isNotEmpty())
addressString = String ("[") + addressString + String ("]") + portString;
addressString = "[" + addressString + "]" + portString;
return addressString;
}
@@ -249,7 +250,7 @@ bool IPAddress::operator!= (const IPAddress& other) const noexcept
#if (! JUCE_WINDOWS) && (! JUCE_ANDROID)
static void addAddress (const sockaddr_in* addr_in, Array<IPAddress>& result)
{
in_addr_t addr = addr_in->sin_addr.s_addr;
auto addr = addr_in->sin_addr.s_addr;
if (addr != INADDR_NONE)
result.addIfNotAlreadyThere (IPAddress (ntohl (addr)));


+ 1
- 1
modules/juce_core/time/juce_PerformanceCounter.h View File

@@ -131,7 +131,7 @@ private:
doSomething();
}
Logger::writeToLog (String ("doSomething() took ") + String (timeSec) + "seconds");
Logger::writeToLog ("doSomething() took " + String (timeSec) + "seconds");
}
@param resultInSeconds The result of the measurement will be stored in this variable.


+ 4
- 4
modules/juce_dsp/frequency/juce_FFT.cpp View File

@@ -601,14 +601,14 @@ struct FFTWImpl : public FFT::Instance
#if ! JUCE_DSP_USE_STATIC_FFTW
#if JUCE_MAC
const char* libsuffix = "dylib";
auto libName = "libfftw3f.dylib";
#elif JUCE_WINDOWS
const char* libsuffix = "dll";
auto libName = "libfftw3f.dll";
#else
const char* libsuffix = "so";
auto libName = "libfftw3f.so";
#endif
if (lib.open (String ("libfftw3f.") + libsuffix))
if (lib.open (libName))
#endif
{
Symbols symbols;


+ 1
- 1
modules/juce_gui_basics/native/juce_ios_FileChooser.mm View File

@@ -181,7 +181,7 @@ private:
extension = fallbackExtension;
if (extension.isNotEmpty())
filename += String (".") + extension;
filename += "." + extension;
return filename;
}


+ 2
- 3
modules/juce_gui_extra/native/juce_mac_WebBrowserComponent.mm View File

@@ -119,13 +119,12 @@ private:
{
if ([frame isEqual: [sender mainFrame]] && error != nullptr && [error code] != NSURLErrorCancelled)
{
String errorString (nsStringToJuce ([error localizedDescription]));
auto errorString = nsStringToJuce ([error localizedDescription]);
bool proceedToErrorPage = getOwner (self)->pageLoadHadNetworkError (errorString);
// WebKit doesn't have an internal error page, so make a really simple one ourselves
if (proceedToErrorPage)
getOwner(self)->goToURL (String ("data:text/plain;charset=UTF-8,") + errorString);
getOwner (self)->goToURL ("data:text/plain;charset=UTF-8," + errorString);
}
}


+ 1
- 1
modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp View File

@@ -100,7 +100,7 @@ String OpenGLHelpers::translateVertexShaderToV3 (const String& code)
for (int p = code.indexOf (0, "attribute "); p >= 0; p = code.indexOf (p + 1, "attribute "))
{
output += code.substring (last, p) + String ("layout(location=") + String (--numAttributes) + ") in ";
output += code.substring (last, p) + "layout(location=" + String (--numAttributes) + ") in ";
last = p + 10;
}


+ 3
- 3
modules/juce_osc/osc/juce_OSCSender.cpp View File

@@ -677,7 +677,7 @@ public:
beginTest ("OSC message with multiple arguments");
{
OSCMessage outMessage ("/test/four_args", 42, 0.5f, String ("foo"), String ("bar"));
OSCMessage outMessage ("/test/four_args", 42, 0.5f, "foo", "bar");
OSCOutputStream output;
output.writeMessage (outMessage);
@@ -721,7 +721,7 @@ public:
OSCMessage inMessage = inBundle[0].getMessage();
expectEquals (inMessage.getAddressPattern().toString(), String ("/test/one_arg"));
expectEquals (inMessage.getAddressPattern().toString(), "/test/one_arg");
expectEquals (inMessage.size(), 1);
expectEquals (inMessage[0].getInt32(), 42);
}
@@ -730,7 +730,7 @@ public:
{
OSCMessage outMessage1 ("/test/empty");
OSCMessage outMessage2 ("/test/one_arg", 42);
OSCMessage outMessage3 ("/test/four_args", 42, 0.5f, String ("foo"), String ("bar"));
OSCMessage outMessage3 ("/test/four_args", 42, 0.5f, "foo", "bar");
OSCBundle outBundle;
outBundle.addElement (outMessage1);


Loading…
Cancel
Save