Browse Source

Eradicated the last vestiges of printf from the library. String::formatted and String::printf are now gone - please use the << operators instead!

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
e07c59c8f4
12 changed files with 249 additions and 373 deletions
  1. +3
    -5
      extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp
  2. +1
    -5
      extras/the jucer/src/utility/jucer_ColourEditorComponent.h
  3. +94
    -160
      juce_amalgamated.cpp
  4. +24
    -8
      juce_amalgamated.h
  5. +30
    -0
      src/containers/juce_OwnedArray.h
  6. +2
    -14
      src/gui/components/special/juce_ColourSelector.cpp
  7. +91
    -85
      src/gui/graphics/colour/juce_Colour.cpp
  8. +4
    -1
      src/gui/graphics/colour/juce_Colour.h
  9. +0
    -19
      src/text/juce_CharacterFunctions.cpp
  10. +0
    -4
      src/text/juce_CharacterFunctions.h
  11. +0
    -46
      src/text/juce_String.cpp
  12. +0
    -26
      src/text/juce_String.h

+ 3
- 5
extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp View File

@@ -71,13 +71,11 @@
#include "juce_IncludeBrowserPluginInfo.h"
#if JUCE_MAC && JUCE_DEBUG && 0
#include <fstream>
static void log (const String& s)
{
FILE* f = fopen ("/Users/jules/Desktop/log.txt", "a+");
fprintf (f, (const char*) s);
fprintf (f, "\n");
fflush (f);
fclose (f);
std::ofstream file ("/Users/jules/Desktop/log.txt", std::ios::out | std::ios::app);
file << s << std::endl;
}
#else
#define log(a)


+ 1
- 5
extras/the jucer/src/utility/jucer_ColourEditorComponent.h View File

@@ -56,11 +56,7 @@ public:
g.setColour (Colours::white.overlaidWith (colour).contrasting());
g.setFont (getHeight() * 0.6f, Font::bold);
g.drawFittedText (String::formatted (T("%02X%02X%02X%02X"),
(int) colour.getAlpha(),
(int) colour.getRed(),
(int) colour.getGreen(),
(int) colour.getBlue()),
g.drawFittedText (colour.toDisplayString (true),
2, 1, getWidth() - 4, getHeight() - 1,
Justification::centred, 1);
}


+ 94
- 160
juce_amalgamated.cpp View File

@@ -10228,24 +10228,6 @@ int CharacterFunctions::getHexDigitValue (const juce_wchar digit) throw()
return -1;
}

int CharacterFunctions::vprintf (char* const dest, const int maxLength, const char* const format, va_list& args) throw()
{
#if JUCE_WIN32
return (int) _vsnprintf (dest, maxLength, format, args);
#else
return (int) vsnprintf (dest, maxLength, format, args);
#endif
}

int CharacterFunctions::vprintf (juce_wchar* const dest, const int maxLength, const juce_wchar* const format, va_list& args) throw()
{
#if defined (JUCE_WIN32)
return (int) _vsnwprintf (dest, maxLength, format, args);
#else
return (int) vswprintf (dest, maxLength, format, args);
#endif
}

END_JUCE_NAMESPACE
/*** End of inlined file: juce_CharacterFunctions.cpp ***/

@@ -11430,50 +11412,6 @@ bool String::matchesWildcard (const tchar* wildcard, const bool ignoreCase) cons
}
}

const String String::formatted (const tchar* const pf, ...) throw()
{
va_list list;
va_start (list, pf);

String result;
result.vprintf (pf, list);
return result;
}

void String::vprintf (const tchar* const pf, va_list& args) throw()
{
int bufferSize = 256;
String result (bufferSize, 0);

do
{
#if JUCE_LINUX && JUCE_64BIT
va_list tempArgs;
va_copy (tempArgs, args);
const int num = CharacterFunctions::vprintf (result.text->text, bufferSize - 1, pf, tempArgs);
va_end (tempArgs);
#else
const int num = CharacterFunctions::vprintf (result.text->text, bufferSize - 1, pf, args);
#endif

if (num > 0)
{
*this = result;
break;
}
else if (num == 0)
{
*this = String::empty;
break;
}

bufferSize += 256;
result.preallocateStorage (bufferSize);
}
while (bufferSize < 65536); // this is a sanity check to avoid situations where vprintf repeatedly
// returns -1 because of an error rather than because it needs more space.
}

const String String::repeatedString (const tchar* const stringToRepeat,
int numberOfTimesToRepeat)
{
@@ -72818,11 +72756,6 @@ BEGIN_JUCE_NAMESPACE
static const int swatchesPerRow = 8;
static const int swatchHeight = 22;

static const String colourComponentToHexString (int value)
{
return String::toHexString (value).toUpperCase().paddedLeft ('0', 2);
}

class ColourComponentSlider : public Slider
{
public:
@@ -72838,7 +72771,7 @@ public:

const String getTextFromValue (double value)
{
return colourComponentToHexString ((int) value);
return String::toHexString ((int) value).toUpperCase().paddedLeft ('0', 2);
}

double getValueFromText (const String& text)
@@ -73272,14 +73205,7 @@ void ColourSelector::paint (Graphics& g)

g.setColour (Colours::white.overlaidWith (colour).contrasting());
g.setFont (14.0f, true);
g.drawText (((flags & showAlphaChannel) != 0)
? colourComponentToHexString ((int) colour.getAlpha())
+ colourComponentToHexString ((int) colour.getRed())
+ colourComponentToHexString ((int) colour.getGreen())
+ colourComponentToHexString ((int) colour.getBlue())
: colourComponentToHexString ((int) colour.getRed())
+ colourComponentToHexString ((int) colour.getGreen())
+ colourComponentToHexString ((int) colour.getBlue()),
g.drawText (colour.toDisplayString ((flags & showAlphaChannel) != 0),
0, edgeGap, getWidth(), topSpace - edgeGap * 2,
Justification::centred, false);
}
@@ -78072,12 +77998,82 @@ END_JUCE_NAMESPACE
/*** Start of inlined file: juce_Colour.cpp ***/
BEGIN_JUCE_NAMESPACE

static uint8 floatAlphaToInt (const float alpha)
namespace ColourHelpers
{
return (uint8) jlimit (0, 0xff, roundToInt (alpha * 255.0f));
}
static uint8 floatAlphaToInt (const float alpha) throw()
{
return (uint8) jlimit (0, 0xff, roundToInt (alpha * 255.0f));
}

static void convertHSBtoRGB (float h, float s, float v,
uint8& r, uint8& g, uint8& b) throw()
{
v = jlimit (0.0f, 1.0f, v);
v *= 255.0f;
const uint8 intV = (uint8) roundToInt (v);

static const float oneOver255 = 1.0f / 255.0f;
if (s <= 0)
{
r = intV;
g = intV;
b = intV;
}
else
{
s = jmin (1.0f, s);
h = jlimit (0.0f, 1.0f, h);
h = (h - floorf (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors
const float f = h - floorf (h);

const uint8 x = (uint8) roundToInt (v * (1.0f - s));
const float y = v * (1.0f - s * f);
const float z = v * (1.0f - (s * (1.0f - f)));

if (h < 1.0f)
{
r = intV;
g = (uint8) roundToInt (z);
b = x;
}
else if (h < 2.0f)
{
r = (uint8) roundToInt (y);
g = intV;
b = x;
}
else if (h < 3.0f)
{
r = x;
g = intV;
b = (uint8) roundToInt (z);
}
else if (h < 4.0f)
{
r = x;
g = (uint8) roundToInt (y);
b = intV;
}
else if (h < 5.0f)
{
r = (uint8) roundToInt (z);
g = x;
b = intV;
}
else if (h < 6.0f)
{
r = intV;
g = x;
b = (uint8) roundToInt (y);
}
else
{
r = 0;
g = 0;
b = 0;
}
}
}
}

Colour::Colour() throw()
: argb (0)
@@ -78145,7 +78141,7 @@ Colour::Colour (const uint8 red,
const uint8 blue,
const float alpha) throw()
{
argb.setARGB (floatAlphaToInt (alpha), red, green, blue);
argb.setARGB (ColourHelpers::floatAlphaToInt (alpha), red, green, blue);
}

const Colour Colour::fromRGBAFloat (const uint8 red,
@@ -78156,84 +78152,15 @@ const Colour Colour::fromRGBAFloat (const uint8 red,
return Colour (red, green, blue, alpha);
}

static void convertHSBtoRGB (float h, float s, float v,
uint8& r, uint8& g, uint8& b) throw()
{
v = jlimit (0.0f, 1.0f, v);
v *= 255.0f;
const uint8 intV = (uint8) roundToInt (v);

if (s <= 0)
{
r = intV;
g = intV;
b = intV;
}
else
{
s = jmin (1.0f, s);
h = jlimit (0.0f, 1.0f, h);
h = (h - floorf (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors
const float f = h - floorf (h);

const uint8 x = (uint8) roundToInt (v * (1.0f - s));
const float y = v * (1.0f - s * f);
const float z = v * (1.0f - (s * (1.0f - f)));

if (h < 1.0f)
{
r = intV;
g = (uint8) roundToInt (z);
b = x;
}
else if (h < 2.0f)
{
r = (uint8) roundToInt (y);
g = intV;
b = x;
}
else if (h < 3.0f)
{
r = x;
g = intV;
b = (uint8) roundToInt (z);
}
else if (h < 4.0f)
{
r = x;
g = (uint8) roundToInt (y);
b = intV;
}
else if (h < 5.0f)
{
r = (uint8) roundToInt (z);
g = x;
b = intV;
}
else if (h < 6.0f)
{
r = intV;
g = x;
b = (uint8) roundToInt (y);
}
else
{
r = 0;
g = 0;
b = 0;
}
}
}

Colour::Colour (const float hue,
const float saturation,
const float brightness,
const float alpha) throw()
{
uint8 r = getRed(), g = getGreen(), b = getBlue();
convertHSBtoRGB (hue, saturation, brightness, r, g, b);
ColourHelpers::convertHSBtoRGB (hue, saturation, brightness, r, g, b);

argb.setARGB (floatAlphaToInt (alpha), r, g, b);
argb.setARGB (ColourHelpers::floatAlphaToInt (alpha), r, g, b);
}

const Colour Colour::fromHSV (const float hue,
@@ -78250,7 +78177,7 @@ Colour::Colour (const float hue,
const uint8 alpha) throw()
{
uint8 r = getRed(), g = getGreen(), b = getBlue();
convertHSBtoRGB (hue, saturation, brightness, r, g, b);
ColourHelpers::convertHSBtoRGB (hue, saturation, brightness, r, g, b);

argb.setARGB (alpha, r, g, b);
}
@@ -78293,7 +78220,7 @@ const Colour Colour::withAlpha (const float newAlpha) const throw()
jassert (newAlpha >= 0 && newAlpha <= 1.0f);

PixelARGB newCol (argb);
newCol.setAlpha (floatAlphaToInt (newAlpha));
newCol.setAlpha (ColourHelpers::floatAlphaToInt (newAlpha));
return Colour (newCol.getARGB());
}

@@ -78351,22 +78278,22 @@ const Colour Colour::interpolatedWith (const Colour& other, float proportionOfOt

float Colour::getFloatRed() const throw()
{
return getRed() * oneOver255;
return getRed() / 255.0f;
}

float Colour::getFloatGreen() const throw()
{
return getGreen() * oneOver255;
return getGreen() / 255.0f;
}

float Colour::getFloatBlue() const throw()
{
return getBlue() * oneOver255;
return getBlue() / 255.0f;
}

float Colour::getFloatAlpha() const throw()
{
return getAlpha() * oneOver255;
return getAlpha() / 255.0f;
}

void Colour::getHSB (float& h, float& s, float& v) const throw()
@@ -78413,7 +78340,7 @@ void Colour::getHSB (float& h, float& s, float& v) const throw()
h = 0;
}

v = hi * oneOver255;
v = hi / 255.0f;
}

float Colour::getHue() const throw()
@@ -78553,7 +78480,7 @@ const Colour Colour::contrasting (const Colour& colour1,
.withBrightness (best);
}

const String Colour::toString() const throw()
const String Colour::toString() const
{
return String::toHexString ((int) argb.getARGB());
}
@@ -78563,6 +78490,13 @@ const Colour Colour::fromString (const String& encodedColourString)
return Colour ((uint32) encodedColourString.getHexValue32());
}

const String Colour::toDisplayString (const bool includeAlphaValue) const
{
return String::toHexString ((int) (argb.getARGB() & (includeAlphaValue ? 0xffffffff : 0xffffff)))
.paddedLeft ('0', includeAlphaValue ? 8 : 6)
.toUpperCase();
}

END_JUCE_NAMESPACE
/*** End of inlined file: juce_Colour.cpp ***/



+ 24
- 8
juce_amalgamated.h View File

@@ -1056,9 +1056,6 @@ public:
static bool isLetterOrDigit (const juce_wchar character) throw();

static int getHexDigitValue (const juce_wchar digit) throw();

static int vprintf (char* const dest, const int maxLength, const char* const format, va_list& args) throw();
static int vprintf (juce_wchar* const dest, const int maxLength, const juce_wchar* const format, va_list& args) throw();
};

#endif // __JUCE_CHARACTERFUNCTIONS_JUCEHEADER__
@@ -1269,10 +1266,6 @@ public:

const String quoted (const tchar quoteCharacter = JUCE_T('"')) const throw();

static const String formatted (const tchar* const format, ...) throw();

void vprintf (const tchar* const format, va_list& args) throw();

static const String repeatedString (const tchar* const stringToRepeat,
int numberOfTimesToRepeat);

@@ -3577,6 +3570,27 @@ public:
}
}

template <class OtherArrayType>
void addArray (const OtherArrayType& arrayToAddFrom,
int startIndex = 0,
int numElementsToAdd = -1)
{
const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());
const ScopedLockType lock2 (getLock());

if (startIndex < 0)
{
jassertfalse
startIndex = 0;
}

if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size())
numElementsToAdd = arrayToAddFrom.size() - startIndex;

while (--numElementsToAdd >= 0)
add (arrayToAddFrom.getUnchecked (startIndex++));
}

template <class ElementComparator>
void addSorted (ElementComparator& comparator,
ObjectClass* const newObject) throw()
@@ -11475,10 +11489,12 @@ public:

static const Colour greyLevel (const float brightness) throw();

const String toString() const throw();
const String toString() const;

static const Colour fromString (const String& encodedColourString);

const String toDisplayString (bool includeAlphaValue) const;

juce_UseDebuggingNewOperator

private:


+ 30
- 0
src/containers/juce_OwnedArray.h View File

@@ -315,6 +315,36 @@ public:
}
}
/** Adds elements from another array to the end of this array.
@param arrayToAddFrom the array from which to copy the elements
@param startIndex the first element of the other array to start copying from
@param numElementsToAdd how many elements to add from the other array. If this
value is negative or greater than the number of available elements,
all available elements will be copied.
@see add
*/
template <class OtherArrayType>
void addArray (const OtherArrayType& arrayToAddFrom,
int startIndex = 0,
int numElementsToAdd = -1)
{
const typename OtherArrayType::ScopedLockType lock1 (arrayToAddFrom.getLock());
const ScopedLockType lock2 (getLock());
if (startIndex < 0)
{
jassertfalse
startIndex = 0;
}
if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size())
numElementsToAdd = arrayToAddFrom.size() - startIndex;
while (--numElementsToAdd >= 0)
add (arrayToAddFrom.getUnchecked (startIndex++));
}
/** Inserts a new object into the array assuming that the array is sorted.
This will use a comparator to find the position at which the new object


+ 2
- 14
src/gui/components/special/juce_ColourSelector.cpp View File

@@ -36,11 +36,6 @@ BEGIN_JUCE_NAMESPACE
static const int swatchesPerRow = 8;
static const int swatchHeight = 22;
static const String colourComponentToHexString (int value)
{
return String::toHexString (value).toUpperCase().paddedLeft ('0', 2);
}
//==============================================================================
class ColourComponentSlider : public Slider
{
@@ -57,7 +52,7 @@ public:
const String getTextFromValue (double value)
{
return colourComponentToHexString ((int) value);
return String::toHexString ((int) value).toUpperCase().paddedLeft ('0', 2);
}
double getValueFromText (const String& text)
@@ -500,14 +495,7 @@ void ColourSelector::paint (Graphics& g)
g.setColour (Colours::white.overlaidWith (colour).contrasting());
g.setFont (14.0f, true);
g.drawText (((flags & showAlphaChannel) != 0)
? colourComponentToHexString ((int) colour.getAlpha())
+ colourComponentToHexString ((int) colour.getRed())
+ colourComponentToHexString ((int) colour.getGreen())
+ colourComponentToHexString ((int) colour.getBlue())
: colourComponentToHexString ((int) colour.getRed())
+ colourComponentToHexString ((int) colour.getGreen())
+ colourComponentToHexString ((int) colour.getBlue()),
g.drawText (colour.toDisplayString ((flags & showAlphaChannel) != 0),
0, edgeGap, getWidth(), topSpace - edgeGap * 2,
Justification::centred, false);
}


+ 91
- 85
src/gui/graphics/colour/juce_Colour.cpp View File

@@ -31,13 +31,82 @@ BEGIN_JUCE_NAMESPACE
//==============================================================================
static uint8 floatAlphaToInt (const float alpha)
namespace ColourHelpers
{
return (uint8) jlimit (0, 0xff, roundToInt (alpha * 255.0f));
}
static uint8 floatAlphaToInt (const float alpha) throw()
{
return (uint8) jlimit (0, 0xff, roundToInt (alpha * 255.0f));
}
static const float oneOver255 = 1.0f / 255.0f;
static void convertHSBtoRGB (float h, float s, float v,
uint8& r, uint8& g, uint8& b) throw()
{
v = jlimit (0.0f, 1.0f, v);
v *= 255.0f;
const uint8 intV = (uint8) roundToInt (v);
if (s <= 0)
{
r = intV;
g = intV;
b = intV;
}
else
{
s = jmin (1.0f, s);
h = jlimit (0.0f, 1.0f, h);
h = (h - floorf (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors
const float f = h - floorf (h);
const uint8 x = (uint8) roundToInt (v * (1.0f - s));
const float y = v * (1.0f - s * f);
const float z = v * (1.0f - (s * (1.0f - f)));
if (h < 1.0f)
{
r = intV;
g = (uint8) roundToInt (z);
b = x;
}
else if (h < 2.0f)
{
r = (uint8) roundToInt (y);
g = intV;
b = x;
}
else if (h < 3.0f)
{
r = x;
g = intV;
b = (uint8) roundToInt (z);
}
else if (h < 4.0f)
{
r = x;
g = (uint8) roundToInt (y);
b = intV;
}
else if (h < 5.0f)
{
r = (uint8) roundToInt (z);
g = x;
b = intV;
}
else if (h < 6.0f)
{
r = intV;
g = x;
b = (uint8) roundToInt (y);
}
else
{
r = 0;
g = 0;
b = 0;
}
}
}
}
//==============================================================================
Colour::Colour() throw()
@@ -107,7 +176,7 @@ Colour::Colour (const uint8 red,
const uint8 blue,
const float alpha) throw()
{
argb.setARGB (floatAlphaToInt (alpha), red, green, blue);
argb.setARGB (ColourHelpers::floatAlphaToInt (alpha), red, green, blue);
}
const Colour Colour::fromRGBAFloat (const uint8 red,
@@ -118,85 +187,15 @@ const Colour Colour::fromRGBAFloat (const uint8 red,
return Colour (red, green, blue, alpha);
}
//==============================================================================
static void convertHSBtoRGB (float h, float s, float v,
uint8& r, uint8& g, uint8& b) throw()
{
v = jlimit (0.0f, 1.0f, v);
v *= 255.0f;
const uint8 intV = (uint8) roundToInt (v);
if (s <= 0)
{
r = intV;
g = intV;
b = intV;
}
else
{
s = jmin (1.0f, s);
h = jlimit (0.0f, 1.0f, h);
h = (h - floorf (h)) * 6.0f + 0.00001f; // need a small adjustment to compensate for rounding errors
const float f = h - floorf (h);
const uint8 x = (uint8) roundToInt (v * (1.0f - s));
const float y = v * (1.0f - s * f);
const float z = v * (1.0f - (s * (1.0f - f)));
if (h < 1.0f)
{
r = intV;
g = (uint8) roundToInt (z);
b = x;
}
else if (h < 2.0f)
{
r = (uint8) roundToInt (y);
g = intV;
b = x;
}
else if (h < 3.0f)
{
r = x;
g = intV;
b = (uint8) roundToInt (z);
}
else if (h < 4.0f)
{
r = x;
g = (uint8) roundToInt (y);
b = intV;
}
else if (h < 5.0f)
{
r = (uint8) roundToInt (z);
g = x;
b = intV;
}
else if (h < 6.0f)
{
r = intV;
g = x;
b = (uint8) roundToInt (y);
}
else
{
r = 0;
g = 0;
b = 0;
}
}
}
Colour::Colour (const float hue,
const float saturation,
const float brightness,
const float alpha) throw()
{
uint8 r = getRed(), g = getGreen(), b = getBlue();
convertHSBtoRGB (hue, saturation, brightness, r, g, b);
ColourHelpers::convertHSBtoRGB (hue, saturation, brightness, r, g, b);
argb.setARGB (floatAlphaToInt (alpha), r, g, b);
argb.setARGB (ColourHelpers::floatAlphaToInt (alpha), r, g, b);
}
const Colour Colour::fromHSV (const float hue,
@@ -213,7 +212,7 @@ Colour::Colour (const float hue,
const uint8 alpha) throw()
{
uint8 r = getRed(), g = getGreen(), b = getBlue();
convertHSBtoRGB (hue, saturation, brightness, r, g, b);
ColourHelpers::convertHSBtoRGB (hue, saturation, brightness, r, g, b);
argb.setARGB (alpha, r, g, b);
}
@@ -258,7 +257,7 @@ const Colour Colour::withAlpha (const float newAlpha) const throw()
jassert (newAlpha >= 0 && newAlpha <= 1.0f);
PixelARGB newCol (argb);
newCol.setAlpha (floatAlphaToInt (newAlpha));
newCol.setAlpha (ColourHelpers::floatAlphaToInt (newAlpha));
return Colour (newCol.getARGB());
}
@@ -318,22 +317,22 @@ const Colour Colour::interpolatedWith (const Colour& other, float proportionOfOt
//==============================================================================
float Colour::getFloatRed() const throw()
{
return getRed() * oneOver255;
return getRed() / 255.0f;
}
float Colour::getFloatGreen() const throw()
{
return getGreen() * oneOver255;
return getGreen() / 255.0f;
}
float Colour::getFloatBlue() const throw()
{
return getBlue() * oneOver255;
return getBlue() / 255.0f;
}
float Colour::getFloatAlpha() const throw()
{
return getAlpha() * oneOver255;
return getAlpha() / 255.0f;
}
//==============================================================================
@@ -381,7 +380,7 @@ void Colour::getHSB (float& h, float& s, float& v) const throw()
h = 0;
}
v = hi * oneOver255;
v = hi / 255.0f;
}
//==============================================================================
@@ -528,7 +527,7 @@ const Colour Colour::contrasting (const Colour& colour1,
}
//==============================================================================
const String Colour::toString() const throw()
const String Colour::toString() const
{
return String::toHexString ((int) argb.getARGB());
}
@@ -538,5 +537,12 @@ const Colour Colour::fromString (const String& encodedColourString)
return Colour ((uint32) encodedColourString.getHexValue32());
}
const String Colour::toDisplayString (const bool includeAlphaValue) const
{
return String::toHexString ((int) (argb.getARGB() & (includeAlphaValue ? 0xffffffff : 0xffffff)))
.paddedLeft ('0', includeAlphaValue ? 8 : 6)
.toUpperCase();
}
END_JUCE_NAMESPACE

+ 4
- 1
src/gui/graphics/colour/juce_Colour.h View File

@@ -343,12 +343,15 @@ public:
The string can be turned back into a colour using the fromString() method.
*/
const String toString() const throw();
const String toString() const;
/** Reads the colour from a string that was created with toString().
*/
static const Colour fromString (const String& encodedColourString);
/** Returns the colour as a hex string in the form RRGGBB or AARRGGBB. */
const String toDisplayString (bool includeAlphaValue) const;
//==============================================================================
juce_UseDebuggingNewOperator


+ 0
- 19
src/text/juce_CharacterFunctions.cpp View File

@@ -771,24 +771,5 @@ int CharacterFunctions::getHexDigitValue (const juce_wchar digit) throw()
return -1;
}
//==============================================================================
int CharacterFunctions::vprintf (char* const dest, const int maxLength, const char* const format, va_list& args) throw()
{
#if JUCE_WIN32
return (int) _vsnprintf (dest, maxLength, format, args);
#else
return (int) vsnprintf (dest, maxLength, format, args);
#endif
}
int CharacterFunctions::vprintf (juce_wchar* const dest, const int maxLength, const juce_wchar* const format, va_list& args) throw()
{
#if defined (JUCE_WIN32)
return (int) _vsnwprintf (dest, maxLength, format, args);
#else
return (int) vswprintf (dest, maxLength, format, args);
#endif
}
END_JUCE_NAMESPACE

+ 0
- 4
src/text/juce_CharacterFunctions.h View File

@@ -146,10 +146,6 @@ public:
hex digit.
*/
static int getHexDigitValue (const juce_wchar digit) throw();
//==============================================================================
static int vprintf (char* const dest, const int maxLength, const char* const format, va_list& args) throw();
static int vprintf (juce_wchar* const dest, const int maxLength, const juce_wchar* const format, va_list& args) throw();
};
#endif // __JUCE_CHARACTERFUNCTIONS_JUCEHEADER__

+ 0
- 46
src/text/juce_String.cpp View File

@@ -1093,52 +1093,6 @@ bool String::matchesWildcard (const tchar* wildcard, const bool ignoreCase) cons
}
}
//==============================================================================
const String String::formatted (const tchar* const pf, ...) throw()
{
va_list list;
va_start (list, pf);
String result;
result.vprintf (pf, list);
return result;
}
//==============================================================================
void String::vprintf (const tchar* const pf, va_list& args) throw()
{
int bufferSize = 256;
String result (bufferSize, 0);
do
{
#if JUCE_LINUX && JUCE_64BIT
va_list tempArgs;
va_copy (tempArgs, args);
const int num = CharacterFunctions::vprintf (result.text->text, bufferSize - 1, pf, tempArgs);
va_end (tempArgs);
#else
const int num = CharacterFunctions::vprintf (result.text->text, bufferSize - 1, pf, args);
#endif
if (num > 0)
{
*this = result;
break;
}
else if (num == 0)
{
*this = String::empty;
break;
}
bufferSize += 256;
result.preallocateStorage (bufferSize);
}
while (bufferSize < 65536); // this is a sanity check to avoid situations where vprintf repeatedly
// returns -1 because of an error rather than because it needs more space.
}
//==============================================================================
const String String::repeatedString (const tchar* const stringToRepeat,
int numberOfTimesToRepeat)


+ 0
- 26
src/text/juce_String.h View File

@@ -705,32 +705,6 @@ public:
const String quoted (const tchar quoteCharacter = JUCE_T('"')) const throw();
//==============================================================================
/** Returns a string, created using arguments in the style of printf.
This will return a string which is the result of a sprintf using the
arguments passed-in.
Note that using the %s token with a juce string is probably a bad idea, as
this may expect differect encodings on different platforms.
@see printf, vprintf
*/
static const String formatted (const tchar* const format, ...) throw();
/** Writes text into this string, using a printf style, but taking a va_list argument.
This will replace the contents of the string with the output of this
formatted printf. Used by other methods, this is public in case it's
useful for other purposes where you want to pass a va_list through directly.
Note that using the %s token with a juce string is probably a bad idea, as
this may expect differect encodings on different platforms.
@see printf, formatted
*/
void vprintf (const tchar* const format, va_list& args) throw();
//==============================================================================
/** Creates a string which is a version of a string repeated and joined together.


Loading…
Cancel
Save