summaryrefslogtreecommitdiffstats
path: root/include/plist
diff options
context:
space:
mode:
Diffstat (limited to 'include/plist')
-rw-r--r--include/plist/plist.h162
1 files changed, 161 insertions, 1 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h
index dcc4a04..7d5b4cb 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -492,6 +492,166 @@ extern "C"
492 */ 492 */
493 PLIST_API void plist_dict_merge(plist_t *target, plist_t source); 493 PLIST_API void plist_dict_merge(plist_t *target, plist_t source);
494 494
495 /**
496 * Get a boolean value from a given #PLIST_DICT entry.
497 *
498 * The value node can be of type #PLIST_BOOLEAN, but also
499 * #PLIST_STRING (either 'true' or 'false'),
500 * #PLIST_INT with a numerical value of 0 or >= 1,
501 * or #PLIST_DATA with a single byte with a value of 0 or >= 1.
502 *
503 * @note This function returns 0 if the dictionary does not contain an
504 * entry for the given key, if the value node is of any other than
505 * the above mentioned type, or has any mismatching value.
506 *
507 * @param dict A node of type #PLIST_DICT
508 * @param key The key to look for in dict
509 * @return 0 or 1 depending on the value of the node.
510 */
511 PLIST_API uint8_t plist_dict_get_bool(plist_t dict, const char *key);
512
513 /**
514 * Get a signed integer value from a given #PLIST_DICT entry.
515 * The value node can be of type #PLIST_INT, but also
516 * #PLIST_STRING with a numerical value as string (decimal or hexadecimal),
517 * or #PLIST_DATA with a size of 1, 2, 4, or 8 bytes in little endian byte order.
518 *
519 * @note This function returns 0 if the dictionary does not contain an
520 * entry for the given key, if the value node is of any other than
521 * the above mentioned type, or has any mismatching value.
522 *
523 * @param dict A node of type #PLIST_DICT
524 * @param key The key to look for in dict
525 * @return Signed integer value depending on the value of the node.
526 */
527 PLIST_API int64_t plist_dict_get_int(plist_t dict, const char *key);
528
529 /**
530 * Get an unsigned integer value from a given #PLIST_DICT entry.
531 * The value node can be of type #PLIST_INT, but also
532 * #PLIST_STRING with a numerical value as string (decimal or hexadecimal),
533 * or #PLIST_DATA with a size of 1, 2, 4, or 8 bytes in little endian byte order.
534 *
535 * @note This function returns 0 if the dictionary does not contain an
536 * entry for the given key, if the value node is of any other than
537 * the above mentioned type, or has any mismatching value.
538 *
539 * @param dict A node of type #PLIST_DICT
540 * @param key The key to look for in dict
541 * @return Signed integer value depending on the value of the node.
542 */
543 PLIST_API uint64_t plist_dict_get_uint(plist_t dict, const char *key);
544
545 /**
546 * Copy a node from *source_dict* to *target_dict*.
547 * The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
548 * is non-NULL, in which case it is looked up with *alt_source_key*.
549 * The entry in *target_dict* is **always** created with *key*.
550 *
551 * @param target_dict The target dictionary to copy to.
552 * @param source_dict The source dictionary to copy from.
553 * @param key The key for the node to copy.
554 * @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
555 *
556 * @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
557 * any entry with given key or alt_source_key.
558 */
559 PLIST_API plist_err_t plist_dict_copy_item(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
560
561 /**
562 * Copy a boolean value from *source_dict* to *target_dict*.
563 * The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
564 * is non-NULL, in which case it is looked up with *alt_source_key*.
565 * The entry in *target_dict* is **always** created with *key*.
566 *
567 * @note The boolean value from *source_dict* is retrieved with #plist_dict_get_bool,
568 * but is **always** created as #PLIST_BOOLEAN in *target_dict*.
569 *
570 * @param target_dict The target dictionary to copy to.
571 * @param source_dict The source dictionary to copy from.
572 * @param key The key for the node to copy.
573 * @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
574 *
575 * @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
576 * any entry with given key or alt_source_key.
577 */
578 PLIST_API plist_err_t plist_dict_copy_bool(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
579
580 /**
581 * Copy a signed integer value from *source_dict* to *target_dict*.
582 * The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
583 * is non-NULL, in which case it is looked up with *alt_source_key*.
584 * The entry in *target_dict* is **always** created with *key*.
585 *
586 * @note The signed integer value from *source_dict* is retrieved with #plist_dict_get_int,
587 * but is **always** created as #PLIST_INT.
588 *
589 * @param target_dict The target dictionary to copy to.
590 * @param source_dict The source dictionary to copy from.
591 * @param key The key for the node value to copy.
592 * @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
593 *
594 * @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
595 * any entry with given key or alt_source_key.
596 */
597 PLIST_API plist_err_t plist_dict_copy_int(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
598
599 /**
600 * Copy an unsigned integer value from *source_dict* to *target_dict*.
601 * The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
602 * is non-NULL, in which case it is looked up with *alt_source_key*.
603 * The entry in *target_dict* is **always** created with *key*.
604 *
605 * @note The unsigned integer value from *source_dict* is retrieved with #plist_dict_get_uint,
606 * but is **always** created as #PLIST_INT.
607 *
608 * @param target_dict The target dictionary to copy to.
609 * @param source_dict The source dictionary to copy from.
610 * @param key The key for the node value to copy.
611 * @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
612 *
613 * @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
614 * any entry with given key or alt_source_key.
615 */
616 PLIST_API plist_err_t plist_dict_copy_uint(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
617
618 /**
619 * Copy a #PLIST_DATA node from *source_dict* to *target_dict*.
620 * The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
621 * is non-NULL, in which case it is looked up with *alt_source_key*.
622 * The entry in *target_dict* is **always** created with *key*.
623 *
624 * @note This function is like #plist_dict_copy_item, except that it fails
625 * if the source node is not of type #PLIST_DATA.
626 *
627 * @param target_dict The target dictionary to copy to.
628 * @param source_dict The source dictionary to copy from.
629 * @param key The key for the node value to copy.
630 * @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
631 *
632 * @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
633 * any entry with given key or alt_source_key, or if it is not of type #PLIST_DATA.
634 */
635 PLIST_API plist_err_t plist_dict_copy_data(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
636
637 /**
638 * Copy a #PLIST_STRING node from *source_dict* to *target_dict*.
639 * The node is looked up in *source_dict* with given *key*, unless *alt_source_key*
640 * is non-NULL, in which case it is looked up with *alt_source_key*.
641 * The entry in *target_dict* is **always** created with *key*.
642 *
643 * @note This function is like #plist_dict_copy_item, except that it fails
644 * if the source node is not of type #PLIST_STRING.
645 *
646 * @param target_dict The target dictionary to copy to.
647 * @param source_dict The source dictionary to copy from.
648 * @param key The key for the node value to copy.
649 * @param alt_source_key The alternative source key for lookup in *source_dict* or NULL.
650 *
651 * @result PLIST_ERR_SUCCESS on success or PLIST_ERR_INVALID_ARG if the source dictionary does not contain
652 * any entry with given key or alt_source_key, or if it is not of type #PLIST_STRING.
653 */
654 PLIST_API plist_err_t plist_dict_copy_string(plist_t target_dict, plist_t source_dict, const char *key, const char *alt_source_key);
495 655
496 /******************************************** 656 /********************************************
497 * * 657 * *
@@ -608,7 +768,7 @@ extern "C"
608 * 768 *
609 * @return Pointer to the buffer 769 * @return Pointer to the buffer
610 */ 770 */
611 PLIST_API const uint8_t* plist_get_data_ptr(plist_t node, uint64_t * length); 771 PLIST_API const uint8_t* plist_get_data_ptr(plist_t node, uint64_t* length);
612 772
613 /** 773 /**
614 * Get the value of a #PLIST_DATE node. 774 * Get the value of a #PLIST_DATE node.