diff options
author | Rodeo <[email protected]> | 2012-03-28 22:56:52 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2012-03-28 22:56:52 +0000 |
commit | a9d238763d17fafb04f96deed93b798310303f7d (patch) | |
tree | 2234177e90b0ab69b36bb21da74830f1979603cf /libhb/hb_dict.h | |
parent | 719b77cfe9b5280c8bbc492bc0a2ca341ccfbf03 (diff) |
libhb: add basic dictionary implementation.
Note: under OS X, this commit may require a full rebuild to work properly.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4550 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/hb_dict.h')
-rw-r--r-- | libhb/hb_dict.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libhb/hb_dict.h b/libhb/hb_dict.h new file mode 100644 index 000000000..b8ca4c562 --- /dev/null +++ b/libhb/hb_dict.h @@ -0,0 +1,43 @@ +/* This file is part of the HandBrake source code. + Homepage: <http://handbrake.fr/>. + It may be used under the terms of the GNU General Public License. */ + +typedef struct hb_dict_entry_s hb_dict_entry_t; +typedef struct hb_dict_s hb_dict_t; + +/* Basic dictionary implementation. + * + * an hb_dict_t must be initialized with hb_dict_init() before use. + * + * "key" must be a string with non-zero length (NULL and "" are invalid keys). + * "value" can be NULL (the zero-length string "" is mapped to NULL). + * + * hb_dict_next( dict, NULL ) returns the first key in the dictionary. + * hb_dict_next( dict, previous ) returns key directly following previous, or + * NULL if the end of the dictionary was reached. + * + * hb_encopts_to_dict() converts an op1=val1:opt2=val2:opt3=val3 type string to + * an hb_dict_t dictionary. */ + +hb_dict_t * hb_dict_init( int alloc ); +void hb_dict_free( hb_dict_t ** dict_ptr ); + +void hb_dict_set( hb_dict_t ** dict_ptr, const char * key, const char * value ); + +hb_dict_entry_t * hb_dict_get( hb_dict_t * dict, const char * key ); +hb_dict_entry_t * hb_dict_next( hb_dict_t * dict, hb_dict_entry_t * previous ); + +hb_dict_t * hb_encopts_to_dict( const char * encopts ); + +struct hb_dict_entry_s +{ + char * key; + char * value; +}; + +struct hb_dict_s +{ + int alloc; + int count; + hb_dict_entry_t * objects; +}; |