src/cx/json.h

changeset 1594
4b9537f93239
parent 1591
ef2f47fc5f0c
equal deleted inserted replaced
1593:0df5128ab675 1594:4b9537f93239
294 struct cx_json_s { 294 struct cx_json_s {
295 /** 295 /**
296 * The allocator used for produced JSON values. 296 * The allocator used for produced JSON values.
297 */ 297 */
298 const CxAllocator *allocator; 298 const CxAllocator *allocator;
299
299 /** 300 /**
300 * The input buffer. 301 * The input buffer.
301 */ 302 */
302 CxBuffer buffer; 303 CxBuffer buffer;
303 304
1374 * @retval zero the values are equal (except for ordering of object members) 1375 * @retval zero the values are equal (except for ordering of object members)
1375 * @retval non-zero the values differ 1376 * @retval non-zero the values differ
1376 */ 1377 */
1377 CX_EXPORT int cxJsonCompare(const CxJsonValue *json, const CxJsonValue *other); 1378 CX_EXPORT int cxJsonCompare(const CxJsonValue *json, const CxJsonValue *other);
1378 1379
1380
1381 /**
1382 * Creates a deep copy of the specified JSON value.
1383 *
1384 * If you need a @c cx_clone_func compatible version, see cxJsonCloneFunc().
1385 *
1386 * @note when you are cloning @c NULL, you will get a pointer to a statically
1387 * allocated value which represents nothing.
1388 *
1389 * @param value the value to be cloned
1390 * @param allocator the allocator for the new value
1391 * @return the new value or @c NULL if any allocation was unsuccessful
1392 * @see cxJsonCloneFunc()
1393 */
1394 cx_attr_nodiscard
1395 CX_EXPORT CxJsonValue* cxJsonClone(const CxJsonValue* value,
1396 const CxAllocator* allocator);
1397
1398
1399 /**
1400 * A @c cx_clone_func compatible version of cxJsonClone().
1401 *
1402 * Internal function - use cxJsonCloneFunc() to get a properly casted function pointer.
1403 *
1404 * @param target the target memory or @c NULL
1405 * @param source the value to be cloned
1406 * @param allocator the allocator for the new value
1407 * @param data unused
1408 * @return the new value or @c NULL if any allocation was unsuccessful
1409 * @see cxJsonClone()
1410 */
1411 cx_attr_nodiscard
1412 CX_EXPORT CxJsonValue* cx_json_clone_func(
1413 CxJsonValue* target, const CxJsonValue* source,
1414 const CxAllocator* allocator, void *data);
1415
1416 /**
1417 * A @c cx_clone_func compatible version of cxJsonClone().
1418 *
1419 * @param target (@c CxJsonValue*) the target memory or @c NULL
1420 * @param source (@c CxJsonValue*) the value to be cloned
1421 * @param allocator (@c CxAllocator*) the allocator for the new value
1422 * @param data unused
1423 * @return the new value or @c NULL if any allocation was unsuccessful
1424 * @see cxJsonClone()
1425 */
1426 #define cxJsonCloneFunc ((cx_clone_func) cx_json_clone_func)
1427
1379 #ifdef __cplusplus 1428 #ifdef __cplusplus
1380 } 1429 }
1381 #endif 1430 #endif
1382 1431
1383 #endif /* UCX_JSON_H */ 1432 #endif /* UCX_JSON_H */

mercurial