1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-14 00:14:18 +00:00

Tidied up a few OutputStream operators.

This commit is contained in:
Julian Storer 2010-02-22 11:37:43 +00:00
parent 20ab8e6e96
commit 9f201da3c5
6 changed files with 151 additions and 226 deletions

View file

@ -39,6 +39,7 @@ BEGIN_JUCE_NAMESPACE
#include "juce_String.h"
#include "../core/juce_Atomic.h"
#include "../io/streams/juce_OutputStream.h"
#ifdef _MSC_VER
#pragma warning (pop)
@ -771,6 +772,17 @@ String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const double number)
return string1 += String (number);
}
OutputStream& JUCE_PUBLIC_FUNCTION operator<< (OutputStream& stream, const String& text)
{
// (This avoids using toUTF8() to prevent the memory bloat that it would leave behind
// if lots of large, persistent strings were to be written to streams).
const int numBytes = text.getNumBytesAsUTF8();
HeapBlock <uint8> temp (numBytes);
text.copyToUTF8 (temp, numBytes);
stream.write (temp, numBytes);
return stream;
}
//==============================================================================
int String::indexOfChar (const tchar character) const throw()
{