| @@ -43,7 +43,7 @@ namespace FileHelpers | |||
| return stream != 0 ? calculateStreamHashCode (*stream) : 0; | |||
| } | |||
| bool overwriteFileWithNewDataIfDifferent (const File& file, const char* data, int numBytes) | |||
| bool overwriteFileWithNewDataIfDifferent (const File& file, const void* data, int numBytes) | |||
| { | |||
| if (file.getSize() == numBytes) | |||
| { | |||
| @@ -33,7 +33,7 @@ namespace FileHelpers | |||
| int64 calculateStreamHashCode (InputStream& stream); | |||
| int64 calculateFileHashCode (const File& file); | |||
| bool overwriteFileWithNewDataIfDifferent (const File& file, const char* data, int numBytes); | |||
| bool overwriteFileWithNewDataIfDifferent (const File& file, const void* data, int numBytes); | |||
| bool overwriteFileWithNewDataIfDifferent (const File& file, const MemoryOutputStream& newData); | |||
| bool overwriteFileWithNewDataIfDifferent (const File& file, const String& newData); | |||
| @@ -257,6 +257,8 @@ int JUCEApplication::shutdownAppAndClearUp() | |||
| JUCE_TRY | |||
| { | |||
| app->releaseMessageListener(); | |||
| shutdownJuce_GUI(); | |||
| returnValue = app->getApplicationReturnValue(); | |||
| @@ -37,6 +37,11 @@ ApplicationCommandTarget::ApplicationCommandTarget() | |||
| } | |||
| ApplicationCommandTarget::~ApplicationCommandTarget() | |||
| { | |||
| releaseMessageListener(); | |||
| } | |||
| void ApplicationCommandTarget::releaseMessageListener() | |||
| { | |||
| messageInvoker = 0; | |||
| } | |||
| @@ -232,10 +232,12 @@ public: | |||
| */ | |||
| ApplicationCommandTarget* findFirstTargetParentComponent(); | |||
| //============================================================================== | |||
| juce_UseDebuggingNewOperator | |||
| /** @internal */ | |||
| void releaseMessageListener(); | |||
| private: | |||
| // (for async invocation of commands) | |||
| class CommandTargetMessageInvoker : public MessageListener | |||
| @@ -29,6 +29,7 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "juce_Variant.h" | |||
| #include "juce_DynamicObject.h" | |||
| #include "../io/streams/juce_MemoryOutputStream.h" | |||
| //============================================================================== | |||
| @@ -358,9 +359,9 @@ const var var::readFromStream (InputStream& input) | |||
| case 4: return var (input.readDouble()); | |||
| case 5: | |||
| { | |||
| MemoryBlock mb; | |||
| input.readIntoMemoryBlock (mb, numBytes - 1); | |||
| return var (String::fromUTF8 (static_cast <const char*> (mb.getData()), (int) mb.getSize())); | |||
| MemoryOutputStream mo; | |||
| mo.writeFromInputStream (input, numBytes - 1); | |||
| return var (mo.toUTF8()); | |||
| } | |||
| default: input.skipNextBytes (numBytes - 1); break; | |||
| @@ -144,7 +144,7 @@ public: | |||
| This is exposed publically in case you need to manipulate it directly | |||
| for performance reasons. | |||
| */ | |||
| Type value; | |||
| volatile Type value; | |||
| }; | |||
| @@ -158,9 +158,9 @@ public: | |||
| #if JUCE_PPC || JUCE_IPHONE | |||
| // None of these atomics are available for PPC or for iPhoneOS 3.1 or earlier!! | |||
| template <typename Type> static Type OSAtomicAdd64 (Type b, volatile Type* a) throw() { jassertfalse; return *a += b; } | |||
| template <typename Type> static Type OSAtomicIncrement64 (volatile Type* a) throw() { jassertfalse; return ++*a; } | |||
| template <typename Type> static Type OSAtomicDecrement64 (volatile Type* a) throw() { jassertfalse; return --*a; } | |||
| template <typename Type> static Type OSAtomicAdd64Barrier (Type b, volatile Type* a) throw() { jassertfalse; return *a += b; } | |||
| template <typename Type> static Type OSAtomicIncrement64Barrier (volatile Type* a) throw() { jassertfalse; return ++*a; } | |||
| template <typename Type> static Type OSAtomicDecrement64Barrier (volatile Type* a) throw() { jassertfalse; return --*a; } | |||
| template <typename Type> static bool OSAtomicCompareAndSwap64Barrier (Type old, Type newValue, volatile Type* value) throw() | |||
| { jassertfalse; if (old == *value) { *value = newValue; return true; } return false; } | |||
| #define JUCE_64BIT_ATOMICS_UNAVAILABLE 1 | |||
| @@ -250,8 +250,8 @@ template <typename Type> | |||
| inline Type Atomic<Type>::operator+= (const Type amountToAdd) throw() | |||
| { | |||
| #if JUCE_ATOMICS_MAC | |||
| return sizeof (Type) == 4 ? (Type) OSAtomicAdd32 ((int32_t) amountToAdd, (int32_t*) &value) | |||
| : (Type) OSAtomicAdd64 ((int64_t) amountToAdd, (int64_t*) &value); | |||
| return sizeof (Type) == 4 ? (Type) OSAtomicAdd32Barrier ((int32_t) amountToAdd, (int32_t*) &value) | |||
| : (Type) OSAtomicAdd64Barrier ((int64_t) amountToAdd, (int64_t*) &value); | |||
| #elif JUCE_ATOMICS_WINDOWS | |||
| return sizeof (Type) == 4 ? (Type) (juce_InterlockedExchangeAdd ((volatile long*) &value, (long) amountToAdd) + (long) amountToAdd) | |||
| : (Type) (juce_InterlockedExchangeAdd64 ((volatile __int64*) &value, (__int64) amountToAdd) + (__int64) amountToAdd); | |||
| @@ -270,8 +270,8 @@ template <typename Type> | |||
| inline Type Atomic<Type>::operator++() throw() | |||
| { | |||
| #if JUCE_ATOMICS_MAC | |||
| return sizeof (Type) == 4 ? (Type) OSAtomicIncrement32 ((int32_t*) &value) | |||
| : (Type) OSAtomicIncrement64 ((int64_t*) &value); | |||
| return sizeof (Type) == 4 ? (Type) OSAtomicIncrement32Barrier ((int32_t*) &value) | |||
| : (Type) OSAtomicIncrement64Barrier ((int64_t*) &value); | |||
| #elif JUCE_ATOMICS_WINDOWS | |||
| return sizeof (Type) == 4 ? (Type) juce_InterlockedIncrement ((volatile long*) &value) | |||
| : (Type) juce_InterlockedIncrement64 ((volatile __int64*) &value); | |||
| @@ -284,8 +284,8 @@ template <typename Type> | |||
| inline Type Atomic<Type>::operator--() throw() | |||
| { | |||
| #if JUCE_ATOMICS_MAC | |||
| return sizeof (Type) == 4 ? (Type) OSAtomicDecrement32 ((int32_t*) &value) | |||
| : (Type) OSAtomicDecrement64 ((int64_t*) &value); | |||
| return sizeof (Type) == 4 ? (Type) OSAtomicDecrement32Barrier ((int32_t*) &value) | |||
| : (Type) OSAtomicDecrement64Barrier ((int64_t*) &value); | |||
| #elif JUCE_ATOMICS_WINDOWS | |||
| return sizeof (Type) == 4 ? (Type) juce_InterlockedDecrement ((volatile long*) &value) | |||
| : (Type) juce_InterlockedDecrement64 ((volatile __int64*) &value); | |||
| @@ -33,7 +33,7 @@ | |||
| */ | |||
| #define JUCE_MAJOR_VERSION 1 | |||
| #define JUCE_MINOR_VERSION 52 | |||
| #define JUCE_BUILDNUMBER 34 | |||
| #define JUCE_BUILDNUMBER 35 | |||
| /** Current Juce version number. | |||
| @@ -35,6 +35,7 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "../imaging/juce_ImageFileFormat.h" | |||
| #include "../../../text/juce_XmlDocument.h" | |||
| #include "../../../io/files/juce_FileInputStream.h" | |||
| #include "../../../io/streams/juce_MemoryOutputStream.h" | |||
| //============================================================================== | |||
| @@ -120,10 +121,10 @@ Drawable* Drawable::createFromImageData (const void* data, const size_t numBytes | |||
| Drawable* Drawable::createFromImageDataStream (InputStream& dataSource) | |||
| { | |||
| MemoryBlock mb; | |||
| dataSource.readIntoMemoryBlock (mb); | |||
| MemoryOutputStream mo; | |||
| mo.writeFromInputStream (dataSource, -1); | |||
| return createFromImageData (mb.getData(), mb.getSize()); | |||
| return createFromImageData (mo.getData(), mo.getDataSize()); | |||
| } | |||
| Drawable* Drawable::createFromImageFile (const File& file) | |||
| @@ -1385,7 +1385,7 @@ void Path::writePathToStream (OutputStream& dest) const | |||
| const String Path::toString() const | |||
| { | |||
| MemoryOutputStream s (2048, 2048); | |||
| MemoryOutputStream s (2048); | |||
| if (! useNonZeroWinding) | |||
| s << 'a'; | |||
| @@ -128,7 +128,7 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "../juce_ImageFileFormat.h" | |||
| #include "../../../../io/streams/juce_InputStream.h" | |||
| #include "../../../../io/streams/juce_OutputStream.h" | |||
| #include "../../../../io/streams/juce_MemoryOutputStream.h" | |||
| #include "../../colour/juce_PixelFormats.h" | |||
| //============================================================================== | |||
| @@ -254,12 +254,12 @@ const Image JPEGImageFormat::decodeImage (InputStream& in) | |||
| using namespace jpeglibNamespace; | |||
| using namespace JPEGHelpers; | |||
| MemoryBlock mb; | |||
| in.readIntoMemoryBlock (mb); | |||
| MemoryOutputStream mb; | |||
| mb.writeFromInputStream (in, -1); | |||
| Image image; | |||
| if (mb.getSize() > 16) | |||
| if (mb.getDataSize() > 16) | |||
| { | |||
| struct jpeg_decompress_struct jpegDecompStruct; | |||
| @@ -279,7 +279,7 @@ const Image JPEGImageFormat::decodeImage (InputStream& in) | |||
| jpegDecompStruct.src->term_source = dummyCallback1; | |||
| jpegDecompStruct.src->next_input_byte = static_cast <const unsigned char*> (mb.getData()); | |||
| jpegDecompStruct.src->bytes_in_buffer = mb.getSize(); | |||
| jpegDecompStruct.src->bytes_in_buffer = mb.getDataSize(); | |||
| try | |||
| { | |||
| @@ -361,7 +361,7 @@ private: | |||
| void createHeadersAndPostData (const URL& url) | |||
| { | |||
| MemoryOutputStream data (256, 256, &postData); | |||
| MemoryOutputStream data (postData, false); | |||
| if (url.getFilesToUpload().size() > 0) | |||
| { | |||
| @@ -444,7 +444,7 @@ bool URL::readEntireBinaryStream (MemoryBlock& destData, | |||
| if (in != 0) | |||
| { | |||
| in->readIntoMemoryBlock (destData, -1); | |||
| in->readIntoMemoryBlock (destData); | |||
| return true; | |||
| } | |||
| @@ -28,6 +28,7 @@ | |||
| BEGIN_JUCE_NAMESPACE | |||
| #include "juce_InputStream.h" | |||
| #include "juce_MemoryOutputStream.h" | |||
| //============================================================================== | |||
| @@ -206,62 +207,15 @@ const String InputStream::readNextLine() | |||
| int InputStream::readIntoMemoryBlock (MemoryBlock& block, int numBytes) | |||
| { | |||
| const int64 totalLength = getTotalLength(); | |||
| if (totalLength >= 0) | |||
| { | |||
| const int totalBytesRemaining = (int) jmin ((int64) 0x7fffffff, | |||
| totalLength - getPosition()); | |||
| if (numBytes < 0) | |||
| numBytes = totalBytesRemaining; | |||
| else if (numBytes > 0) | |||
| numBytes = jmin (numBytes, totalBytesRemaining); | |||
| else | |||
| return 0; | |||
| } | |||
| const size_t originalBlockSize = block.getSize(); | |||
| int totalBytesRead = 0; | |||
| if (numBytes > 0) | |||
| { | |||
| // know how many bytes we want, so we can resize the block first.. | |||
| block.setSize (originalBlockSize + numBytes, false); | |||
| totalBytesRead = read (static_cast<char*> (block.getData()) + originalBlockSize, numBytes); | |||
| } | |||
| else | |||
| { | |||
| // read until end of stram.. | |||
| const int chunkSize = 32768; | |||
| for (;;) | |||
| { | |||
| block.ensureSize (originalBlockSize + totalBytesRead + chunkSize, false); | |||
| const int bytesJustIn = read (static_cast<char*> (block.getData()) | |||
| + originalBlockSize | |||
| + totalBytesRead, | |||
| chunkSize); | |||
| if (bytesJustIn == 0) | |||
| break; | |||
| totalBytesRead += bytesJustIn; | |||
| } | |||
| } | |||
| // trim off any excess left at the end | |||
| block.setSize (originalBlockSize + totalBytesRead, false); | |||
| return totalBytesRead; | |||
| MemoryOutputStream mo (block, true); | |||
| return mo.writeFromInputStream (*this, numBytes); | |||
| } | |||
| const String InputStream::readEntireStreamAsString() | |||
| { | |||
| MemoryBlock mb; | |||
| const int size = readIntoMemoryBlock (mb); | |||
| return String::createStringFromData (static_cast<const char*> (mb.getData()), size); | |||
| MemoryOutputStream mo; | |||
| mo.writeFromInputStream (*this, -1); | |||
| return mo.toString(); | |||
| } | |||
| //============================================================================== | |||
| @@ -31,18 +31,22 @@ BEGIN_JUCE_NAMESPACE | |||
| //============================================================================== | |||
| MemoryOutputStream::MemoryOutputStream (const size_t initialSize, | |||
| const size_t blockSizeToIncreaseBy, | |||
| MemoryBlock* const memoryBlockToWriteTo) | |||
| MemoryOutputStream::MemoryOutputStream (const size_t initialSize) | |||
| : data (internalBlock), | |||
| position (0), | |||
| size (0) | |||
| { | |||
| internalBlock.setSize (initialSize, false); | |||
| } | |||
| MemoryOutputStream::MemoryOutputStream (MemoryBlock& memoryBlockToWriteTo, | |||
| const bool appendToExistingBlockContent) | |||
| : data (memoryBlockToWriteTo), | |||
| position (0), | |||
| size (0), | |||
| blockSize (jmax ((size_t) 16, blockSizeToIncreaseBy)) | |||
| size (0) | |||
| { | |||
| if (data == 0) | |||
| dataToDelete = data = new MemoryBlock (initialSize); | |||
| else | |||
| data->setSize (initialSize, false); | |||
| if (appendToExistingBlockContent) | |||
| position = size = memoryBlockToWriteTo.getSize(); | |||
| } | |||
| MemoryOutputStream::~MemoryOutputStream() | |||
| @@ -52,8 +56,13 @@ MemoryOutputStream::~MemoryOutputStream() | |||
| void MemoryOutputStream::flush() | |||
| { | |||
| if (dataToDelete == 0) | |||
| data->setSize (size, false); | |||
| if (&data != &internalBlock) | |||
| data.setSize (size, false); | |||
| } | |||
| void MemoryOutputStream::preallocate (const size_t bytesToPreallocate) | |||
| { | |||
| data.ensureSize (bytesToPreallocate + 1); | |||
| } | |||
| void MemoryOutputStream::reset() throw() | |||
| @@ -66,18 +75,12 @@ bool MemoryOutputStream::write (const void* const buffer, int howMany) | |||
| { | |||
| if (howMany > 0) | |||
| { | |||
| size_t storageNeeded = position + howMany; | |||
| if (storageNeeded >= data->getSize()) | |||
| { | |||
| // if we need more space, increase the block by at least 10%.. | |||
| storageNeeded += jmax (blockSize, storageNeeded / 10); | |||
| storageNeeded = storageNeeded - (storageNeeded % blockSize) + blockSize; | |||
| const size_t storageNeeded = position + howMany; | |||
| data->ensureSize (storageNeeded); | |||
| } | |||
| if (storageNeeded >= data.getSize()) | |||
| data.ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~31); | |||
| data->copyFrom (buffer, (int) position, howMany); | |||
| memcpy (static_cast<char*> (data.getData()) + position, buffer, howMany); | |||
| position += howMany; | |||
| size = jmax (size, position); | |||
| } | |||
| @@ -85,12 +88,12 @@ bool MemoryOutputStream::write (const void* const buffer, int howMany) | |||
| return true; | |||
| } | |||
| const char* MemoryOutputStream::getData() const throw() | |||
| const void* MemoryOutputStream::getData() const throw() | |||
| { | |||
| char* const d = static_cast <char*> (data->getData()); | |||
| void* const d = data.getData(); | |||
| if (data->getSize() > size) | |||
| d [size] = 0; | |||
| if (data.getSize() > size) | |||
| static_cast <char*> (d) [size] = 0; | |||
| return d; | |||
| } | |||
| @@ -110,9 +113,36 @@ bool MemoryOutputStream::setPosition (int64 newPosition) | |||
| } | |||
| } | |||
| int MemoryOutputStream::writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite) | |||
| { | |||
| // before writing from an input, see if we can preallocate to make it more efficient.. | |||
| int64 availableData = source.getTotalLength() - source.getPosition(); | |||
| if (availableData > 0) | |||
| { | |||
| if (maxNumBytesToWrite > 0 && maxNumBytesToWrite < availableData) | |||
| availableData = maxNumBytesToWrite; | |||
| preallocate (data.getSize() + (size_t) maxNumBytesToWrite); | |||
| } | |||
| return OutputStream::writeFromInputStream (source, maxNumBytesToWrite); | |||
| } | |||
| const String MemoryOutputStream::toUTF8() const | |||
| { | |||
| return String (getData(), getDataSize()); | |||
| return String (static_cast <const char*> (getData()), getDataSize()); | |||
| } | |||
| const String MemoryOutputStream::toString() const | |||
| { | |||
| return String::createStringFromData (getData(), getDataSize()); | |||
| } | |||
| OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead) | |||
| { | |||
| stream.write (streamToRead.getData(), streamToRead.getDataSize()); | |||
| return stream; | |||
| } | |||
| END_JUCE_NAMESPACE | |||
| @@ -41,21 +41,28 @@ class JUCE_API MemoryOutputStream : public OutputStream | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| /** Creates a memory stream ready for writing into. | |||
| @param initialSize the intial amount of space to allocate for writing into | |||
| @param granularity the increments by which the internal storage will be increased | |||
| @param memoryBlockToWriteTo if this is non-zero, then this block will be used as the | |||
| place that the data gets stored. If it's zero, the stream | |||
| will allocate its own storage internally, which you can | |||
| access using getData() and getDataSize() | |||
| /** Creates an empty memory stream ready for writing into. | |||
| @param initialSize the intial amount of capacity to allocate for writing into | |||
| */ | |||
| MemoryOutputStream (size_t initialSize = 256, | |||
| size_t granularity = 256, | |||
| MemoryBlock* memoryBlockToWriteTo = 0); | |||
| MemoryOutputStream (size_t initialSize = 256); | |||
| /** Destructor. | |||
| /** Creates a memory stream for writing into into a pre-existing MemoryBlock object. | |||
| Note that the destination block will always be larger than the amount of data | |||
| that has been written to the stream, because the MemoryOutputStream keeps some | |||
| spare capactity at its end. To trim the block's size down to fit the actual | |||
| data, call flush(), or delete the MemoryOutputStream. | |||
| @param memoryBlockToWriteTo the block into which new data will be written. | |||
| @param appendToExistingBlockContent if this is true, the contents of the block will be | |||
| kept, and new data will be appended to it. If false, | |||
| the block will be cleared before use | |||
| */ | |||
| MemoryOutputStream (MemoryBlock& memoryBlockToWriteTo, | |||
| bool appendToExistingBlockContent); | |||
| /** Destructor. | |||
| This will free any data that was written to it. | |||
| */ | |||
| ~MemoryOutputStream(); | |||
| @@ -65,7 +72,7 @@ public: | |||
| @see getDataSize | |||
| */ | |||
| const char* getData() const throw(); | |||
| const void* getData() const throw(); | |||
| /** Returns the number of bytes of data that have been written to the stream. | |||
| @@ -76,26 +83,46 @@ public: | |||
| /** Resets the stream, clearing any data that has been written to it so far. */ | |||
| void reset() throw(); | |||
| /** Increases the internal storage capacity to be able to contain at least the specified | |||
| amount of data without needing to be resized. | |||
| */ | |||
| void preallocate (size_t bytesToPreallocate); | |||
| /** Returns a String created from the (UTF8) data that has been written to the stream. */ | |||
| const String toUTF8() const; | |||
| /** Attempts to detect the encoding of the data and convert it to a string. | |||
| @see String::createStringFromData | |||
| */ | |||
| const String toString() const; | |||
| //============================================================================== | |||
| /** If the stream is writing to a user-supplied MemoryBlock, this will trim any excess | |||
| capacity off the block, so that its length matches the amount of actual data that | |||
| has been written so far. | |||
| */ | |||
| void flush(); | |||
| bool write (const void* buffer, int howMany); | |||
| int64 getPosition() { return position; } | |||
| bool setPosition (int64 newPosition); | |||
| int writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite); | |||
| //============================================================================== | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| MemoryBlock* data; | |||
| ScopedPointer <MemoryBlock> dataToDelete; | |||
| MemoryBlock& data; | |||
| MemoryBlock internalBlock; | |||
| size_t position, size, blockSize; | |||
| MemoryOutputStream (const MemoryOutputStream&); | |||
| MemoryOutputStream& operator= (const MemoryOutputStream&); | |||
| }; | |||
| /** Copies all the data that has been written to a MemoryOutputStream into another stream. */ | |||
| OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead); | |||
| #endif // __JUCE_MEMORYOUTPUTSTREAM_JUCEHEADER__ | |||
| @@ -55,7 +55,7 @@ | |||
| #include <sys/types.h> | |||
| #include <sys/ioctl.h> | |||
| #include <sys/socket.h> | |||
| #include <linux/if.h> | |||
| #include <net/if.h> | |||
| #include <sys/sysinfo.h> | |||
| #include <sys/file.h> | |||
| #include <signal.h> | |||
| @@ -494,52 +494,52 @@ int64 String::hashCode64() const throw() | |||
| } | |||
| //============================================================================== | |||
| bool JUCE_CALLTYPE operator== (const String& string1, const String& string2) throw() | |||
| bool JUCE_PUBLIC_FUNCTION operator== (const String& string1, const String& string2) throw() | |||
| { | |||
| return string1.compare (string2) == 0; | |||
| } | |||
| bool JUCE_CALLTYPE operator== (const String& string1, const char* string2) throw() | |||
| bool JUCE_PUBLIC_FUNCTION operator== (const String& string1, const char* string2) throw() | |||
| { | |||
| return string1.compare (string2) == 0; | |||
| } | |||
| bool JUCE_CALLTYPE operator== (const String& string1, const juce_wchar* string2) throw() | |||
| bool JUCE_PUBLIC_FUNCTION operator== (const String& string1, const juce_wchar* string2) throw() | |||
| { | |||
| return string1.compare (string2) == 0; | |||
| } | |||
| bool JUCE_CALLTYPE operator!= (const String& string1, const String& string2) throw() | |||
| bool JUCE_PUBLIC_FUNCTION operator!= (const String& string1, const String& string2) throw() | |||
| { | |||
| return string1.compare (string2) != 0; | |||
| } | |||
| bool JUCE_CALLTYPE operator!= (const String& string1, const char* string2) throw() | |||
| bool JUCE_PUBLIC_FUNCTION operator!= (const String& string1, const char* string2) throw() | |||
| { | |||
| return string1.compare (string2) != 0; | |||
| } | |||
| bool JUCE_CALLTYPE operator!= (const String& string1, const juce_wchar* string2) throw() | |||
| bool JUCE_PUBLIC_FUNCTION operator!= (const String& string1, const juce_wchar* string2) throw() | |||
| { | |||
| return string1.compare (string2) != 0; | |||
| } | |||
| bool JUCE_CALLTYPE operator> (const String& string1, const String& string2) throw() | |||
| bool JUCE_PUBLIC_FUNCTION operator> (const String& string1, const String& string2) throw() | |||
| { | |||
| return string1.compare (string2) > 0; | |||
| } | |||
| bool JUCE_CALLTYPE operator< (const String& string1, const String& string2) throw() | |||
| bool JUCE_PUBLIC_FUNCTION operator< (const String& string1, const String& string2) throw() | |||
| { | |||
| return string1.compare (string2) < 0; | |||
| } | |||
| bool JUCE_CALLTYPE operator>= (const String& string1, const String& string2) throw() | |||
| bool JUCE_PUBLIC_FUNCTION operator>= (const String& string1, const String& string2) throw() | |||
| { | |||
| return string1.compare (string2) >= 0; | |||
| } | |||
| bool JUCE_CALLTYPE operator<= (const String& string1, const String& string2) throw() | |||
| bool JUCE_PUBLIC_FUNCTION operator<= (const String& string1, const String& string2) throw() | |||
| { | |||
| return string1.compare (string2) <= 0; | |||
| } | |||
| @@ -658,114 +658,114 @@ void String::append (const juce_wchar* const other, const int howMany) | |||
| } | |||
| //============================================================================== | |||
| const String JUCE_CALLTYPE operator+ (const char* const string1, const String& string2) | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (const char* const string1, const String& string2) | |||
| { | |||
| String s (string1); | |||
| return s += string2; | |||
| } | |||
| const String JUCE_CALLTYPE operator+ (const juce_wchar* const string1, const String& string2) | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (const juce_wchar* const string1, const String& string2) | |||
| { | |||
| String s (string1); | |||
| return s += string2; | |||
| } | |||
| const String JUCE_CALLTYPE operator+ (const char string1, const String& string2) | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (const char string1, const String& string2) | |||
| { | |||
| return String::charToString (string1) + string2; | |||
| } | |||
| const String JUCE_CALLTYPE operator+ (const juce_wchar string1, const String& string2) | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (const juce_wchar string1, const String& string2) | |||
| { | |||
| return String::charToString (string1) + string2; | |||
| } | |||
| const String JUCE_CALLTYPE operator+ (String string1, const String& string2) | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (String string1, const String& string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| const String JUCE_CALLTYPE operator+ (String string1, const char* const string2) | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (String string1, const char* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar* const string2) | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (String string1, const juce_wchar* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| const String JUCE_CALLTYPE operator+ (String string1, const char string2) | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (String string1, const char string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar string2) | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (String string1, const juce_wchar string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const char characterToAppend) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const char characterToAppend) | |||
| { | |||
| return string1 += characterToAppend; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar characterToAppend) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const juce_wchar characterToAppend) | |||
| { | |||
| return string1 += characterToAppend; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const char* const string2) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const char* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar* const string2) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const juce_wchar* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const String& string2) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const String& string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const short number) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const short number) | |||
| { | |||
| return string1 += (int) number; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const int number) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const int number) | |||
| { | |||
| return string1 += number; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const unsigned int number) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const unsigned int number) | |||
| { | |||
| return string1 += number; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const long number) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const long number) | |||
| { | |||
| return string1 += (int) number; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const unsigned long number) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const unsigned long number) | |||
| { | |||
| return string1 += (unsigned int) number; | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const float number) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const float number) | |||
| { | |||
| return string1 += String (number); | |||
| } | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const double number) | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const double number) | |||
| { | |||
| return string1 += String (number); | |||
| } | |||
| OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const String& text) | |||
| 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). | |||
| @@ -1048,86 +1048,86 @@ private: | |||
| //============================================================================== | |||
| /** Concatenates two strings. */ | |||
| const String JUCE_CALLTYPE operator+ (const char* string1, const String& string2); | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (const char* string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| const String JUCE_CALLTYPE operator+ (const juce_wchar* string1, const String& string2); | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (const juce_wchar* string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| const String JUCE_CALLTYPE operator+ (char string1, const String& string2); | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (char string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| const String JUCE_CALLTYPE operator+ (juce_wchar string1, const String& string2); | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (juce_wchar string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| const String JUCE_CALLTYPE operator+ (String string1, const String& string2); | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (String string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| const String JUCE_CALLTYPE operator+ (String string1, const char* string2); | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (String string1, const char* string2); | |||
| /** Concatenates two strings. */ | |||
| const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar* string2); | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (String string1, const juce_wchar* string2); | |||
| /** Concatenates two strings. */ | |||
| const String JUCE_CALLTYPE operator+ (String string1, char characterToAppend); | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (String string1, char characterToAppend); | |||
| /** Concatenates two strings. */ | |||
| const String JUCE_CALLTYPE operator+ (String string1, juce_wchar characterToAppend); | |||
| const String JUCE_PUBLIC_FUNCTION operator+ (String string1, juce_wchar characterToAppend); | |||
| //============================================================================== | |||
| /** Appends a character at the end of a string. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, char characterToAppend); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, char characterToAppend); | |||
| /** Appends a character at the end of a string. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, juce_wchar characterToAppend); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, juce_wchar characterToAppend); | |||
| /** Appends a string to the end of the first one. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const char* string2); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const char* string2); | |||
| /** Appends a string to the end of the first one. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar* string2); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const juce_wchar* string2); | |||
| /** Appends a string to the end of the first one. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, const String& string2); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, const String& string2); | |||
| /** Appends a decimal number at the end of a string. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, short number); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, short number); | |||
| /** Appends a decimal number at the end of a string. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, int number); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, int number); | |||
| /** Appends a decimal number at the end of a string. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, unsigned int number); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, unsigned int number); | |||
| /** Appends a decimal number at the end of a string. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, long number); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, long number); | |||
| /** Appends a decimal number at the end of a string. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, unsigned long number); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, unsigned long number); | |||
| /** Appends a decimal number at the end of a string. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, float number); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, float number); | |||
| /** Appends a decimal number at the end of a string. */ | |||
| String& JUCE_CALLTYPE operator<< (String& string1, double number); | |||
| String& JUCE_PUBLIC_FUNCTION operator<< (String& string1, double number); | |||
| //============================================================================== | |||
| /** Case-sensitive comparison of two strings. */ | |||
| bool JUCE_CALLTYPE operator== (const String& string1, const String& string2) throw(); | |||
| bool JUCE_PUBLIC_FUNCTION operator== (const String& string1, const String& string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| bool JUCE_CALLTYPE operator== (const String& string1, const char* string2) throw(); | |||
| bool JUCE_PUBLIC_FUNCTION operator== (const String& string1, const char* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| bool JUCE_CALLTYPE operator== (const String& string1, const juce_wchar* string2) throw(); | |||
| bool JUCE_PUBLIC_FUNCTION operator== (const String& string1, const juce_wchar* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| bool JUCE_CALLTYPE operator!= (const String& string1, const String& string2) throw(); | |||
| bool JUCE_PUBLIC_FUNCTION operator!= (const String& string1, const String& string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| bool JUCE_CALLTYPE operator!= (const String& string1, const char* string2) throw(); | |||
| bool JUCE_PUBLIC_FUNCTION operator!= (const String& string1, const char* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| bool JUCE_CALLTYPE operator!= (const String& string1, const juce_wchar* string2) throw(); | |||
| bool JUCE_PUBLIC_FUNCTION operator!= (const String& string1, const juce_wchar* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| bool JUCE_CALLTYPE operator> (const String& string1, const String& string2) throw(); | |||
| bool JUCE_PUBLIC_FUNCTION operator> (const String& string1, const String& string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| bool JUCE_CALLTYPE operator< (const String& string1, const String& string2) throw(); | |||
| bool JUCE_PUBLIC_FUNCTION operator< (const String& string1, const String& string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| bool JUCE_CALLTYPE operator>= (const String& string1, const String& string2) throw(); | |||
| bool JUCE_PUBLIC_FUNCTION operator>= (const String& string1, const String& string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| bool JUCE_CALLTYPE operator<= (const String& string1, const String& string2) throw(); | |||
| bool JUCE_PUBLIC_FUNCTION operator<= (const String& string1, const String& string2) throw(); | |||
| //============================================================================== | |||
| /** This streaming override allows you to pass a juce String directly into std output streams. | |||
| This is very handy for writing strings to std::cout, std::cerr, etc. | |||
| */ | |||
| template <class charT, class traits> | |||
| std::basic_ostream <charT, traits>& JUCE_CALLTYPE operator<< (std::basic_ostream <charT, traits>& stream, const String& stringToWrite) | |||
| std::basic_ostream <charT, traits>& JUCE_PUBLIC_FUNCTION operator<< (std::basic_ostream <charT, traits>& stream, const String& stringToWrite) | |||
| { | |||
| return stream << stringToWrite.toUTF8(); | |||
| } | |||
| /** Writes a string to an OutputStream as UTF8. */ | |||
| OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const String& text); | |||
| OutputStream& JUCE_PUBLIC_FUNCTION operator<< (OutputStream& stream, const String& text); | |||
| #endif // __JUCE_STRING_JUCEHEADER__ | |||
| @@ -29,6 +29,7 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "juce_XmlDocument.h" | |||
| #include "../io/streams/juce_FileInputSource.h" | |||
| #include "../io/streams/juce_MemoryOutputStream.h" | |||
| //============================================================================== | |||
| @@ -80,20 +81,9 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle | |||
| if (in != 0) | |||
| { | |||
| MemoryBlock data; | |||
| in->readIntoMemoryBlock (data, onlyReadOuterDocumentElement ? 8192 : -1); | |||
| if (data.getSize() >= 2 | |||
| && ((data[0] == (char)-2 && data[1] == (char)-1) | |||
| || (data[0] == (char)-1 && data[1] == (char)-2))) | |||
| { | |||
| textToParse = String::createStringFromData (static_cast <const char*> (data.getData()), (int) data.getSize()); | |||
| } | |||
| else | |||
| { | |||
| textToParse = String::fromUTF8 (static_cast <const char*> (data.getData()), (int) data.getSize()); | |||
| } | |||
| MemoryOutputStream data; | |||
| data.writeFromInputStream (*in, onlyReadOuterDocumentElement ? 8192 : -1); | |||
| textToParse = data.toString(); | |||
| if (! onlyReadOuterDocumentElement) | |||
| originalText = textToParse; | |||
| @@ -386,7 +386,7 @@ const String XmlElement::createDocument (const String& dtdToUse, | |||
| const String& encodingType, | |||
| const int lineWrapLength) const | |||
| { | |||
| MemoryOutputStream mem (2048, 4096); | |||
| MemoryOutputStream mem (2048); | |||
| writeToStream (mem, dtdToUse, allOnOneLine, includeXmlHeader, encodingType, lineWrapLength); | |||
| return mem.toUTF8(); | |||