carb::dictionary::setDictionaryArrayElementFromStringValue

Defined in carb/dictionary/DictionaryUtils.h

inline void carb::dictionary::setDictionaryArrayElementFromStringValue(dictionary::IDictionary *dictionaryInterface, dictionary::Item *targetDictionary, const std::string &elementPath, const std::string &elementValue)

Parses a string representation of an array and sets it relative to a dictionary path.

Remark

This parses an array of values from a string into a dictionary array item. The array string is expected to have the format “[<value1>, <value2>, <value3>, …]”. Quoted values are not respected if they contain internal commas (the comma is still seen as a value separator in this case). Each value parsed from the array will be set in the dictionary item with its data type detected from its content. This detection is done in the same manner as in setDictionaryElementAutoType().

Thread Safety

This call itself is thread safe. However, if another thread is simultaneously attempting to modify, retrieve, or delete items or values in the same branch of the dictionary, the results may be undefined.

Parameters
  • dictionaryInterface[in] The IDictionary interface to use to access the items in the dictionary. This must not be nullptr. This must be the same interface that was originally used to create the dictionary targetDictionary.

  • targetDictionary[in] The base item to act as the root of where to set the values relative to. This may not be nullptr.

  • elementPath[in] The path to the item to set the values in. This path does not need to exist yet in the dictionary. This may be an empty string to create the new values in the dict item itself. Any item at this path will be completely overwritten by this operation.

  • elementValue[in] The string containing the values to parse for the new array value. These are expected to be expressed in the format “[<value1>, <value2>, <value3>, …]” (ie: all values enclosed in a single set of square brackets with each individual value separated by commas). Individual value strings may not contain a comma (even if escaped or surrounded by quotation marks) otherwise they will be seen as separate values and likely not set appropriately in the dictionary. This must not be an empty string and must contain at least the square brackets at either end of the string.

Returns

No return value.