| @@ -561,10 +561,8 @@ void ComponentTypeHandler::fillInCreationCode (GeneratedCode& code, Component* c | |||||
| s << "());\n"; | s << "());\n"; | ||||
| else | else | ||||
| { | { | ||||
| StringArray lines; | |||||
| lines.addLines (params); | |||||
| params = lines.joinIntoString ("\n" + String::repeatedString (" ", s.length() + 2)); | |||||
| params = StringArray::fromLines (params) | |||||
| .joinIntoString ("\n" + String::repeatedString (" ", s.length() + 2)); | |||||
| s << " (" << params << "));\n"; | s << " (" << params << "));\n"; | ||||
| } | } | ||||
| @@ -258,8 +258,7 @@ private: | |||||
| if (responseHeader.isNotEmpty()) | if (responseHeader.isNotEmpty()) | ||||
| { | { | ||||
| headerLines.clear(); | |||||
| headerLines.addLines (responseHeader); | |||||
| headerLines = StringArray::fromLines (responseHeader); | |||||
| const int statusCode = responseHeader.fromFirstOccurrenceOf (" ", false, false) | const int statusCode = responseHeader.fromFirstOccurrenceOf (" ", false, false) | ||||
| .substring (0, 3).getIntValue(); | .substring (0, 3).getIntValue(); | ||||
| @@ -1077,9 +1077,7 @@ private: | |||||
| bool ChildProcess::start (const String& command) | bool ChildProcess::start (const String& command) | ||||
| { | { | ||||
| StringArray tokens; | |||||
| tokens.addTokens (command, true); | |||||
| return start (tokens); | |||||
| return start (StringArray::fromTokens (command, true)); | |||||
| } | } | ||||
| bool ChildProcess::start (const StringArray& args) | bool ChildProcess::start (const StringArray& args) | ||||
| @@ -418,6 +418,30 @@ int StringArray::addLines (const String& sourceText) | |||||
| return numLines; | return numLines; | ||||
| } | } | ||||
| StringArray StringArray::fromTokens (const String& stringToTokenise, | |||||
| bool preserveQuotedStrings) | |||||
| { | |||||
| StringArray s; | |||||
| s.addTokens (stringToTokenise, preserveQuotedStrings); | |||||
| return s; | |||||
| } | |||||
| StringArray StringArray::fromTokens (const String& stringToTokenise, | |||||
| const String& breakCharacters, | |||||
| const String& quoteCharacters) | |||||
| { | |||||
| StringArray s; | |||||
| s.addTokens (stringToTokenise, breakCharacters, quoteCharacters); | |||||
| return s; | |||||
| } | |||||
| StringArray StringArray::fromLines (const String& stringToBreakUp) | |||||
| { | |||||
| StringArray s; | |||||
| s.addLines (stringToBreakUp); | |||||
| return s; | |||||
| } | |||||
| //============================================================================== | //============================================================================== | ||||
| void StringArray::removeDuplicates (const bool ignoreCase) | void StringArray::removeDuplicates (const bool ignoreCase) | ||||
| { | { | ||||
| @@ -211,8 +211,8 @@ public: | |||||
| This will tokenise the given string using whitespace characters as the | This will tokenise the given string using whitespace characters as the | ||||
| token delimiters, and will add these tokens to the end of the array. | token delimiters, and will add these tokens to the end of the array. | ||||
| @returns the number of tokens added | @returns the number of tokens added | ||||
| @see fromTokens | |||||
| */ | */ | ||||
| int addTokens (const String& stringToTokenise, | int addTokens (const String& stringToTokenise, | ||||
| bool preserveQuotedStrings); | bool preserveQuotedStrings); | ||||
| @@ -229,6 +229,7 @@ public: | |||||
| which are treated as quotes. Any text occurring | which are treated as quotes. Any text occurring | ||||
| between quotes is not broken up into tokens. | between quotes is not broken up into tokens. | ||||
| @returns the number of tokens added | @returns the number of tokens added | ||||
| @see fromTokens | |||||
| */ | */ | ||||
| int addTokens (const String& stringToTokenise, | int addTokens (const String& stringToTokenise, | ||||
| const String& breakCharacters, | const String& breakCharacters, | ||||
| @@ -242,6 +243,40 @@ public: | |||||
| */ | */ | ||||
| int addLines (const String& stringToBreakUp); | int addLines (const String& stringToBreakUp); | ||||
| /** Returns an array containing the tokens in a given string. | |||||
| This will tokenise the given string using whitespace characters as the | |||||
| token delimiters, and return these tokens as an array. | |||||
| @see addTokens | |||||
| */ | |||||
| static StringArray fromTokens (const String& stringToTokenise, | |||||
| bool preserveQuotedStrings); | |||||
| /** Returns an array containing the tokens in a given string. | |||||
| This will tokenise the given string using whitespace characters as the | |||||
| token delimiters, and return these tokens as an array. | |||||
| @param stringToTokenise the string to tokenise | |||||
| @param breakCharacters a string of characters, any of which will be considered | |||||
| to be a token delimiter. | |||||
| @param quoteCharacters if this string isn't empty, it defines a set of characters | |||||
| which are treated as quotes. Any text occurring | |||||
| between quotes is not broken up into tokens. | |||||
| @see addTokens | |||||
| */ | |||||
| static StringArray fromTokens (const String& stringToTokenise, | |||||
| const String& breakCharacters, | |||||
| const String& quoteCharacters); | |||||
| /** Returns an array containing the lines in a given string. | |||||
| This breaks a string down into lines separated by \\n or \\r\\n, and returns an | |||||
| array containing these lines. Line-break characters are omitted from the strings that | |||||
| are added to the array. | |||||
| */ | |||||
| static StringArray fromLines (const String& stringToBreakUp); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** Removes all elements from the array. */ | /** Removes all elements from the array. */ | ||||
| void clear(); | void clear(); | ||||
| @@ -584,9 +584,8 @@ void CodeDocument::replaceSection (const int start, const int end, const String& | |||||
| void CodeDocument::applyChanges (const String& newContent) | void CodeDocument::applyChanges (const String& newContent) | ||||
| { | { | ||||
| StringArray correctedLines; | |||||
| correctedLines.addLines (newContent); | |||||
| const String corrected (correctedLines.joinIntoString (newLineChars)); | |||||
| const String corrected (StringArray::fromLines (newContent) | |||||
| .joinIntoString (newLineChars)); | |||||
| TextDiff diff (getAllContent(), corrected); | TextDiff diff (getAllContent(), corrected); | ||||