Browse Source

water: add back String::quoted()

tags/1.9.8
falkTX 7 years ago
parent
commit
7a51444ff3
2 changed files with 29 additions and 3 deletions
  1. +16
    -0
      source/modules/water/text/String.cpp
  2. +13
    -3
      source/modules/water/text/String.h

+ 16
- 0
source/modules/water/text/String.cpp View File

@@ -1523,6 +1523,22 @@ String String::unquoted() const
return substring (dropAtStart, len - dropAtEnd);
}
String String::quoted (water_uchar quoteCharacter) const
{
if (isEmpty())
return charToString (quoteCharacter) + quoteCharacter;
String t (*this);
if (! t.startsWithChar (quoteCharacter))
t = charToString (quoteCharacter) + t;
if (! t.endsWithChar (quoteCharacter))
t += quoteCharacter;
return t;
}
//==============================================================================
static String::CharPointerType findTrimmedEnd (const String::CharPointerType start,
String::CharPointerType end)


+ 13
- 3
source/modules/water/text/String.h View File

@@ -780,6 +780,16 @@ public:
*/
String unquoted() const;
/** Adds quotation marks around a string.
This will return a copy of the string with a quote at the start and end, (but won't
add the quote if there's already one there, so it's safe to call this on strings that
may already have quotes around them).
Note that this is a const method, and won't alter the string itself.
@param quoteCharacter the character to add at the start and end
@see isQuotedString, unquoted
*/
String quoted (water_uchar quoteCharacter = '"') const;
//==============================================================================
/** Creates a string which is a version of a string repeated and joined together.
@@ -1102,11 +1112,11 @@ private:
//==============================================================================
/** Concatenates two strings. */
String operator+ (const char* string1, const String& string2);
String operator+ (const char* string1, const String& string2);
/** Concatenates two strings. */
String operator+ (char string1, const String& string2);
String operator+ (char string1, const String& string2);
/** Concatenates two strings. */
String operator+ (water_uchar string1, const String& string2);
String operator+ (water_uchar string1, const String& string2);
/** Concatenates two strings. */
String operator+ (String string1, const String& string2);


Loading…
Cancel
Save