Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1814605
  • 博文数量: 274
  • 博客积分: 2366
  • 博客等级: 大尉
  • 技术积分: 1880
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-22 09:37
文章分类

全部博文(274)

文章存档

2022年(1)

2020年(10)

2019年(7)

2018年(18)

2017年(26)

2016年(32)

2015年(43)

2014年(30)

2013年(44)

2012年(36)

2011年(17)

2010年(10)

分类: 其他平台

2014-07-29 15:15:11

struct AVDictionary av字典


#define AV_DICT_MATCH_CASE      1
#define AV_DICT_IGNORE_SUFFIX   2
#define AV_DICT_DONT_STRDUP_KEY 4   /**< Take ownership of a key that's been
                                         allocated with av_malloc() and children. */
#define AV_DICT_DONT_STRDUP_VAL 8   /**< Take ownership of a value that's been
                                         allocated with av_malloc() and chilren. */
#define AV_DICT_DONT_OVERWRITE 16   ///< Don't overwrite existing entries.
#define AV_DICT_APPEND         32   /**< If the entry already exists, append to it.  Note that no
                                      delimiter is added, the strings are simply concatenated. */


typedef struct {
    char *key;
    char *value;
} AVDictionaryEntry;


struct AVDictionary {
    int count;
    AVDictionaryEntry *elems;
};


从字面上看这是一个键值对, 更宏观一些则为键值对数组, 嗯, 动态数组
这就能构建我们通常所说的字典?
这个数据结构有4个操作, 读(查找)/写(创建)/拷贝, 释放


里面有几个操作标志, 记录下
AV_DICT_MATCH_CASE     查找时是否比较大小, 不比较大小则全部转化为大写来比较
AV_DICT_IGNORE_SUFFIX  查找时是否忽略后缀, 这里的后缀指字典里key 超过查找key 部分
                       如果设置了改参数则, 查找"abc", 可能会找到"abcde" 这样的key
AV_DICT_DONT_STRDUP_KEY 设置key时, 是否把key 字符串复制一份
AV_DICT_DONT_STRDUP_VAL 设置value时, 是否把value 字符串复制一份
AV_DICT_DONT_OVERWRITE  写入时不要覆盖原来存在的key(存在key 则不设置), 否则把原来的key/value 释放重建
AV_DICT_APPEND   如果已经存在key/value, 把将新的value 值连到旧的后面 
阅读(4516) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~