annotate lib/libavutil/dict.h @ 2556:91c75d202d30

Shooting bow sound & stats word wrap (bugfix submitted by default8p)
author a.parshin
date Thu, 14 May 2015 11:03:14 +0200
parents 992d2e6f907d
children
rev   line source
2134
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
1 /*
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
2 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
3 * This file is part of FFmpeg.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
4 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
5 * FFmpeg is free software; you can redistribute it and/or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
9 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
10 * FFmpeg is distributed in the hope that it will be useful,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
13 * Lesser General Public License for more details.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
14 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
16 * License along with FFmpeg; if not, write to the Free Software
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
18 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
19
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
20 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
21 * @file
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
22 * Public dictionary API.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
23 * @deprecated
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
24 * AVDictionary is provided for compatibility with libav. It is both in
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
25 * implementation as well as API inefficient. It does not scale and is
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
26 * extremely slow with large dictionaries.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
27 * It is recommended that new code uses our tree container from tree.c/h
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
28 * where applicable, which uses AVL trees to achieve O(log n) performance.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
29 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
30
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
31 #ifndef AVUTIL_DICT_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
32 #define AVUTIL_DICT_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
33
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
34 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
35 * @addtogroup lavu_dict AVDictionary
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
36 * @ingroup lavu_data
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
37 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
38 * @brief Simple key:value store
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
39 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
40 * @{
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
41 * Dictionaries are used for storing key:value pairs. To create
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
42 * an AVDictionary, simply pass an address of a NULL pointer to
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
43 * av_dict_set(). NULL can be used as an empty dictionary wherever
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
44 * a pointer to an AVDictionary is required.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
45 * Use av_dict_get() to retrieve an entry or iterate over all
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
46 * entries and finally av_dict_free() to free the dictionary
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
47 * and all its contents.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
48 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
49 * @code
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
50 * AVDictionary *d = NULL; // "create" an empty dictionary
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
51 * av_dict_set(&d, "foo", "bar", 0); // add an entry
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
52 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
53 * char *k = av_strdup("key"); // if your strings are already allocated,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
54 * char *v = av_strdup("value"); // you can avoid copying them like this
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
55 * av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
56 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
57 * AVDictionaryEntry *t = NULL;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
58 * while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
59 * <....> // iterate over all entries in d
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
60 * }
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
61 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
62 * av_dict_free(&d);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
63 * @endcode
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
64 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
65 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
66
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
67 #define AV_DICT_MATCH_CASE 1
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
68 #define AV_DICT_IGNORE_SUFFIX 2
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
69 #define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
70 allocated with av_malloc() and children. */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
71 #define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
72 allocated with av_malloc() and chilren. */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
73 #define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
74 #define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
75 delimiter is added, the strings are simply concatenated. */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
76
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
77 typedef struct AVDictionaryEntry {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
78 char *key;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
79 char *value;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
80 } AVDictionaryEntry;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
81
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
82 typedef struct AVDictionary AVDictionary;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
83
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
84 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
85 * Get a dictionary entry with matching key.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
86 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
87 * @param prev Set to the previous matching element to find the next.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
88 * If set to NULL the first matching element is returned.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
89 * @param flags Allows case as well as suffix-insensitive comparisons.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
90 * @return Found entry or NULL, changing key or value leads to undefined behavior.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
91 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
92 AVDictionaryEntry *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
93 av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
94
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
95 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
96 * Get number of entries in dictionary.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
97 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
98 * @param m dictionary
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
99 * @return number of entries in dictionary
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
100 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
101 int av_dict_count(const AVDictionary *m);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
102
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
103 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
104 * Set the given entry in *pm, overwriting an existing entry.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
105 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
106 * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
107 * a dictionary struct is allocated and put in *pm.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
108 * @param key entry key to add to *pm (will be av_strduped depending on flags)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
109 * @param value entry value to add to *pm (will be av_strduped depending on flags).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
110 * Passing a NULL value will cause an existing entry to be deleted.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
111 * @return >= 0 on success otherwise an error code <0
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
112 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
113 int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
114
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
115 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
116 * Parse the key/value pairs list and add to a dictionary.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
117 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
118 * @param key_val_sep a 0-terminated list of characters used to separate
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
119 * key from value
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
120 * @param pairs_sep a 0-terminated list of characters used to separate
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
121 * two pairs from each other
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
122 * @param flags flags to use when adding to dictionary.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
123 * AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
124 * are ignored since the key/value tokens will always
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
125 * be duplicated.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
126 * @return 0 on success, negative AVERROR code on failure
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
127 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
128 int av_dict_parse_string(AVDictionary **pm, const char *str,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
129 const char *key_val_sep, const char *pairs_sep,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
130 int flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
131
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
132 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
133 * Copy entries from one AVDictionary struct into another.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
134 * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
135 * this function will allocate a struct for you and put it in *dst
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
136 * @param src pointer to source AVDictionary struct
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
137 * @param flags flags to use when setting entries in *dst
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
138 * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
139 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
140 void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
141
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
142 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
143 * Free all the memory allocated for an AVDictionary struct
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
144 * and all keys and values.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
145 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
146 void av_dict_free(AVDictionary **m);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
147
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
148 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
149 * @}
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
150 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
151
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
152 #endif /* AVUTIL_DICT_H */