StringArray - populate array from comma divided string


hey jules,
ive been using this method alot, and i guess it might be helpfull to others if it were implemented in StringArray

addCommaSeparatedStrings(String stringsToAdd) { String singleString; while (stringsToAdd.isNotEmpty()) { singleString = stringsToAdd.upToFirstOccurrenceOf(T(","), false, false).trim(); if (singleString.isNotEmpty()) { add(singleString); } stringsToAdd= stringsToAdd.fromFirstOccurrenceOf(T(","),false, false); } }

or better yet:

addSeparatedStrings(String stringsToAdd, const tchar* const dividingChar) { String singleString; while (stringsToAdd.isNotEmpty()) { singleString = stringsToAdd.upToFirstOccurrenceOf(dividingChar, false, false).trim(); if (singleString.isNotEmpty()) { add(singleString); } stringsToAdd= stringsToAdd.fromFirstOccurrenceOf(dividingChar,false, false); } }


int StringArray::addTokens (const tchar *const stringToTokenise, const tchar * breakCharacters, const tchar * quoteCharacters) throw ()
Breaks up a string into tokens and adds them to this array.

This will tokenise the given string (using the string passed in to define the token delimiters), and will add these tokens to the end of the array.

[]stringToTokenise the string to tokenise[/]
[]breakCharacters a string of characters, any of which will be considered to be a token delimiter.[/]
[]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.[/][/list]
[]the number of tokens added[/][/list]