| @@ -103,7 +103,7 @@ public: | |||
| void anotherInstanceStarted (const String& commandLine) | |||
| { | |||
| if (theMainWindow != 0) | |||
| if (theMainWindow != 0 && commandLine.unquoted().isNotEmpty()) | |||
| theMainWindow->openFile (commandLine.unquoted()); | |||
| } | |||
| }; | |||
| @@ -1771,24 +1771,24 @@ namespace TimeHelpers | |||
| : (value - ((value / modulo) + 1) * modulo)); | |||
| } | |||
| int doFTime (juce_wchar* const dest, const int maxChars, const String& format, const struct tm* const tm) throw() | |||
| int doFTime (CharPointer_UTF32 dest, const int maxChars, const String& format, const struct tm* const tm) throw() | |||
| { | |||
| #if JUCE_ANDROID | |||
| HeapBlock <char> tempDest; | |||
| tempDest.calloc (maxChars + 2); | |||
| const int result = (int) strftime (tempDest, maxChars, format.toUTF8(), tm); | |||
| if (result > 0) | |||
| CharPointer_UTF32 (dest).writeAll (CharPointer_UTF8 (tempDest.getData())); | |||
| dest.writeAll (CharPointer_UTF8 (tempDest.getData())); | |||
| return result; | |||
| #elif JUCE_WINDOWS | |||
| HeapBlock <wchar_t> tempDest; | |||
| tempDest.calloc (maxChars + 2); | |||
| const int result = (int) wcsftime (tempDest, maxChars, format.toUTF16(), tm); | |||
| if (result > 0) | |||
| CharPointer_UTF32 (dest).writeAll (CharPointer_UTF16 (tempDest.getData())); | |||
| dest.writeAll (CharPointer_UTF16 (tempDest.getData())); | |||
| return result; | |||
| #else | |||
| return (int) wcsftime (dest, maxChars, format.toUTF32(), tm); | |||
| return (int) wcsftime (dest.getAddress(), maxChars, format.toUTF32(), tm); | |||
| #endif | |||
| } | |||
| @@ -2016,13 +2016,13 @@ const String Time::formatted (const String& format) const | |||
| struct tm t (TimeHelpers::millisToLocal (millisSinceEpoch)); | |||
| while (TimeHelpers::doFTime (buffer.getData(), bufferSize, format, &t) <= 0) | |||
| while (TimeHelpers::doFTime (CharPointer_UTF32 (buffer.getData()), bufferSize, format, &t) <= 0) | |||
| { | |||
| bufferSize += 128; | |||
| buffer.malloc (bufferSize); | |||
| } | |||
| return String (buffer); | |||
| return CharPointer_UTF32 (buffer.getData()); | |||
| } | |||
| int Time::getYear() const throw() | |||
| @@ -4490,7 +4490,7 @@ var::var (const char* const value_) : type (&VariantType_String::instance) | |||
| value.stringValue = new String (value_); | |||
| } | |||
| var::var (const juce_wchar* const value_) : type (&VariantType_String::instance) | |||
| var::var (const wchar_t* const value_) : type (&VariantType_String::instance) | |||
| { | |||
| value.stringValue = new String (value_); | |||
| } | |||
| @@ -4538,7 +4538,7 @@ var& var::operator= (int64 newValue) { var v (newValue); swapWith (v); return | |||
| var& var::operator= (bool newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (double newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (const char* newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (const juce_wchar* newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (const wchar_t* newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (const String& newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (DynamicObject* newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (MethodFunction newValue) { var v (newValue); swapWith (v); return *this; } | |||
| @@ -10390,7 +10390,7 @@ public: | |||
| buffer[i] = (juce_wchar) (1 + Random::getSystemRandom().nextInt (0xff)); | |||
| } | |||
| return buffer; | |||
| return CharPointer_UTF32 (buffer); | |||
| } | |||
| }; | |||
| @@ -11173,7 +11173,6 @@ END_JUCE_NAMESPACE | |||
| #endif | |||
| #include <cctype> | |||
| #include <ctime> | |||
| BEGIN_JUCE_NAMESPACE | |||
| @@ -11205,6 +11204,10 @@ bool CharacterFunctions::isLowerCase (const juce_wchar character) throw() | |||
| #endif | |||
| } | |||
| #if JUCE_MSVC | |||
| #pragma warning (pop) | |||
| #endif | |||
| bool CharacterFunctions::isWhitespace (const char character) throw() | |||
| { | |||
| return character == ' ' || (character <= 13 && character >= 9); | |||
| @@ -11265,10 +11268,6 @@ int CharacterFunctions::getHexDigitValue (const juce_wchar digit) throw() | |||
| return -1; | |||
| } | |||
| #if JUCE_MSVC | |||
| #pragma warning (pop) | |||
| #endif | |||
| double CharacterFunctions::mulexp10 (const double value, int exponent) throw() | |||
| { | |||
| if (exponent == 0) | |||
| @@ -11443,6 +11442,8 @@ END_JUCE_NAMESPACE | |||
| BEGIN_JUCE_NAMESPACE | |||
| NewLine newLine; | |||
| #if defined (JUCE_STRINGS_ARE_UNICODE) && ! JUCE_STRINGS_ARE_UNICODE | |||
| #error "JUCE_STRINGS_ARE_UNICODE is deprecated! All strings are now unicode by default." | |||
| #endif | |||
| @@ -11455,7 +11456,10 @@ BEGIN_JUCE_NAMESPACE | |||
| typedef CharPointer_UTF32 CharPointer_wchar_t; | |||
| #endif | |||
| NewLine newLine; | |||
| static inline CharPointer_wchar_t castToCharPointer_wchar_t (const void* t) throw() | |||
| { | |||
| return CharPointer_wchar_t (static_cast <const CharPointer_wchar_t::CharType*> (t)); | |||
| } | |||
| class StringHolder | |||
| { | |||
| @@ -11615,20 +11619,6 @@ private: | |||
| StringHolder StringHolder::empty; | |||
| const String String::empty; | |||
| void String::appendFixedLength (const char* const newText, const int numExtraChars) | |||
| { | |||
| if (numExtraChars > 0) | |||
| { | |||
| const size_t byteOffsetOfNull = getByteOffsetOfEnd(); | |||
| const size_t newBytesNeeded = sizeof (CharPointerType::CharType) + byteOffsetOfNull + sizeof (CharPointerType::CharType) * numExtraChars; | |||
| text = StringHolder::makeUniqueWithByteSize (text, newBytesNeeded); | |||
| CharPointerType newEnd (addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull)); | |||
| newEnd.writeWithCharLimit (CharPointer_ASCII (newText), numExtraChars); | |||
| } | |||
| } | |||
| void String::preallocateBytes (const size_t numBytesNeeded) | |||
| { | |||
| text = StringHolder::makeUniqueWithByteSize (text, numBytesNeeded + sizeof (CharPointerType::CharType)); | |||
| @@ -11669,14 +11659,6 @@ String::String (const PreallocationBytes& preallocationSize) | |||
| { | |||
| } | |||
| /*String::String (const String& stringToCopy, const size_t bytesToAllocate) | |||
| : text (0) | |||
| { | |||
| const size_t otherSize = StringHolder::getAllocatedNumBytes (stringToCopy.text); | |||
| text = StringHolder::createUninitialised (jmax (bytesToAllocate, otherSize)); | |||
| StringHolder::copyChars (text, stringToCopy.text, otherSize); | |||
| }*/ | |||
| String::String (const char* const t) | |||
| : text (StringHolder::createFromCharPointer (CharPointer_ASCII (t))) | |||
| { | |||
| @@ -11715,16 +11697,6 @@ String::String (const char* const t, const size_t maxChars) | |||
| jassert (t == 0 || CharPointer_ASCII::isValidString (t, (int) maxChars)); | |||
| } | |||
| String::String (const juce_wchar* const t) | |||
| : text (StringHolder::createFromCharPointer (CharPointer_UTF32 (t))) | |||
| { | |||
| } | |||
| String::String (const juce_wchar* const t, const size_t maxChars) | |||
| : text (StringHolder::createFromCharPointer (CharPointer_UTF32 (t), maxChars)) | |||
| { | |||
| } | |||
| String::String (const CharPointer_UTF8& t) | |||
| : text (StringHolder::createFromCharPointer (t)) | |||
| { | |||
| @@ -11775,19 +11747,15 @@ String::String (const CharPointer_ASCII& t) | |||
| { | |||
| } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| String::String (const wchar_t* const t) | |||
| : text (StringHolder::createFromCharPointer | |||
| (CharPointer_wchar_t (reinterpret_cast <const CharPointer_wchar_t::CharType*> (t)))) | |||
| : text (StringHolder::createFromCharPointer (castToCharPointer_wchar_t (t))) | |||
| { | |||
| } | |||
| String::String (const wchar_t* const t, size_t maxChars) | |||
| : text (StringHolder::createFromCharPointer | |||
| (CharPointer_wchar_t (reinterpret_cast <const CharPointer_wchar_t::CharType*> (t)), maxChars)) | |||
| : text (StringHolder::createFromCharPointer (castToCharPointer_wchar_t (t), maxChars)) | |||
| { | |||
| } | |||
| #endif | |||
| const String String::charToString (const juce_wchar character) | |||
| { | |||
| @@ -12018,7 +11986,7 @@ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const char* strin | |||
| return string1.compare (string2) == 0; | |||
| } | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const juce_wchar* string2) throw() | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const wchar_t* string2) throw() | |||
| { | |||
| return string1.compare (string2) == 0; | |||
| } | |||
| @@ -12048,7 +12016,7 @@ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const char* strin | |||
| return string1.compare (string2) != 0; | |||
| } | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const juce_wchar* string2) throw() | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const wchar_t* string2) throw() | |||
| { | |||
| return string1.compare (string2) != 0; | |||
| } | |||
| @@ -12088,13 +12056,13 @@ JUCE_API bool JUCE_CALLTYPE operator<= (const String& string1, const String& str | |||
| return string1.compare (string2) <= 0; | |||
| } | |||
| bool String::equalsIgnoreCase (const juce_wchar* t) const throw() | |||
| bool String::equalsIgnoreCase (const wchar_t* const t) const throw() | |||
| { | |||
| return t != 0 ? text.compareIgnoreCase (CharPointer_UTF32 (t)) == 0 | |||
| return t != 0 ? text.compareIgnoreCase (castToCharPointer_wchar_t (t)) == 0 | |||
| : isEmpty(); | |||
| } | |||
| bool String::equalsIgnoreCase (const char* t) const throw() | |||
| bool String::equalsIgnoreCase (const char* const t) const throw() | |||
| { | |||
| return t != 0 ? text.compareIgnoreCase (CharPointer_UTF8 (t)) == 0 | |||
| : isEmpty(); | |||
| @@ -12111,14 +12079,14 @@ int String::compare (const String& other) const throw() | |||
| return (text == other.text) ? 0 : text.compare (other.text); | |||
| } | |||
| int String::compare (const char* other) const throw() | |||
| int String::compare (const char* const other) const throw() | |||
| { | |||
| return text.compare (CharPointer_UTF8 (other)); | |||
| } | |||
| int String::compare (const juce_wchar* other) const throw() | |||
| int String::compare (const wchar_t* const other) const throw() | |||
| { | |||
| return text.compare (CharPointer_UTF32 (other)); | |||
| return text.compare (castToCharPointer_wchar_t (other)); | |||
| } | |||
| int String::compareIgnoreCase (const String& other) const throw() | |||
| @@ -12146,9 +12114,30 @@ void String::append (const String& textToAppend, size_t maxCharsToTake) | |||
| appendCharPointer (textToAppend.text, maxCharsToTake); | |||
| } | |||
| String& String::operator+= (const juce_wchar* const t) | |||
| String& String::operator+= (const wchar_t* const t) | |||
| { | |||
| appendCharPointer (castToCharPointer_wchar_t (t)); | |||
| return *this; | |||
| } | |||
| String& String::operator+= (const char* const t) | |||
| { | |||
| appendCharPointer (CharPointer_UTF32 (t)); | |||
| /* If you get an assertion here, then you're trying to create a string from 8-bit data | |||
| that contains values greater than 127. These can NOT be correctly converted to unicode | |||
| because there's no way for the String class to know what encoding was used to | |||
| create them. The source data could be UTF-8, ASCII or one of many local code-pages. | |||
| To get around this problem, you must be more explicit when you pass an ambiguous 8-bit | |||
| string to the String class - so for example if your source data is actually UTF-8, | |||
| you'd call String (CharPointer_UTF8 ("my utf8 string..")), and it would be able to | |||
| correctly convert the multi-byte characters to unicode. It's *highly* recommended that | |||
| you use UTF-8 with escape characters in your source code to represent extended characters, | |||
| because there's no other way to represent these strings in a way that isn't dependent on | |||
| the compiler, source code editor and platform. | |||
| */ | |||
| jassert (t == 0 || CharPointer_ASCII::isValidString (t, std::numeric_limits<int>::max())); | |||
| appendCharPointer (CharPointer_ASCII (t)); | |||
| return *this; | |||
| } | |||
| @@ -12163,24 +12152,22 @@ String& String::operator+= (const String& other) | |||
| String& String::operator+= (const char ch) | |||
| { | |||
| return operator+= ((juce_wchar) ch); | |||
| const char asString[] = { ch, 0 }; | |||
| return operator+= (asString); | |||
| } | |||
| String& String::operator+= (const juce_wchar ch) | |||
| { | |||
| const juce_wchar asString[] = { ch, 0 }; | |||
| return operator+= (static_cast <const juce_wchar*> (asString)); | |||
| } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| String& String::operator+= (const wchar_t ch) | |||
| { | |||
| return operator+= ((juce_wchar) ch); | |||
| const wchar_t asString[] = { ch, 0 }; | |||
| return operator+= (asString); | |||
| } | |||
| String& String::operator+= (const wchar_t* t) | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| String& String::operator+= (const juce_wchar ch) | |||
| { | |||
| return operator+= (String (t)); | |||
| const juce_wchar asString[] = { ch, 0 }; | |||
| appendCharPointer (CharPointer_UTF32 (asString)); | |||
| return *this; | |||
| } | |||
| #endif | |||
| @@ -12189,7 +12176,21 @@ String& String::operator+= (const int number) | |||
| char buffer [16]; | |||
| char* const end = buffer + numElementsInArray (buffer); | |||
| char* const start = NumberToStringConverters::numberToString (end, number); | |||
| appendFixedLength (start, (int) (end - start)); | |||
| const int numExtraChars = (int) (end - start); | |||
| if (numExtraChars > 0) | |||
| { | |||
| const size_t byteOffsetOfNull = getByteOffsetOfEnd(); | |||
| const size_t newBytesNeeded = sizeof (CharPointerType::CharType) + byteOffsetOfNull | |||
| + sizeof (CharPointerType::CharType) * numExtraChars; | |||
| text = StringHolder::makeUniqueWithByteSize (text, newBytesNeeded); | |||
| CharPointerType newEnd (addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull)); | |||
| newEnd.writeWithCharLimit (CharPointer_ASCII (start), numExtraChars); | |||
| } | |||
| return *this; | |||
| } | |||
| @@ -12199,7 +12200,7 @@ JUCE_API const String JUCE_CALLTYPE operator+ (const char* const string1, const | |||
| return s += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const juce_wchar* const string1, const String& string2) | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const wchar_t* const string1, const String& string2) | |||
| { | |||
| String s (string1); | |||
| return s += string2; | |||
| @@ -12210,104 +12211,43 @@ JUCE_API const String JUCE_CALLTYPE operator+ (const char string1, const String& | |||
| return String::charToString (string1) + string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const juce_wchar string1, const String& string2) | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const wchar_t string1, const String& string2) | |||
| { | |||
| return String::charToString (string1) + string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const String& string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const char* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const char string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, wchar_t string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const wchar_t* string2) | |||
| { | |||
| string1.appendCharPointer (CharPointer_wchar_t (reinterpret_cast <const CharPointer_wchar_t::CharType*> (string2))); | |||
| return string1; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const wchar_t* string1, const String& string2) | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const juce_wchar string1, const String& string2) | |||
| { | |||
| String s (string1); | |||
| return s += string2; | |||
| return String::charToString (string1) + string2; | |||
| } | |||
| #endif | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const char characterToAppend) | |||
| { | |||
| return string1 += characterToAppend; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar characterToAppend) | |||
| { | |||
| return string1 += characterToAppend; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const String& s2) { return s1 += s2; } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const char* const s2) { return s1 += s2; } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const wchar_t* s2) { return s1 += s2; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const char* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const String& string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const short number) | |||
| { | |||
| return string1 += (int) number; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const int number) | |||
| { | |||
| return string1 += number; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const char s2) { return s1 += s2; } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const wchar_t s2) { return s1 += s2; } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const juce_wchar s2) { return s1 += s2; } | |||
| #endif | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const long number) | |||
| { | |||
| return string1 += (int) number; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const char s2) { return s1 += s2; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const wchar_t s2) { return s1 += s2; } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const juce_wchar s2) { return s1 += s2; } | |||
| #endif | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const float number) | |||
| { | |||
| return string1 += String (number); | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const char* const s2) { return s1 += s2; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const wchar_t* const s2) { return s1 += s2; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const String& s2) { return s1 += s2; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const double number) | |||
| { | |||
| return string1 += String (number); | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const short number) { return s1 += (int) number; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const int number) { return s1 += number; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const long number) { return s1 += (int) number; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const float number) { return s1 += String (number); } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const double number) { return s1 += String (number); } | |||
| JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const String& text) | |||
| { | |||
| @@ -13331,10 +13271,8 @@ bool String::containsNonWhitespaceChars() const throw() | |||
| return false; | |||
| } | |||
| const String String::formatted (const juce_wchar* const pf, ... ) | |||
| const String String::formatted (const String& pf, ... ) | |||
| { | |||
| jassert (pf != 0); | |||
| va_list args; | |||
| va_start (args, pf); | |||
| @@ -13346,17 +13284,17 @@ const String String::formatted (const juce_wchar* const pf, ... ) | |||
| HeapBlock <wchar_t> temp (bufferSize); | |||
| va_list tempArgs; | |||
| va_copy (tempArgs, args); | |||
| const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf, tempArgs); | |||
| const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toUTF32(), tempArgs); | |||
| va_end (tempArgs); | |||
| #elif JUCE_WINDOWS | |||
| HeapBlock <wchar_t> temp (bufferSize); | |||
| const int num = (int) _vsnwprintf (temp.getData(), bufferSize - 1, String (pf).toUTF16(), args); | |||
| const int num = (int) _vsnwprintf (temp.getData(), bufferSize - 1, pf.toUTF16(), args); | |||
| #elif JUCE_ANDROID | |||
| HeapBlock <char> temp (bufferSize); | |||
| const int num = (int) vsnprintf (temp.getData(), bufferSize - 1, String (pf).toUTF8(), args); | |||
| const int num = (int) vsnprintf (temp.getData(), bufferSize - 1, pf.toUTF8(), args); | |||
| #else | |||
| HeapBlock <wchar_t> temp (bufferSize); | |||
| const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf, args); | |||
| const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toUTF32(), args); | |||
| #endif | |||
| if (num > 0) | |||
| @@ -13421,14 +13359,14 @@ struct HexConverter | |||
| { | |||
| static const String hexToString (Type v) | |||
| { | |||
| juce_wchar buffer[32]; | |||
| juce_wchar* const end = buffer + 32; | |||
| juce_wchar* t = end; | |||
| char buffer[32]; | |||
| char* const end = buffer + 32; | |||
| char* t = end; | |||
| *--t = 0; | |||
| do | |||
| { | |||
| *--t = (juce_wchar) hexDigits [(int) (v & 15)]; | |||
| *--t = hexDigits [(int) (v & 15)]; | |||
| v >>= 4; | |||
| } while (v != 0); | |||
| @@ -13749,7 +13687,7 @@ public: | |||
| buffer[i] = (juce_wchar) (1 + Random::getSystemRandom().nextInt (0xff)); | |||
| } | |||
| return buffer; | |||
| return CharPointer_UTF32 (buffer); | |||
| } | |||
| void runTest() | |||
| @@ -14055,17 +13993,6 @@ StringArray::StringArray (const char* const* const initialStrings, const int num | |||
| StringArrayHelpers::addArray (strings, initialStrings, numberOfStrings); | |||
| } | |||
| StringArray::StringArray (const juce_wchar* const* const initialStrings) | |||
| { | |||
| StringArrayHelpers::addArray (strings, initialStrings); | |||
| } | |||
| StringArray::StringArray (const juce_wchar* const* const initialStrings, const int numberOfStrings) | |||
| { | |||
| StringArrayHelpers::addArray (strings, initialStrings, numberOfStrings); | |||
| } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| StringArray::StringArray (const wchar_t* const* const initialStrings) | |||
| { | |||
| StringArrayHelpers::addArray (strings, initialStrings); | |||
| @@ -14075,7 +14002,6 @@ StringArray::StringArray (const wchar_t* const* const initialStrings, const int | |||
| { | |||
| StringArrayHelpers::addArray (strings, initialStrings, numberOfStrings); | |||
| } | |||
| #endif | |||
| StringArray& StringArray::operator= (const StringArray& other) | |||
| { | |||
| @@ -14692,7 +14618,7 @@ const String::CharPointerType StringPool::getPooledString (const char* const s) | |||
| return StringPoolHelpers::getPooledStringFromArray (strings, s); | |||
| } | |||
| const String::CharPointerType StringPool::getPooledString (const juce_wchar* const s) | |||
| const String::CharPointerType StringPool::getPooledString (const wchar_t* const s) | |||
| { | |||
| if (s == 0 || *s == 0) | |||
| return String::empty.getCharPointer(); | |||
| @@ -242924,8 +242850,14 @@ public: | |||
| Pimpl (String name, const int timeOutMillisecs) | |||
| : handle (0), refCount (1) | |||
| { | |||
| name = "Local\\" + name.replaceCharacter ('\\', '/'); | |||
| handle = CreateMutexW (0, TRUE, name.toUTF16().getAddress()); | |||
| name = name.replaceCharacter ('\\', '/'); | |||
| handle = CreateMutexW (0, TRUE, ("Global\\" + name).toUTF16().getAddress()); | |||
| // Not 100% sure why a global mutex sometimes can't be allocated, but if it fails, fall back to | |||
| // a local one. (A local one also sometimes fails on other machines so neither type appears to be | |||
| // universally reliable) | |||
| if (handle == 0) | |||
| handle = CreateMutexW (0, TRUE, ("Local\\" + name).toUTF16().getAddress()); | |||
| if (handle != 0 && GetLastError() == ERROR_ALREADY_EXISTS) | |||
| { | |||
| @@ -244564,8 +244496,10 @@ static LRESULT CALLBACK juce_MessageWndProc (HWND h, | |||
| } | |||
| else if (message == WM_COPYDATA && ((const COPYDATASTRUCT*) lParam)->dwData == broadcastId) | |||
| { | |||
| const String messageString ((const juce_wchar*) ((const COPYDATASTRUCT*) lParam)->lpData, | |||
| ((const COPYDATASTRUCT*) lParam)->cbData / sizeof (juce_wchar)); | |||
| const COPYDATASTRUCT* data = (COPYDATASTRUCT*) lParam; | |||
| const String messageString (CharPointer_UTF32 ((const CharPointer_UTF32::CharType*) data->lpData), | |||
| data->cbData / sizeof (CharPointer_UTF32::CharType)); | |||
| PostMessage (juce_messageWindowHandle, broadcastId, 0, (LPARAM) new String (messageString)); | |||
| return 0; | |||
| @@ -244715,8 +244649,8 @@ void MessageManager::broadcastMessage (const String& value) | |||
| COPYDATASTRUCT data; | |||
| data.dwData = broadcastId; | |||
| data.cbData = (localCopy.length() + 1) * sizeof (juce_wchar); | |||
| data.lpData = (void*) localCopy.toUTF16().getAddress(); | |||
| data.cbData = (localCopy.length() + 1) * sizeof (CharPointer_UTF32::CharType); | |||
| data.lpData = (void*) localCopy.toUTF32().getAddress(); | |||
| for (int i = windows.size(); --i >= 0;) | |||
| { | |||
| @@ -244732,9 +244666,7 @@ void MessageManager::broadcastMessage (const String& value) | |||
| SendMessageTimeout (hwnd, WM_COPYDATA, | |||
| (WPARAM) juce_messageWindowHandle, | |||
| (LPARAM) &data, | |||
| SMTO_BLOCK | SMTO_ABORTIFHUNG, | |||
| 8000, | |||
| &result); | |||
| SMTO_BLOCK | SMTO_ABORTIFHUNG, 8000, &result); | |||
| } | |||
| } | |||
| } | |||
| @@ -272654,7 +272586,7 @@ public: | |||
| + pixelFormat.accumulationBufferBlueBits | |||
| + pixelFormat.accumulationBufferAlphaBits), | |||
| NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute) 1, | |||
| 0 | |||
| (NSOpenGLPixelFormatAttribute) 0 | |||
| }; | |||
| NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; | |||
| @@ -272803,7 +272735,7 @@ void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, | |||
| NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) 8, | |||
| NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) 24, | |||
| NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) 32, | |||
| 0 | |||
| (NSOpenGLPixelFormatAttribute) 0 | |||
| }; | |||
| NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attributes]; | |||
| @@ -278392,7 +278324,7 @@ public: | |||
| + pixelFormat.accumulationBufferBlueBits | |||
| + pixelFormat.accumulationBufferAlphaBits), | |||
| NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute) 1, | |||
| 0 | |||
| (NSOpenGLPixelFormatAttribute) 0 | |||
| }; | |||
| NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; | |||
| @@ -278541,7 +278473,7 @@ void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, | |||
| NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) 8, | |||
| NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) 24, | |||
| NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) 32, | |||
| 0 | |||
| (NSOpenGLPixelFormatAttribute) 0 | |||
| }; | |||
| NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attributes]; | |||
| @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} | |||
| */ | |||
| #define JUCE_MAJOR_VERSION 1 | |||
| #define JUCE_MINOR_VERSION 53 | |||
| #define JUCE_BUILDNUMBER 36 | |||
| #define JUCE_BUILDNUMBER 37 | |||
| /** Current Juce version number. | |||
| @@ -4292,23 +4292,15 @@ public: | |||
| */ | |||
| String (const char* text, size_t maxChars); | |||
| /** Creates a string from a zero-terminated unicode text string. */ | |||
| String (const juce_wchar* unicodeText); | |||
| /** Creates a string from a unicode text string. | |||
| This will use up the the first maxChars characters of the string (or | |||
| less if the string is actually shorter) | |||
| /** Creates a string from a whcar_t character string. | |||
| Depending on the platform, this may be treated as either UTF-32 or UTF-16. | |||
| */ | |||
| String (const juce_wchar* unicodeText, size_t maxChars); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Creates a string from a UTF-16 character string */ | |||
| String (const wchar_t* text); | |||
| /** Creates a string from a UTF-16 character string */ | |||
| /** Creates a string from a whcar_t character string. | |||
| Depending on the platform, this may be treated as either UTF-32 or UTF-16. | |||
| */ | |||
| String (const wchar_t* text, size_t maxChars); | |||
| #endif | |||
| /** Creates a string from a UTF-8 character string */ | |||
| String (const CharPointer_UTF8& text); | |||
| @@ -4389,22 +4381,22 @@ public: | |||
| /** Replaces this string's contents with another string. */ | |||
| String& operator= (const String& other) throw(); | |||
| /** Appends another string at the end of this one. */ | |||
| String& operator+= (const juce_wchar* textToAppend); | |||
| /** Appends another string at the end of this one. */ | |||
| String& operator+= (const String& stringToAppend); | |||
| /** Appends another string at the end of this one. */ | |||
| String& operator+= (const char* textToAppend); | |||
| /** Appends another string at the end of this one. */ | |||
| String& operator+= (const wchar_t* textToAppend); | |||
| /** Appends a decimal number at the end of this string. */ | |||
| String& operator+= (int numberToAppend); | |||
| /** Appends a character at the end of this string. */ | |||
| String& operator+= (char characterToAppend); | |||
| /** Appends a character at the end of this string. */ | |||
| String& operator+= (juce_wchar characterToAppend); | |||
| String& operator+= (wchar_t characterToAppend); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Appends a character at the end of this string. */ | |||
| String& operator+= (wchar_t characterToAppend); | |||
| /** Appends another string at the end of this one. */ | |||
| String& operator+= (const wchar_t* textToAppend); | |||
| String& operator+= (juce_wchar characterToAppend); | |||
| #endif | |||
| /** Appends a decimal number at the end of this string. */ | |||
| String& operator+= (int numberToAppend); | |||
| /** Appends a string to the end of this one. | |||
| @@ -4489,7 +4481,7 @@ public: | |||
| bool equalsIgnoreCase (const String& other) const throw(); | |||
| /** Case-insensitive comparison with another string. */ | |||
| bool equalsIgnoreCase (const juce_wchar* other) const throw(); | |||
| bool equalsIgnoreCase (const wchar_t* other) const throw(); | |||
| /** Case-insensitive comparison with another string. */ | |||
| bool equalsIgnoreCase (const char* other) const throw(); | |||
| @@ -4513,7 +4505,7 @@ public: | |||
| comes before the other one alphabetically, or positive if it | |||
| comes after it. | |||
| */ | |||
| int compare (const juce_wchar* other) const throw(); | |||
| int compare (const wchar_t* other) const throw(); | |||
| /** Case-insensitive comparison with another string. | |||
| @returns 0 if the two strings are identical; negative if this string | |||
| @@ -5062,7 +5054,7 @@ public: | |||
| If you're really determined to use it, at least make sure that you never, ever, | |||
| pass any String objects to it as parameters. | |||
| */ | |||
| static const String formatted (const juce_wchar* formatString, ... ); | |||
| static const String formatted (const String& formatString, ... ); | |||
| // Numeric conversions.. | |||
| @@ -5368,12 +5360,10 @@ private: | |||
| size_t numBytes; | |||
| }; | |||
| // This constructor preallocates a certain amount of memory | |||
| explicit String (const PreallocationBytes&); | |||
| JUCE_DEPRECATED (String (const String& stringToCopy, size_t charsToAllocate)); | |||
| explicit String (const PreallocationBytes&); // This constructor preallocates a certain amount of memory | |||
| void appendFixedLength (const char* text, int numExtraChars); | |||
| size_t getByteOffsetOfEnd() const throw(); | |||
| JUCE_DEPRECATED (String (const String& stringToCopy, size_t charsToAllocate)); | |||
| // This private cast operator should prevent strings being accidentally cast | |||
| // to bools (this is possible because the compiler can add an implicit cast | |||
| @@ -5382,41 +5372,46 @@ private: | |||
| }; | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const char* string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const char* string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const wchar_t* string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const juce_wchar* string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (char string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (char string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (wchar_t string1, const String& string2); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (juce_wchar string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (juce_wchar string1, const String& string2); | |||
| #endif | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const char* string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const char* string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar* string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const wchar_t* string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, char characterToAppend); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, char characterToAppend); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, juce_wchar characterToAppend); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, wchar_t characterToAppend); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, wchar_t characterToAppend); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const wchar_t* string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const wchar_t* string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, juce_wchar characterToAppend); | |||
| #endif | |||
| /** Appends a character at the end of a string. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, char characterToAppend); | |||
| /** Appends a character at the end of a string. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, wchar_t characterToAppend); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Appends a character at the end of a string. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, juce_wchar characterToAppend); | |||
| #endif | |||
| /** Appends a string to the end of the first one. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const char* string2); | |||
| /** Appends a string to the end of the first one. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar* string2); | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const wchar_t* string2); | |||
| /** Appends a string to the end of the first one. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const String& string2); | |||
| @@ -5436,7 +5431,7 @@ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const String& str | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const char* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const juce_wchar* string2) throw(); | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const wchar_t* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF8& string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| @@ -5448,7 +5443,7 @@ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const String& str | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const char* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const juce_wchar* string2) throw(); | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const wchar_t* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF8& string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| @@ -7574,7 +7569,7 @@ public: | |||
| The pool will own all the pointers that it returns, deleting them when the pool itself | |||
| is deleted. | |||
| */ | |||
| const String::CharPointerType getPooledString (const juce_wchar* original); | |||
| const String::CharPointerType getPooledString (const wchar_t* original); | |||
| /** Returns the number of strings in the pool. */ | |||
| int size() const throw(); | |||
| @@ -8413,7 +8408,7 @@ public: | |||
| var (bool value) throw(); | |||
| var (double value) throw(); | |||
| var (const char* value); | |||
| var (const juce_wchar* value); | |||
| var (const wchar_t* value); | |||
| var (const String& value); | |||
| var (DynamicObject* object); | |||
| var (MethodFunction method) throw(); | |||
| @@ -8424,7 +8419,7 @@ public: | |||
| var& operator= (bool value); | |||
| var& operator= (double value); | |||
| var& operator= (const char* value); | |||
| var& operator= (const juce_wchar* value); | |||
| var& operator= (const wchar_t* value); | |||
| var& operator= (const String& value); | |||
| var& operator= (DynamicObject* object); | |||
| var& operator= (MethodFunction method); | |||
| @@ -10132,20 +10127,6 @@ public: | |||
| */ | |||
| explicit StringArray (const char* const* strings); | |||
| /** Creates a copy of a null-terminated array of string literals. | |||
| Each item from the array passed-in is added, until it encounters a null pointer, | |||
| at which point it stops. | |||
| */ | |||
| explicit StringArray (const juce_wchar* const* strings); | |||
| /** Creates a copy of an array of string literals. | |||
| @param strings an array of strings to add. Null pointers in the array will be | |||
| treated as empty strings | |||
| @param numberOfStrings how many items there are in the array | |||
| */ | |||
| StringArray (const juce_wchar* const* strings, int numberOfStrings); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Creates a copy of a null-terminated array of string literals. | |||
| Each item from the array passed-in is added, until it encounters a null pointer, | |||
| at which point it stops. | |||
| @@ -10158,7 +10139,6 @@ public: | |||
| @param numberOfStrings how many items there are in the array | |||
| */ | |||
| StringArray (const wchar_t* const* strings, int numberOfStrings); | |||
| #endif | |||
| /** Destructor. */ | |||
| ~StringArray(); | |||
| @@ -333,7 +333,7 @@ var::var (const char* const value_) : type (&VariantType_String::instance) | |||
| value.stringValue = new String (value_); | |||
| } | |||
| var::var (const juce_wchar* const value_) : type (&VariantType_String::instance) | |||
| var::var (const wchar_t* const value_) : type (&VariantType_String::instance) | |||
| { | |||
| value.stringValue = new String (value_); | |||
| } | |||
| @@ -383,7 +383,7 @@ var& var::operator= (int64 newValue) { var v (newValue); swapWith ( | |||
| var& var::operator= (bool newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (double newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (const char* newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (const juce_wchar* newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (const wchar_t* newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (const String& newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (DynamicObject* newValue) { var v (newValue); swapWith (v); return *this; } | |||
| var& var::operator= (MethodFunction newValue) { var v (newValue); swapWith (v); return *this; } | |||
| @@ -67,7 +67,7 @@ public: | |||
| var (bool value) throw(); | |||
| var (double value) throw(); | |||
| var (const char* value); | |||
| var (const juce_wchar* value); | |||
| var (const wchar_t* value); | |||
| var (const String& value); | |||
| var (DynamicObject* object); | |||
| var (MethodFunction method) throw(); | |||
| @@ -78,7 +78,7 @@ public: | |||
| var& operator= (bool value); | |||
| var& operator= (double value); | |||
| var& operator= (const char* value); | |||
| var& operator= (const juce_wchar* value); | |||
| var& operator= (const wchar_t* value); | |||
| var& operator= (const String& value); | |||
| var& operator= (DynamicObject* object); | |||
| var& operator= (MethodFunction method); | |||
| @@ -33,7 +33,7 @@ | |||
| */ | |||
| #define JUCE_MAJOR_VERSION 1 | |||
| #define JUCE_MINOR_VERSION 53 | |||
| #define JUCE_BUILDNUMBER 36 | |||
| #define JUCE_BUILDNUMBER 37 | |||
| /** Current Juce version number. | |||
| @@ -116,24 +116,24 @@ namespace TimeHelpers | |||
| : (value - ((value / modulo) + 1) * modulo)); | |||
| } | |||
| int doFTime (juce_wchar* const dest, const int maxChars, const String& format, const struct tm* const tm) throw() | |||
| int doFTime (CharPointer_UTF32 dest, const int maxChars, const String& format, const struct tm* const tm) throw() | |||
| { | |||
| #if JUCE_ANDROID | |||
| HeapBlock <char> tempDest; | |||
| tempDest.calloc (maxChars + 2); | |||
| const int result = (int) strftime (tempDest, maxChars, format.toUTF8(), tm); | |||
| if (result > 0) | |||
| CharPointer_UTF32 (dest).writeAll (CharPointer_UTF8 (tempDest.getData())); | |||
| dest.writeAll (CharPointer_UTF8 (tempDest.getData())); | |||
| return result; | |||
| #elif JUCE_WINDOWS | |||
| HeapBlock <wchar_t> tempDest; | |||
| tempDest.calloc (maxChars + 2); | |||
| const int result = (int) wcsftime (tempDest, maxChars, format.toUTF16(), tm); | |||
| if (result > 0) | |||
| CharPointer_UTF32 (dest).writeAll (CharPointer_UTF16 (tempDest.getData())); | |||
| dest.writeAll (CharPointer_UTF16 (tempDest.getData())); | |||
| return result; | |||
| #else | |||
| return (int) wcsftime (dest, maxChars, format.toUTF32(), tm); | |||
| return (int) wcsftime (dest.getAddress(), maxChars, format.toUTF32(), tm); | |||
| #endif | |||
| } | |||
| @@ -368,13 +368,13 @@ const String Time::formatted (const String& format) const | |||
| struct tm t (TimeHelpers::millisToLocal (millisSinceEpoch)); | |||
| while (TimeHelpers::doFTime (buffer.getData(), bufferSize, format, &t) <= 0) | |||
| while (TimeHelpers::doFTime (CharPointer_UTF32 (buffer.getData()), bufferSize, format, &t) <= 0) | |||
| { | |||
| bufferSize += 128; | |||
| buffer.malloc (bufferSize); | |||
| } | |||
| return String (buffer); | |||
| return CharPointer_UTF32 (buffer.getData()); | |||
| } | |||
| //============================================================================== | |||
| @@ -153,7 +153,7 @@ public: | |||
| buffer[i] = (juce_wchar) (1 + Random::getSystemRandom().nextInt (0xff)); | |||
| } | |||
| return buffer; | |||
| return CharPointer_UTF32 (buffer); | |||
| } | |||
| }; | |||
| @@ -155,7 +155,7 @@ public: | |||
| + pixelFormat.accumulationBufferBlueBits | |||
| + pixelFormat.accumulationBufferAlphaBits), | |||
| NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute) 1, | |||
| 0 | |||
| (NSOpenGLPixelFormatAttribute) 0 | |||
| }; | |||
| NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; | |||
| @@ -307,7 +307,7 @@ void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, | |||
| NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) 8, | |||
| NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) 24, | |||
| NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) 32, | |||
| 0 | |||
| (NSOpenGLPixelFormatAttribute) 0 | |||
| }; | |||
| NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attributes]; | |||
| @@ -78,8 +78,10 @@ static LRESULT CALLBACK juce_MessageWndProc (HWND h, | |||
| } | |||
| else if (message == WM_COPYDATA && ((const COPYDATASTRUCT*) lParam)->dwData == broadcastId) | |||
| { | |||
| const String messageString ((const juce_wchar*) ((const COPYDATASTRUCT*) lParam)->lpData, | |||
| ((const COPYDATASTRUCT*) lParam)->cbData / sizeof (juce_wchar)); | |||
| const COPYDATASTRUCT* data = (COPYDATASTRUCT*) lParam; | |||
| const String messageString (CharPointer_UTF32 ((const CharPointer_UTF32::CharType*) data->lpData), | |||
| data->cbData / sizeof (CharPointer_UTF32::CharType)); | |||
| PostMessage (juce_messageWindowHandle, broadcastId, 0, (LPARAM) new String (messageString)); | |||
| return 0; | |||
| @@ -232,8 +234,8 @@ void MessageManager::broadcastMessage (const String& value) | |||
| COPYDATASTRUCT data; | |||
| data.dwData = broadcastId; | |||
| data.cbData = (localCopy.length() + 1) * sizeof (juce_wchar); | |||
| data.lpData = (void*) localCopy.toUTF16().getAddress(); | |||
| data.cbData = (localCopy.length() + 1) * sizeof (CharPointer_UTF32::CharType); | |||
| data.lpData = (void*) localCopy.toUTF32().getAddress(); | |||
| for (int i = windows.size(); --i >= 0;) | |||
| { | |||
| @@ -249,9 +251,7 @@ void MessageManager::broadcastMessage (const String& value) | |||
| SendMessageTimeout (hwnd, WM_COPYDATA, | |||
| (WPARAM) juce_messageWindowHandle, | |||
| (LPARAM) &data, | |||
| SMTO_BLOCK | SMTO_ABORTIFHUNG, | |||
| 8000, | |||
| &result); | |||
| SMTO_BLOCK | SMTO_ABORTIFHUNG, 8000, &result); | |||
| } | |||
| } | |||
| } | |||
| @@ -348,8 +348,14 @@ public: | |||
| Pimpl (String name, const int timeOutMillisecs) | |||
| : handle (0), refCount (1) | |||
| { | |||
| name = "Local\\" + name.replaceCharacter ('\\', '/'); | |||
| handle = CreateMutexW (0, TRUE, name.toUTF16().getAddress()); | |||
| name = name.replaceCharacter ('\\', '/'); | |||
| handle = CreateMutexW (0, TRUE, ("Global\\" + name).toUTF16().getAddress()); | |||
| // Not 100% sure why a global mutex sometimes can't be allocated, but if it fails, fall back to | |||
| // a local one. (A local one also sometimes fails on other machines so neither type appears to be | |||
| // universally reliable) | |||
| if (handle == 0) | |||
| handle = CreateMutexW (0, TRUE, ("Local\\" + name).toUTF16().getAddress()); | |||
| if (handle != 0 && GetLastError() == ERROR_ALREADY_EXISTS) | |||
| { | |||
| @@ -35,7 +35,6 @@ | |||
| #endif | |||
| #include <cctype> | |||
| #include <ctime> | |||
| BEGIN_JUCE_NAMESPACE | |||
| @@ -71,6 +70,10 @@ bool CharacterFunctions::isLowerCase (const juce_wchar character) throw() | |||
| #endif | |||
| } | |||
| #if JUCE_MSVC | |||
| #pragma warning (pop) | |||
| #endif | |||
| //============================================================================== | |||
| bool CharacterFunctions::isWhitespace (const char character) throw() | |||
| { | |||
| @@ -132,10 +135,6 @@ int CharacterFunctions::getHexDigitValue (const juce_wchar digit) throw() | |||
| return -1; | |||
| } | |||
| #if JUCE_MSVC | |||
| #pragma warning (pop) | |||
| #endif | |||
| double CharacterFunctions::mulexp10 (const double value, int exponent) throw() | |||
| { | |||
| if (exponent == 0) | |||
| @@ -38,6 +38,8 @@ BEGIN_JUCE_NAMESPACE | |||
| #include "../memory/juce_Atomic.h" | |||
| #include "../io/streams/juce_OutputStream.h" | |||
| NewLine newLine; | |||
| #if defined (JUCE_STRINGS_ARE_UNICODE) && ! JUCE_STRINGS_ARE_UNICODE | |||
| #error "JUCE_STRINGS_ARE_UNICODE is deprecated! All strings are now unicode by default." | |||
| #endif | |||
| @@ -50,7 +52,10 @@ BEGIN_JUCE_NAMESPACE | |||
| typedef CharPointer_UTF32 CharPointer_wchar_t; | |||
| #endif | |||
| NewLine newLine; | |||
| static inline CharPointer_wchar_t castToCharPointer_wchar_t (const void* t) throw() | |||
| { | |||
| return CharPointer_wchar_t (static_cast <const CharPointer_wchar_t::CharType*> (t)); | |||
| } | |||
| //============================================================================== | |||
| class StringHolder | |||
| @@ -216,20 +221,6 @@ StringHolder StringHolder::empty; | |||
| const String String::empty; | |||
| //============================================================================== | |||
| void String::appendFixedLength (const char* const newText, const int numExtraChars) | |||
| { | |||
| if (numExtraChars > 0) | |||
| { | |||
| const size_t byteOffsetOfNull = getByteOffsetOfEnd(); | |||
| const size_t newBytesNeeded = sizeof (CharPointerType::CharType) + byteOffsetOfNull + sizeof (CharPointerType::CharType) * numExtraChars; | |||
| text = StringHolder::makeUniqueWithByteSize (text, newBytesNeeded); | |||
| CharPointerType newEnd (addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull)); | |||
| newEnd.writeWithCharLimit (CharPointer_ASCII (newText), numExtraChars); | |||
| } | |||
| } | |||
| void String::preallocateBytes (const size_t numBytesNeeded) | |||
| { | |||
| text = StringHolder::makeUniqueWithByteSize (text, numBytesNeeded + sizeof (CharPointerType::CharType)); | |||
| @@ -271,14 +262,6 @@ String::String (const PreallocationBytes& preallocationSize) | |||
| { | |||
| } | |||
| /*String::String (const String& stringToCopy, const size_t bytesToAllocate) | |||
| : text (0) | |||
| { | |||
| const size_t otherSize = StringHolder::getAllocatedNumBytes (stringToCopy.text); | |||
| text = StringHolder::createUninitialised (jmax (bytesToAllocate, otherSize)); | |||
| StringHolder::copyChars (text, stringToCopy.text, otherSize); | |||
| }*/ | |||
| String::String (const char* const t) | |||
| : text (StringHolder::createFromCharPointer (CharPointer_ASCII (t))) | |||
| { | |||
| @@ -317,16 +300,6 @@ String::String (const char* const t, const size_t maxChars) | |||
| jassert (t == 0 || CharPointer_ASCII::isValidString (t, (int) maxChars)); | |||
| } | |||
| String::String (const juce_wchar* const t) | |||
| : text (StringHolder::createFromCharPointer (CharPointer_UTF32 (t))) | |||
| { | |||
| } | |||
| String::String (const juce_wchar* const t, const size_t maxChars) | |||
| : text (StringHolder::createFromCharPointer (CharPointer_UTF32 (t), maxChars)) | |||
| { | |||
| } | |||
| String::String (const CharPointer_UTF8& t) | |||
| : text (StringHolder::createFromCharPointer (t)) | |||
| { | |||
| @@ -377,19 +350,15 @@ String::String (const CharPointer_ASCII& t) | |||
| { | |||
| } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| String::String (const wchar_t* const t) | |||
| : text (StringHolder::createFromCharPointer | |||
| (CharPointer_wchar_t (reinterpret_cast <const CharPointer_wchar_t::CharType*> (t)))) | |||
| : text (StringHolder::createFromCharPointer (castToCharPointer_wchar_t (t))) | |||
| { | |||
| } | |||
| String::String (const wchar_t* const t, size_t maxChars) | |||
| : text (StringHolder::createFromCharPointer | |||
| (CharPointer_wchar_t (reinterpret_cast <const CharPointer_wchar_t::CharType*> (t)), maxChars)) | |||
| : text (StringHolder::createFromCharPointer (castToCharPointer_wchar_t (t), maxChars)) | |||
| { | |||
| } | |||
| #endif | |||
| const String String::charToString (const juce_wchar character) | |||
| { | |||
| @@ -624,7 +593,7 @@ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const char* strin | |||
| return string1.compare (string2) == 0; | |||
| } | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const juce_wchar* string2) throw() | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const wchar_t* string2) throw() | |||
| { | |||
| return string1.compare (string2) == 0; | |||
| } | |||
| @@ -654,7 +623,7 @@ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const char* strin | |||
| return string1.compare (string2) != 0; | |||
| } | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const juce_wchar* string2) throw() | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const wchar_t* string2) throw() | |||
| { | |||
| return string1.compare (string2) != 0; | |||
| } | |||
| @@ -694,13 +663,13 @@ JUCE_API bool JUCE_CALLTYPE operator<= (const String& string1, const String& str | |||
| return string1.compare (string2) <= 0; | |||
| } | |||
| bool String::equalsIgnoreCase (const juce_wchar* t) const throw() | |||
| bool String::equalsIgnoreCase (const wchar_t* const t) const throw() | |||
| { | |||
| return t != 0 ? text.compareIgnoreCase (CharPointer_UTF32 (t)) == 0 | |||
| return t != 0 ? text.compareIgnoreCase (castToCharPointer_wchar_t (t)) == 0 | |||
| : isEmpty(); | |||
| } | |||
| bool String::equalsIgnoreCase (const char* t) const throw() | |||
| bool String::equalsIgnoreCase (const char* const t) const throw() | |||
| { | |||
| return t != 0 ? text.compareIgnoreCase (CharPointer_UTF8 (t)) == 0 | |||
| : isEmpty(); | |||
| @@ -717,14 +686,14 @@ int String::compare (const String& other) const throw() | |||
| return (text == other.text) ? 0 : text.compare (other.text); | |||
| } | |||
| int String::compare (const char* other) const throw() | |||
| int String::compare (const char* const other) const throw() | |||
| { | |||
| return text.compare (CharPointer_UTF8 (other)); | |||
| } | |||
| int String::compare (const juce_wchar* other) const throw() | |||
| int String::compare (const wchar_t* const other) const throw() | |||
| { | |||
| return text.compare (CharPointer_UTF32 (other)); | |||
| return text.compare (castToCharPointer_wchar_t (other)); | |||
| } | |||
| int String::compareIgnoreCase (const String& other) const throw() | |||
| @@ -753,9 +722,30 @@ void String::append (const String& textToAppend, size_t maxCharsToTake) | |||
| appendCharPointer (textToAppend.text, maxCharsToTake); | |||
| } | |||
| String& String::operator+= (const juce_wchar* const t) | |||
| String& String::operator+= (const wchar_t* const t) | |||
| { | |||
| appendCharPointer (CharPointer_UTF32 (t)); | |||
| appendCharPointer (castToCharPointer_wchar_t (t)); | |||
| return *this; | |||
| } | |||
| String& String::operator+= (const char* const t) | |||
| { | |||
| /* If you get an assertion here, then you're trying to create a string from 8-bit data | |||
| that contains values greater than 127. These can NOT be correctly converted to unicode | |||
| because there's no way for the String class to know what encoding was used to | |||
| create them. The source data could be UTF-8, ASCII or one of many local code-pages. | |||
| To get around this problem, you must be more explicit when you pass an ambiguous 8-bit | |||
| string to the String class - so for example if your source data is actually UTF-8, | |||
| you'd call String (CharPointer_UTF8 ("my utf8 string..")), and it would be able to | |||
| correctly convert the multi-byte characters to unicode. It's *highly* recommended that | |||
| you use UTF-8 with escape characters in your source code to represent extended characters, | |||
| because there's no other way to represent these strings in a way that isn't dependent on | |||
| the compiler, source code editor and platform. | |||
| */ | |||
| jassert (t == 0 || CharPointer_ASCII::isValidString (t, std::numeric_limits<int>::max())); | |||
| appendCharPointer (CharPointer_ASCII (t)); | |||
| return *this; | |||
| } | |||
| @@ -770,24 +760,22 @@ String& String::operator+= (const String& other) | |||
| String& String::operator+= (const char ch) | |||
| { | |||
| return operator+= ((juce_wchar) ch); | |||
| } | |||
| String& String::operator+= (const juce_wchar ch) | |||
| { | |||
| const juce_wchar asString[] = { ch, 0 }; | |||
| return operator+= (static_cast <const juce_wchar*> (asString)); | |||
| const char asString[] = { ch, 0 }; | |||
| return operator+= (asString); | |||
| } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| String& String::operator+= (const wchar_t ch) | |||
| { | |||
| return operator+= ((juce_wchar) ch); | |||
| const wchar_t asString[] = { ch, 0 }; | |||
| return operator+= (asString); | |||
| } | |||
| String& String::operator+= (const wchar_t* t) | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| String& String::operator+= (const juce_wchar ch) | |||
| { | |||
| return operator+= (String (t)); | |||
| const juce_wchar asString[] = { ch, 0 }; | |||
| appendCharPointer (CharPointer_UTF32 (asString)); | |||
| return *this; | |||
| } | |||
| #endif | |||
| @@ -796,7 +784,21 @@ String& String::operator+= (const int number) | |||
| char buffer [16]; | |||
| char* const end = buffer + numElementsInArray (buffer); | |||
| char* const start = NumberToStringConverters::numberToString (end, number); | |||
| appendFixedLength (start, (int) (end - start)); | |||
| const int numExtraChars = (int) (end - start); | |||
| if (numExtraChars > 0) | |||
| { | |||
| const size_t byteOffsetOfNull = getByteOffsetOfEnd(); | |||
| const size_t newBytesNeeded = sizeof (CharPointerType::CharType) + byteOffsetOfNull | |||
| + sizeof (CharPointerType::CharType) * numExtraChars; | |||
| text = StringHolder::makeUniqueWithByteSize (text, newBytesNeeded); | |||
| CharPointerType newEnd (addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull)); | |||
| newEnd.writeWithCharLimit (CharPointer_ASCII (start), numExtraChars); | |||
| } | |||
| return *this; | |||
| } | |||
| @@ -807,7 +809,7 @@ JUCE_API const String JUCE_CALLTYPE operator+ (const char* const string1, const | |||
| return s += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const juce_wchar* const string1, const String& string2) | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const wchar_t* const string1, const String& string2) | |||
| { | |||
| String s (string1); | |||
| return s += string2; | |||
| @@ -818,104 +820,43 @@ JUCE_API const String JUCE_CALLTYPE operator+ (const char string1, const String& | |||
| return String::charToString (string1) + string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const juce_wchar string1, const String& string2) | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const wchar_t string1, const String& string2) | |||
| { | |||
| return String::charToString (string1) + string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const String& string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const char* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const char string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, wchar_t string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const wchar_t* string2) | |||
| { | |||
| string1.appendCharPointer (CharPointer_wchar_t (reinterpret_cast <const CharPointer_wchar_t::CharType*> (string2))); | |||
| return string1; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const wchar_t* string1, const String& string2) | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const juce_wchar string1, const String& string2) | |||
| { | |||
| String s (string1); | |||
| return s += string2; | |||
| return String::charToString (string1) + string2; | |||
| } | |||
| #endif | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const char characterToAppend) | |||
| { | |||
| return string1 += characterToAppend; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar characterToAppend) | |||
| { | |||
| return string1 += characterToAppend; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const char* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar* const string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const String& string2) | |||
| { | |||
| return string1 += string2; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const short number) | |||
| { | |||
| return string1 += (int) number; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const String& s2) { return s1 += s2; } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const char* const s2) { return s1 += s2; } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const wchar_t* s2) { return s1 += s2; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const int number) | |||
| { | |||
| return string1 += number; | |||
| } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const char s2) { return s1 += s2; } | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const wchar_t s2) { return s1 += s2; } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String s1, const juce_wchar s2) { return s1 += s2; } | |||
| #endif | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const long number) | |||
| { | |||
| return string1 += (int) number; | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const char s2) { return s1 += s2; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const wchar_t s2) { return s1 += s2; } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const juce_wchar s2) { return s1 += s2; } | |||
| #endif | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const float number) | |||
| { | |||
| return string1 += String (number); | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const char* const s2) { return s1 += s2; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const wchar_t* const s2) { return s1 += s2; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const String& s2) { return s1 += s2; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const double number) | |||
| { | |||
| return string1 += String (number); | |||
| } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const short number) { return s1 += (int) number; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const int number) { return s1 += number; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const long number) { return s1 += (int) number; } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const float number) { return s1 += String (number); } | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const double number) { return s1 += String (number); } | |||
| JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const String& text) | |||
| { | |||
| @@ -1948,10 +1889,8 @@ bool String::containsNonWhitespaceChars() const throw() | |||
| return false; | |||
| } | |||
| const String String::formatted (const juce_wchar* const pf, ... ) | |||
| const String String::formatted (const String& pf, ... ) | |||
| { | |||
| jassert (pf != 0); | |||
| va_list args; | |||
| va_start (args, pf); | |||
| @@ -1963,17 +1902,17 @@ const String String::formatted (const juce_wchar* const pf, ... ) | |||
| HeapBlock <wchar_t> temp (bufferSize); | |||
| va_list tempArgs; | |||
| va_copy (tempArgs, args); | |||
| const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf, tempArgs); | |||
| const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toUTF32(), tempArgs); | |||
| va_end (tempArgs); | |||
| #elif JUCE_WINDOWS | |||
| HeapBlock <wchar_t> temp (bufferSize); | |||
| const int num = (int) _vsnwprintf (temp.getData(), bufferSize - 1, String (pf).toUTF16(), args); | |||
| const int num = (int) _vsnwprintf (temp.getData(), bufferSize - 1, pf.toUTF16(), args); | |||
| #elif JUCE_ANDROID | |||
| HeapBlock <char> temp (bufferSize); | |||
| const int num = (int) vsnprintf (temp.getData(), bufferSize - 1, String (pf).toUTF8(), args); | |||
| const int num = (int) vsnprintf (temp.getData(), bufferSize - 1, pf.toUTF8(), args); | |||
| #else | |||
| HeapBlock <wchar_t> temp (bufferSize); | |||
| const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf, args); | |||
| const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toUTF32(), args); | |||
| #endif | |||
| if (num > 0) | |||
| @@ -2039,14 +1978,14 @@ struct HexConverter | |||
| { | |||
| static const String hexToString (Type v) | |||
| { | |||
| juce_wchar buffer[32]; | |||
| juce_wchar* const end = buffer + 32; | |||
| juce_wchar* t = end; | |||
| char buffer[32]; | |||
| char* const end = buffer + 32; | |||
| char* t = end; | |||
| *--t = 0; | |||
| do | |||
| { | |||
| *--t = (juce_wchar) hexDigits [(int) (v & 15)]; | |||
| *--t = hexDigits [(int) (v & 15)]; | |||
| v >>= 4; | |||
| } while (v != 0); | |||
| @@ -2379,7 +2318,7 @@ public: | |||
| buffer[i] = (juce_wchar) (1 + Random::getSystemRandom().nextInt (0xff)); | |||
| } | |||
| return buffer; | |||
| return CharPointer_UTF32 (buffer); | |||
| } | |||
| void runTest() | |||
| @@ -104,23 +104,15 @@ public: | |||
| */ | |||
| String (const char* text, size_t maxChars); | |||
| /** Creates a string from a zero-terminated unicode text string. */ | |||
| String (const juce_wchar* unicodeText); | |||
| /** Creates a string from a unicode text string. | |||
| This will use up the the first maxChars characters of the string (or | |||
| less if the string is actually shorter) | |||
| /** Creates a string from a whcar_t character string. | |||
| Depending on the platform, this may be treated as either UTF-32 or UTF-16. | |||
| */ | |||
| String (const juce_wchar* unicodeText, size_t maxChars); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Creates a string from a UTF-16 character string */ | |||
| String (const wchar_t* text); | |||
| /** Creates a string from a UTF-16 character string */ | |||
| /** Creates a string from a whcar_t character string. | |||
| Depending on the platform, this may be treated as either UTF-32 or UTF-16. | |||
| */ | |||
| String (const wchar_t* text, size_t maxChars); | |||
| #endif | |||
| //============================================================================== | |||
| /** Creates a string from a UTF-8 character string */ | |||
| @@ -209,22 +201,22 @@ public: | |||
| /** Replaces this string's contents with another string. */ | |||
| String& operator= (const String& other) throw(); | |||
| /** Appends another string at the end of this one. */ | |||
| String& operator+= (const juce_wchar* textToAppend); | |||
| /** Appends another string at the end of this one. */ | |||
| String& operator+= (const String& stringToAppend); | |||
| /** Appends another string at the end of this one. */ | |||
| String& operator+= (const char* textToAppend); | |||
| /** Appends another string at the end of this one. */ | |||
| String& operator+= (const wchar_t* textToAppend); | |||
| /** Appends a decimal number at the end of this string. */ | |||
| String& operator+= (int numberToAppend); | |||
| /** Appends a character at the end of this string. */ | |||
| String& operator+= (char characterToAppend); | |||
| /** Appends a character at the end of this string. */ | |||
| String& operator+= (juce_wchar characterToAppend); | |||
| String& operator+= (wchar_t characterToAppend); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Appends a character at the end of this string. */ | |||
| String& operator+= (wchar_t characterToAppend); | |||
| /** Appends another string at the end of this one. */ | |||
| String& operator+= (const wchar_t* textToAppend); | |||
| String& operator+= (juce_wchar characterToAppend); | |||
| #endif | |||
| /** Appends a decimal number at the end of this string. */ | |||
| String& operator+= (int numberToAppend); | |||
| /** Appends a string to the end of this one. | |||
| @@ -310,7 +302,7 @@ public: | |||
| bool equalsIgnoreCase (const String& other) const throw(); | |||
| /** Case-insensitive comparison with another string. */ | |||
| bool equalsIgnoreCase (const juce_wchar* other) const throw(); | |||
| bool equalsIgnoreCase (const wchar_t* other) const throw(); | |||
| /** Case-insensitive comparison with another string. */ | |||
| bool equalsIgnoreCase (const char* other) const throw(); | |||
| @@ -334,7 +326,7 @@ public: | |||
| comes before the other one alphabetically, or positive if it | |||
| comes after it. | |||
| */ | |||
| int compare (const juce_wchar* other) const throw(); | |||
| int compare (const wchar_t* other) const throw(); | |||
| /** Case-insensitive comparison with another string. | |||
| @returns 0 if the two strings are identical; negative if this string | |||
| @@ -894,7 +886,7 @@ public: | |||
| If you're really determined to use it, at least make sure that you never, ever, | |||
| pass any String objects to it as parameters. | |||
| */ | |||
| static const String formatted (const juce_wchar* formatString, ... ); | |||
| static const String formatted (const String& formatString, ... ); | |||
| //============================================================================== | |||
| // Numeric conversions.. | |||
| @@ -1207,12 +1199,10 @@ private: | |||
| size_t numBytes; | |||
| }; | |||
| // This constructor preallocates a certain amount of memory | |||
| explicit String (const PreallocationBytes&); | |||
| JUCE_DEPRECATED (String (const String& stringToCopy, size_t charsToAllocate)); | |||
| explicit String (const PreallocationBytes&); // This constructor preallocates a certain amount of memory | |||
| void appendFixedLength (const char* text, int numExtraChars); | |||
| size_t getByteOffsetOfEnd() const throw(); | |||
| JUCE_DEPRECATED (String (const String& stringToCopy, size_t charsToAllocate)); | |||
| // This private cast operator should prevent strings being accidentally cast | |||
| // to bools (this is possible because the compiler can add an implicit cast | |||
| @@ -1222,42 +1212,47 @@ private: | |||
| //============================================================================== | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const char* string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const char* string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const juce_wchar* string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const wchar_t* string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (char string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (char string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (juce_wchar string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (wchar_t string1, const String& string2); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (juce_wchar string1, const String& string2); | |||
| #endif | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const String& string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const char* string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const char* string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const juce_wchar* string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const wchar_t* string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, char characterToAppend); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, char characterToAppend); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, juce_wchar characterToAppend); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, wchar_t characterToAppend); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, wchar_t characterToAppend); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, const wchar_t* string2); | |||
| /** Concatenates two strings. */ | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (const wchar_t* string1, const String& string2); | |||
| JUCE_API const String JUCE_CALLTYPE operator+ (String string1, juce_wchar characterToAppend); | |||
| #endif | |||
| //============================================================================== | |||
| /** Appends a character at the end of a string. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, char characterToAppend); | |||
| /** Appends a character at the end of a string. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, wchar_t characterToAppend); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Appends a character at the end of a string. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, juce_wchar characterToAppend); | |||
| #endif | |||
| /** Appends a string to the end of the first one. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const char* string2); | |||
| /** Appends a string to the end of the first one. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const juce_wchar* string2); | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const wchar_t* string2); | |||
| /** Appends a string to the end of the first one. */ | |||
| JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const String& string2); | |||
| @@ -1278,7 +1273,7 @@ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const String& str | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const char* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const juce_wchar* string2) throw(); | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const wchar_t* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, const CharPointer_UTF8& string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| @@ -1290,7 +1285,7 @@ JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const String& str | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const char* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const juce_wchar* string2) throw(); | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const wchar_t* string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, const CharPointer_UTF8& string2) throw(); | |||
| /** Case-sensitive comparison of two strings. */ | |||
| @@ -73,17 +73,6 @@ StringArray::StringArray (const char* const* const initialStrings, const int num | |||
| StringArrayHelpers::addArray (strings, initialStrings, numberOfStrings); | |||
| } | |||
| StringArray::StringArray (const juce_wchar* const* const initialStrings) | |||
| { | |||
| StringArrayHelpers::addArray (strings, initialStrings); | |||
| } | |||
| StringArray::StringArray (const juce_wchar* const* const initialStrings, const int numberOfStrings) | |||
| { | |||
| StringArrayHelpers::addArray (strings, initialStrings, numberOfStrings); | |||
| } | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| StringArray::StringArray (const wchar_t* const* const initialStrings) | |||
| { | |||
| StringArrayHelpers::addArray (strings, initialStrings); | |||
| @@ -93,7 +82,6 @@ StringArray::StringArray (const wchar_t* const* const initialStrings, const int | |||
| { | |||
| StringArrayHelpers::addArray (strings, initialStrings, numberOfStrings); | |||
| } | |||
| #endif | |||
| StringArray& StringArray::operator= (const StringArray& other) | |||
| { | |||
| @@ -63,20 +63,6 @@ public: | |||
| */ | |||
| explicit StringArray (const char* const* strings); | |||
| /** Creates a copy of a null-terminated array of string literals. | |||
| Each item from the array passed-in is added, until it encounters a null pointer, | |||
| at which point it stops. | |||
| */ | |||
| explicit StringArray (const juce_wchar* const* strings); | |||
| /** Creates a copy of an array of string literals. | |||
| @param strings an array of strings to add. Null pointers in the array will be | |||
| treated as empty strings | |||
| @param numberOfStrings how many items there are in the array | |||
| */ | |||
| StringArray (const juce_wchar* const* strings, int numberOfStrings); | |||
| #if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
| /** Creates a copy of a null-terminated array of string literals. | |||
| Each item from the array passed-in is added, until it encounters a null pointer, | |||
| at which point it stops. | |||
| @@ -89,7 +75,6 @@ public: | |||
| @param numberOfStrings how many items there are in the array | |||
| */ | |||
| StringArray (const wchar_t* const* strings, int numberOfStrings); | |||
| #endif | |||
| /** Destructor. */ | |||
| ~StringArray(); | |||
| @@ -97,7 +97,7 @@ const String::CharPointerType StringPool::getPooledString (const char* const s) | |||
| return StringPoolHelpers::getPooledStringFromArray (strings, s); | |||
| } | |||
| const String::CharPointerType StringPool::getPooledString (const juce_wchar* const s) | |||
| const String::CharPointerType StringPool::getPooledString (const wchar_t* const s) | |||
| { | |||
| if (s == 0 || *s == 0) | |||
| return String::empty.getCharPointer(); | |||
| @@ -74,7 +74,7 @@ public: | |||
| The pool will own all the pointers that it returns, deleting them when the pool itself | |||
| is deleted. | |||
| */ | |||
| const String::CharPointerType getPooledString (const juce_wchar* original); | |||
| const String::CharPointerType getPooledString (const wchar_t* original); | |||
| //============================================================================== | |||
| /** Returns the number of strings in the pool. */ | |||