X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavutil%2Fdict.h;h=e4aee27ca3b1f32472fe74b52a9d65f7fdfc9d49;hb=f929ab0569ff31ed5a59b0b0adb7ce09df3fca39;hp=492da9a41c31f65ebc54d2bcc4dd0dfb5812d2a1;hpb=e4cbf7529ba4bcfff47c44b0d026ecb356004c8c;p=ffmpeg diff --git a/libavutil/dict.h b/libavutil/dict.h index 492da9a41c3..e4aee27ca3b 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -40,21 +40,21 @@ * entries and finally av_dict_free() to free the dictionary * and all its contents. * - * @code - * AVDictionary *d = NULL; // "create" an empty dictionary - * av_dict_set(&d, "foo", "bar", 0); // add an entry - * - * char *k = av_strdup("key"); // if your strings are already allocated, - * char *v = av_strdup("value"); // you can avoid copying them like this - * av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); - * - * AVDictionaryEntry *t = NULL; - * while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { - * <....> // iterate over all entries in d - * } - * - * av_dict_free(&d); - * @endcode + @code + AVDictionary *d = NULL; // "create" an empty dictionary + AVDictionaryEntry *t = NULL; + + av_dict_set(&d, "foo", "bar", 0); // add an entry + + char *k = av_strdup("key"); // if your strings are already allocated, + char *v = av_strdup("value"); // you can avoid copying them like this + av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); + + while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { + <....> // iterate over all entries in d + } + av_dict_free(&d); + @endcode * */ @@ -83,8 +83,8 @@ typedef struct AVDictionary AVDictionary; * @param flags Allows case as well as suffix-insensitive comparisons. * @return Found entry or NULL, changing key or value leads to undefined behavior. */ -AVDictionaryEntry * -av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); +AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, + const AVDictionaryEntry *prev, int flags); /** * Get number of entries in dictionary. @@ -106,6 +106,23 @@ int av_dict_count(const AVDictionary *m); */ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags); +/** + * Parse the key/value pairs list and add to a dictionary. + * + * @param key_val_sep a 0-terminated list of characters used to separate + * key from value + * @param pairs_sep a 0-terminated list of characters used to separate + * two pairs from each other + * @param flags flags to use when adding to dictionary. + * AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL + * are ignored since the key/value tokens will always + * be duplicated. + * @return 0 on success, negative AVERROR code on failure + */ +int av_dict_parse_string(AVDictionary **pm, const char *str, + const char *key_val_sep, const char *pairs_sep, + int flags); + /** * Copy entries from one AVDictionary struct into another. * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL, @@ -114,7 +131,7 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags * @param flags flags to use when setting entries in *dst * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag */ -void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags); +void av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags); /** * Free all the memory allocated for an AVDictionary struct