carb::dictionary::dumpToString

Defined in carb/dictionary/DictionaryUtils.h

inline std::string carb::dictionary::dumpToString(const dictionary::Item *c, const char *serializerName = nullptr)

Writes a dictionary to a string.

Thread Safety

This operation itself is thread safe. However, if the dictionary c is being modified concurrently by another thread, the output contents may be unexpected.

Parameters
  • c[in] The dictionary to be serialized. This must not be nullptr. This dictionary must have been created by the same dictionary interface that the serializer will use. The serializer that is used controls how the string is formatted.

  • serializerName[in] The name of the serializer plugin to use. This must be the name of the serializer plugin to be potentially loaded and used. For example, “carb.dictionary.serializer-json.plugin” to serialize to use the JSON serializer. The serializer plugin must already be known to the framework. This may be nullptr to pick the first or best serializer plugin instead. If the serializer plugin with this name cannot be found or the ISerializer interface cannot be acquired from it, the first loaded serializer interface will be acquired and used instead.

Returns

A string containing the human readable contents of the dictionary c. If the dictionary failed to be written, an empty string will be returned but the operation will still be considered successful. The dictionary will always be formatted using the fSerializerOptionMakePretty flag so that it is as human-readable as possible.