From 3d3eec675e8b3e0a16e2128e47503bb9f2103556 Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 31 Oct 2015 14:57:33 +0000 Subject: [PATCH] Added a couple of extra StringRef and NewLine concatenation operators --- modules/juce_core/text/juce_NewLine.h | 9 +++++---- modules/juce_core/text/juce_String.cpp | 10 ---------- modules/juce_core/text/juce_StringRef.h | 6 +++++- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/juce_core/text/juce_NewLine.h b/modules/juce_core/text/juce_NewLine.h index d056470432..ec2d17a214 100644 --- a/modules/juce_core/text/juce_NewLine.h +++ b/modules/juce_core/text/juce_NewLine.h @@ -77,11 +77,12 @@ extern NewLine newLine; myString << "Hello World" << 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& string1, const NewLine&) { return string1 += NewLine::getDefault(); } +inline String& operator+= (String& s1, const NewLine&) { return s1 += NewLine::getDefault(); } -inline String operator+ (String s1, const NewLine&) { return s1 += NewLine::getDefault(); } -inline String& operator+= (String& s1, const NewLine&) { return s1 += NewLine::getDefault(); } +inline String operator+ (const NewLine&, const NewLine&) { return String (NewLine::getDefault()) + NewLine::getDefault(); } +inline String operator+ (String s1, const NewLine&) { return s1 += NewLine::getDefault(); } +inline String operator+ (const NewLine&, const char* s2) { return String (NewLine::getDefault()) + s2; } #endif // JUCE_NEWLINE_H_INCLUDED diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index d0ecaae33b..26bf4d107a 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -881,16 +881,6 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, StringRef return stream; } -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 { diff --git a/modules/juce_core/text/juce_StringRef.h b/modules/juce_core/text/juce_StringRef.h index bd0e142324..0c70d99ad1 100644 --- a/modules/juce_core/text/juce_StringRef.h +++ b/modules/juce_core/text/juce_StringRef.h @@ -131,6 +131,10 @@ 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; -inline String operator+ (String s1, StringRef s2) { return s1 += String (s2.text); } +inline String operator+ (String s1, StringRef s2) { return s1 += String (s2.text); } +inline String operator+ (StringRef s1, const String& s2) { return String (s1.text) + s2; } +inline String operator+ (const char* s1, StringRef s2) { return String (s1) + String (s2.text); } +inline String operator+ (StringRef s1, const char* s2) { return String (s1.text) + String (s2); } + #endif // JUCE_STRINGREF_H_INCLUDED