summaryrefslogtreecommitdiffstats
path: root/libhb/hb_dict.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2015-04-03 17:43:13 +0000
committerjstebbins <[email protected]>2015-04-03 17:43:13 +0000
commit5efc8273df8372d36819391a1700314bd052ce2c (patch)
tree71d09b609234f496ae630b9b17376188bdd13c8c /libhb/hb_dict.c
parentde17b2d007026cac6bc1aa7821126094e3c5e142 (diff)
hb_dict: add 'const' to a few prototypes and add a couple new helper funcs
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7045 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/hb_dict.c')
-rw-r--r--libhb/hb_dict.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/libhb/hb_dict.c b/libhb/hb_dict.c
index c3c17e380..7fd12b565 100644
--- a/libhb/hb_dict.c
+++ b/libhb/hb_dict.c
@@ -7,6 +7,7 @@
For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
*/
+#include <stdio.h>
#include "hb.h"
#include "hb_dict.h"
@@ -20,7 +21,7 @@ hb_value_type_t hb_value_type(const hb_value_t *value)
return type;
}
-hb_value_t * hb_value_dup(hb_value_t *value)
+hb_value_t * hb_value_dup(const hb_value_t *value)
{
if (value == NULL) return NULL;
return json_deep_copy(value);
@@ -420,6 +421,11 @@ char * hb_value_get_json(hb_value_t *value)
return json_dumps(value, JSON_INDENT(4) | JSON_SORT_KEYS);
}
+int hb_value_write_file_json(hb_value_t *value, FILE *file)
+{
+ return json_dumpf(value, file, JSON_INDENT(4) | JSON_SORT_KEYS);
+}
+
int hb_value_write_json(hb_value_t *value, const char *path)
{
return json_dump_file(value, path, JSON_INDENT(4) | JSON_SORT_KEYS);
@@ -445,7 +451,7 @@ int hb_dict_remove(hb_dict_t * dict, const char * key)
return json_object_del(dict, key) == 0;
}
-hb_value_t * hb_dict_get(hb_dict_t * dict, const char * key)
+hb_value_t * hb_dict_get(const hb_dict_t * dict, const char * key)
{
return json_object_get(dict, key);
}
@@ -472,6 +478,20 @@ hb_value_t * hb_dict_iter_value(const hb_dict_iter_t iter)
return json_object_iter_value(iter);
}
+int
+hb_dict_iter_next_ex(hb_dict_t *dict, hb_dict_iter_t *iter,
+ const char **key, hb_value_t **val)
+{
+ if (*iter == NULL)
+ return 0;
+ if (key != NULL)
+ *key = json_object_iter_key(*iter);
+ if (val != NULL)
+ *val = json_object_iter_value(*iter);
+ *iter = json_object_iter_next(dict, *iter);
+ return 1;
+}
+
hb_value_array_t*
hb_value_array_init()
{