1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
|
Data Settings API Reference (obs_data_t)
========================================
Data settings objects are reference-counted objects that store values in
a string-table or array. They're similar to Json objects, but
additionally allow additional functionality such as default or
auto-selection values. Data is saved/loaded to/from Json text and Json
text files.
.. type:: obs_data_t
A reference-counted data object.
.. type:: obs_data_array_t
A reference-counted data array object.
.. code:: cpp
#include <obs.h>
General Functions
-----------------
.. function:: obs_data_t *obs_data_create()
:return: A new reference to a data object. Release with
:c:func:`obs_data_release()`.
---------------------
.. function:: obs_data_t *obs_data_create_from_json(const char *json_string)
Creates a data object from a Json string.
:param json_string: Json string
:return: A new reference to a data object. Release with
:c:func:`obs_data_release()`.
---------------------
.. function:: obs_data_t *obs_data_create_from_json_file(const char *json_file)
Creates a data object from a Json file.
:param json_file: Json file path
:return: A new reference to a data object. Release with
:c:func:`obs_data_release()`.
---------------------
.. function:: obs_data_t *obs_data_create_from_json_file_safe(const char *json_file, const char *backup_ext)
Creates a data object from a Json file, with a backup file in case
the original is corrupted or fails to load.
:param json_file: Json file path
:param backup_ext: Backup file extension
:return: A new reference to a data object. Release with
:c:func:`obs_data_release()`.
---------------------
.. function:: void obs_data_addref(obs_data_t *data)
void obs_data_release(obs_data_t *data)
Adds/releases a reference to a data object.
---------------------
.. function:: const char *obs_data_get_json(obs_data_t *data)
Generates a new json string. The string allocation is stored within
the data object itself, and does not need to be manually freed.
:return: Json string for this object
---------------------
.. function:: const char *obs_data_get_last_json(obs_data_t *data)
Returns the last json string generated for this data object. Does not
generate a new string. Use :c:func:`obs_data_get_json()` to generate
a json string first.
:return: Json string for this object
---------------------
.. function:: bool obs_data_save_json(obs_data_t *data, const char *file)
Saves the data to a file as Json text.
:param file: The file to save to
:return: *true* if successful, *false* otherwise
---------------------
.. function:: bool obs_data_save_json_safe(obs_data_t *data, const char *file, const char *temp_ext, const char *backup_ext)
Saves the data to a file as Json text, and if overwriting an old
file, backs up that old file to help prevent potential file
corruption.
:param file: The file to save to
:param backup_ext: The backup extension to use for the overwritten
file if it exists
:return: *true* if successful, *false* otherwise
---------------------
.. function:: void obs_data_apply(obs_data_t *target, obs_data_t *apply_data)
Merges the data of *apply_data* in to *target*.
---------------------
.. function:: void obs_data_erase(obs_data_t *data, const char *name)
Erases the user data for item *name* within the data object.
---------------------
.. function:: void obs_data_clear(obs_data_t *data)
Clears all user data in the data object.
---------------------
Set Functions
-------------
.. function:: void obs_data_set_string(obs_data_t *data, const char *name, const char *val)
---------------------
.. function:: void obs_data_set_int(obs_data_t *data, const char *name, long long val)
---------------------
.. function:: void obs_data_set_double(obs_data_t *data, const char *name, double val)
---------------------
.. function:: void obs_data_set_bool(obs_data_t *data, const char *name, bool val)
---------------------
.. function:: void obs_data_set_obj(obs_data_t *data, const char *name, obs_data_t *obj)
---------------------
.. function:: void obs_data_set_array(obs_data_t *data, const char *name, obs_data_array_t *array)
---------------------
.. _obs_data_get_funcs:
Get Functions
-------------
.. function:: const char *obs_data_get_string(obs_data_t *data, const char *name)
---------------------
.. function:: long long obs_data_get_int(obs_data_t *data, const char *name)
---------------------
.. function:: double obs_data_get_double(obs_data_t *data, const char *name)
---------------------
.. function:: bool obs_data_get_bool(obs_data_t *data, const char *name)
---------------------
.. function:: obs_data_t *obs_data_get_obj(obs_data_t *data, const char *name)
:return: An incremented reference to a data object. Release with
:c:func:`obs_data_release()`.
---------------------
.. function:: obs_data_array_t *obs_data_get_array(obs_data_t *data, const char *name)
:return: An incremented reference to a data array object. Release
with :c:func:`obs_data_array_release()`.
---------------------
.. _obs_data_default_funcs:
Default Value Functions
-----------------------
Default values are used to determine what value will be given if a value
is not set.
.. function:: obs_data_t *obs_data_get_defaults(obs_data_t *data);
:return: obs_data_t * with all default values (recursively for all objects as well).
-----------------------
.. function:: void obs_data_set_default_string(obs_data_t *data, const char *name, const char *val)
const char *obs_data_get_default_string(obs_data_t *data, const char *name)
---------------------
.. function:: void obs_data_set_default_int(obs_data_t *data, const char *name, long long val)
long long obs_data_get_default_int(obs_data_t *data, const char *name)
---------------------
.. function:: void obs_data_set_default_double(obs_data_t *data, const char *name, double val)
double obs_data_get_default_double(obs_data_t *data, const char *name)
---------------------
.. function:: void obs_data_set_default_bool(obs_data_t *data, const char *name, bool val)
bool obs_data_get_default_bool(obs_data_t *data, const char *name)
---------------------
.. function:: void obs_data_set_default_obj(obs_data_t *data, const char *name, obs_data_t *obj)
obs_data_t *obs_data_get_default_obj(obs_data_t *data, const char *name)
:return: An incremented reference to a data object. Release with
:c:func:`obs_data_release()`.
----------------------
.. function:: void obs_data_set_default_array(obs_data_t *data, const char *name, obs_data_array_t *arr)
obs_data_array_t *obs_data_get_default_array(obs_data_t *data, const char *name)
Autoselect Functions
--------------------
Autoselect values are optionally used to determine what values should be
used to ensure functionality if the currently set values are
inappropriate or invalid.
.. function:: void obs_data_set_autoselect_string(obs_data_t *data, const char *name, const char *val)
const char *obs_data_get_autoselect_string(obs_data_t *data, const char *name)
---------------------
.. function:: void obs_data_set_autoselect_int(obs_data_t *data, const char *name, long long val)
long long obs_data_get_autoselect_int(obs_data_t *data, const char *name)
---------------------
.. function:: void obs_data_set_autoselect_double(obs_data_t *data, const char *name, double val)
double obs_data_get_autoselect_double(obs_data_t *data, const char *name)
---------------------
.. function:: void obs_data_set_autoselect_bool(obs_data_t *data, const char *name, bool val)
bool obs_data_get_autoselect_bool(obs_data_t *data, const char *name)
---------------------
.. function:: void obs_data_set_autoselect_obj(obs_data_t *data, const char *name, obs_data_t *obj)
obs_data_t *obs_data_get_autoselect_obj(obs_data_t *data, const char *name)
:return: An incremented reference to a data object. Release with
:c:func:`obs_data_release()`.
---------------------
Array Functions
---------------
.. function:: obs_data_array_t *obs_data_array_create()
:return: A new reference to a data array object. Release
with :c:func:`obs_data_array_release()`.
---------------------
.. function:: void obs_data_array_addref(obs_data_array_t *array)
---------------------
.. function:: void obs_data_array_release(obs_data_array_t *array)
---------------------
.. function:: size_t obs_data_array_count(obs_data_array_t *array)
---------------------
.. function:: obs_data_t *obs_data_array_item(obs_data_array_t *array, size_t idx)
:return: An incremented reference to the data object associated with
this array entry. Release with :c:func:`obs_data_release()`.
---------------------
.. function:: size_t obs_data_array_push_back(obs_data_array_t *array, obs_data_t *obj)
---------------------
.. function:: void obs_data_array_insert(obs_data_array_t *array, size_t idx, obs_data_t *obj)
---------------------
.. function:: void obs_data_array_erase(obs_data_array_t *array, size_t idx)
|