Browse Source

Fix for builds with JUCE_STRING_UTF_TYPE = 32

tags/2021-05-28
jules 9 years ago
parent
commit
145a80f11f
5 changed files with 32 additions and 8 deletions
  1. +2
    -2
      modules/juce_core/native/juce_linux_CommonFile.cpp
  2. +4
    -3
      modules/juce_core/text/juce_NewLine.h
  3. +18
    -0
      modules/juce_core/text/juce_String.cpp
  4. +7
    -0
      modules/juce_core/text/juce_String.h
  5. +1
    -3
      modules/juce_core/text/juce_StringRef.h

+ 2
- 2
modules/juce_core/native/juce_linux_CommonFile.cpp View File

@@ -58,10 +58,10 @@ bool File::isHidden() const
return getFileName().startsWithChar ('.');
}
static String getLinkedFile (StringRef file)
static String getLinkedFile (const String& file)
{
HeapBlock<char> buffer (8194);
const int numBytes = (int) readlink (file.text, buffer, 8192);
const int numBytes = (int) readlink (file.toRawUTF8(), buffer, 8192);
return String::fromUTF8 (buffer, jmax (0, numBytes));
};


+ 4
- 3
modules/juce_core/text/juce_NewLine.h View File

@@ -78,9 +78,10 @@ extern NewLine newLine;
@endcode
*/
JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const NewLine&);
JUCE_API String JUCE_CALLTYPE operator+ (const NewLine&, const NewLine&);
inline String operator+ (String s1, const NewLine&) { return s1 += NewLine::getDefault(); }
inline String& operator+= (String& s1, const NewLine&) { return s1 += NewLine::getDefault(); }
#if JUCE_STRING_UTF_TYPE != 8 && ! defined (DOXYGEN)
inline String operator+ (String s1, const NewLine&) { return s1 += NewLine::getDefault(); }
#endif
#endif // JUCE_NEWLINE_H_INCLUDED

+ 18
- 0
modules/juce_core/text/juce_String.cpp View File

@@ -365,6 +365,7 @@ String::String (const CharPointer_UTF16 start, const CharPointer_UTF16 end) : t
String::String (const CharPointer_UTF32 start, const CharPointer_UTF32 end) : text (StringHolder::createFromCharPointer (start, end)) {}
String::String (const std::string& s) : text (StringHolder::createFromFixedLength (s.data(), s.size())) {}
String::String (StringRef s) : text (StringHolder::createFromCharPointer (s.text)) {}
String String::charToString (const juce_wchar character)
{
@@ -768,6 +769,11 @@ String& String::operator+= (const String& other)
return *this;
}
String& String::operator+= (StringRef other)
{
return operator+= (String (other));
}
String& String::operator+= (const char ch)
{
const char asString[] = { ch, 0 };
@@ -843,6 +849,7 @@ JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const wchar_t s2)
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& s1, StringRef s2) { return s1 += s2; }
JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const int number) { return s1 += number; }
JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const short number) { return s1 += (int) number; }
@@ -879,6 +886,11 @@ JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const NewLine&)
return string1 += NewLine::getDefault();
}
JUCE_API String JUCE_CALLTYPE operator+ (const NewLine&, const NewLine&)
{
return String (NewLine::getDefault()) + NewLine::getDefault();
}
//==============================================================================
int String::indexOfChar (const juce_wchar character) const noexcept
{
@@ -2308,6 +2320,10 @@ public:
expect (String ("abcdEFGH").toLowerCase() == String ("abcdefgh"));
expect (String ("abcdEFGH").toUpperCase() == String ("ABCDEFGH"));
expect (String (StringRef ("abc")) == "abc");
expect (String (StringRef ("abc")) == StringRef ("abc"));
expect (String ("abc") + StringRef ("def") == "abcdef");
String s2 ("123");
s2 << ((int) 4) << ((short) 5) << "678" << L"9" << '0';
s2 += "xyz";
@@ -2316,6 +2332,8 @@ public:
expect (s2 == "1234567890xyz123");
s2 += (int64) 123;
expect (s2 == "1234567890xyz123123");
s2 << StringRef ("def");
expect (s2 == "1234567890xyz123123def");
beginTest ("Numeric conversions");
expect (String::empty.getIntValue() == 0);


+ 7
- 0
modules/juce_core/text/juce_String.h View File

@@ -136,6 +136,9 @@ public:
/** Creates a string from a UTF-8 encoded std::string. */
String (const std::string&);
/** Creates a string from a StringRef */
String (StringRef);
//==============================================================================
/** Creates a string from a single character. */
static String charToString (juce_wchar character);
@@ -202,6 +205,8 @@ public:
String& operator+= (const char* textToAppend);
/** Appends another string at the end of this one. */
String& operator+= (const wchar_t* textToAppend);
/** Appends another string at the end of this one. */
String& operator+= (StringRef textToAppend);
/** Appends a decimal number at the end of this string. */
String& operator+= (int numberToAppend);
/** Appends a decimal number at the end of this string. */
@@ -1289,6 +1294,8 @@ JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, const char* 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);
/** Appends a string to the end of the first one. */
JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, StringRef string2);
/** Appends a decimal number at the end of a string. */
JUCE_API String& JUCE_CALLTYPE operator<< (String& string1, short number);


+ 1
- 3
modules/juce_core/text/juce_StringRef.h View File

@@ -131,8 +131,6 @@ JUCE_API bool JUCE_CALLTYPE operator== (const String& string1, StringRef string2
/** Case-sensitive comparison of two strings. */
JUCE_API bool JUCE_CALLTYPE operator!= (const String& string1, StringRef string2) noexcept;
#if JUCE_STRING_UTF_TYPE != 8 && ! defined (DOXYGEN)
inline String operator+ (String s1, StringRef s2) { return s1 += String (s2.text); }
#endif
inline String operator+ (String s1, StringRef s2) { return s1 += String (s2.text); }
#endif // JUCE_STRINGREF_H_INCLUDED

Loading…
Cancel
Save