1 /* 2 * values.h 3 * Copyright (C) John Stebbins 2008-2021 <stebbins@stebbins> 4 * 5 * values.h is free software. 6 * 7 * You may redistribute it and/or modify it under the terms of the 8 * GNU General Public License version 2, as published by the Free Software 9 * Foundation. 10 * 11 * values.h is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 * See the GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with callbacks.h. If not, write to: 18 * The Free Software Foundation, Inc., 19 * 51 Franklin Street, Fifth Floor 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #if !defined(_GHB_VALUES_H_) 24 #define _GHB_VALUES_H_ 25 26 #include <glib.h> 27 #include <glib-object.h> 28 #include "handbrake/hb_dict.h" 29 30 #define GHB_DICT HB_VALUE_TYPE_DICT 31 #define GHB_ARRAY HB_VALUE_TYPE_ARRAY 32 #define GHB_STRING HB_VALUE_TYPE_STRING 33 #define GHB_INT HB_VALUE_TYPE_INT 34 #define GHB_DOUBLE HB_VALUE_TYPE_DOUBLE 35 #define GHB_NULL HB_VALUE_TYPE_NULL 36 #define GHB_BOOL HB_VALUE_TYPE_BOOL 37 38 typedef hb_value_t GhbValue; 39 typedef hb_value_type_t GhbType; 40 typedef hb_dict_iter_t GhbDictIter; 41 42 #define ghb_dict_new hb_dict_init 43 #define ghb_dict_get hb_dict_get 44 #define ghb_dict_set hb_dict_set 45 #define ghb_dict_remove hb_dict_remove 46 #define ghb_dict_iter_init hb_dict_iter_init 47 #define ghb_dict_iter_next hb_dict_iter_next_ex 48 49 #define ghb_value_incref hb_value_incref 50 #define ghb_value_decref hb_value_decref 51 #define ghb_value_free hb_value_free 52 #define ghb_value_type hb_value_type 53 #define ghb_value_dup hb_value_dup 54 55 #define ghb_array_new hb_value_array_init 56 #define ghb_array_get hb_value_array_get 57 #define ghb_array_insert hb_value_array_insert 58 #define ghb_array_append hb_value_array_append 59 #define ghb_array_remove hb_value_array_remove 60 #define ghb_array_replace hb_value_array_set 61 #define ghb_array_len hb_value_array_len 62 #define ghb_array_copy hb_value_array_copy 63 #define ghb_array_reset hb_value_array_clear 64 65 #define ghb_value_get_int hb_value_get_int 66 #define ghb_value_get_double hb_value_get_double 67 #define ghb_value_get_bool hb_value_get_bool 68 #define ghb_value_get_string hb_value_get_string 69 #define ghb_value_get_string_xform hb_value_get_string_xform 70 71 #define ghb_value_xform hb_value_xform 72 73 #define ghb_string_value_new hb_value_string 74 #define ghb_int_value_new hb_value_int 75 #define ghb_double_value_new hb_value_double 76 #define ghb_bool_value_new hb_value_bool 77 78 #define ghb_json_write(file,val) hb_value_write_file_json(val,file) 79 #define ghb_json_write_file(path,val) hb_value_write_json(val,path) 80 #define ghb_json_parse hb_value_json 81 #define ghb_json_parse_file hb_value_read_json 82 83 gint ghb_value_cmp(const GhbValue *vala, const GhbValue *valb); 84 void ghb_string_value_set(GhbValue *gval, const gchar *str); 85 86 GhbValue* ghb_string_value(const gchar *str); 87 GhbValue* ghb_int_value(gint64 ival); 88 GhbValue* ghb_double_value(gdouble dval); 89 GhbValue* ghb_boolean_value(gboolean bval); 90 91 void debug_show_value(GhbValue *gval); 92 void debug_show_type(GhbType tp); 93 94 void ghb_dict_copy(GhbValue *dst, const GhbValue *src); 95 96 void ghb_dict_set_string(GhbValue *dict, const gchar *key, const gchar *sval); 97 void ghb_dict_set_double(GhbValue *dict, const gchar *key, gdouble dval); 98 void ghb_dict_set_int(GhbValue *dict, const gchar *key, gint64 ival); 99 void ghb_dict_set_bool(GhbValue *dict, const gchar *key, gboolean bval); 100 101 GhbValue* ghb_dict_get_value(const GhbValue *dict, const gchar *key); 102 gboolean ghb_dict_get_bool(const GhbValue *dict, const gchar *key); 103 gint64 ghb_dict_get_int(const GhbValue *dict, const gchar *key); 104 gdouble ghb_dict_get_double(const GhbValue *dict, const gchar *key); 105 gchar* ghb_dict_get_string_xform(const GhbValue *dict, const gchar *key); 106 const gchar* ghb_dict_get_string(const GhbValue *dict, const gchar *key); 107 108 #endif // _GHB_VALUES_H_ 109