carb::dictionary::saveFileFromDictionary

Defined in carb/dictionary/DictionaryUtils.h

inline void carb::dictionary::saveFileFromDictionary(ISerializer *serializer, const dictionary::Item *dictionary, const char *filename, SerializerOptions serializerOptions)

Writes the contents of a dictionary to a file.

Remark

This formats the contents of a dictionary to a string and writes it to a file. The file will be formatted according to the serializer interface that is used. The extra flag options passed to the serializer in serializerOptions control the specifics of the formatting. The formatted data will be written to the file as long as it can be opened successfully for writing.

Thread Safety

This operation itself is thread safe. However, if another thread is attempting to modify the dictionary dictionary at the same time, a race condition may exist and undefined behavior could occur. It won’t crash but the written data may be unexpected.

Parameters
  • serializer[in] The ISerializer interface to use to format the dictionary data before writing it to file. This may not be nullptr.

  • dictionary[in] The dictionary root item to format and write to file. This not be nullptr. This must have been created by the same IDictionary interface that serializer uses internally.

  • filename[in] The name of the file to write the formatted dictionary data to. This file will be unconditionally overwritten. It is the caller’s responsibility to ensure any previous file at this location can be safely overwritten. This must not be nullptr.

  • serializerOptions[in] Option flags passed to the serializer interface when formatting the dictionary data.

Returns

No return value.