1 /* 2 * Copyright (c) 2014-2019 Pavel Kalvoda <me@pavelkalvoda.com> 3 * 4 * libcbor is free software; you can redistribute it and/or modify 5 * it under the terms of the MIT license. See LICENSE for details. 6 */ 7 8 #ifndef LIBCBOR_TAGS_H 9 #define LIBCBOR_TAGS_H 10 11 #include "cbor/common.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /* 18 * ============================================================================ 19 * Tag manipulation 20 * ============================================================================ 21 */ 22 23 /** Create a new tag 24 * 25 * @param value The tag value. Please consult the tag repository 26 * @return **new** tag. Item reference is `NULL`. Returns `NULL` upon 27 * memory allocation failure 28 */ 29 cbor_item_t *cbor_new_tag(uint64_t value); 30 31 /** Get the tagged item 32 * 33 * @param item[borrow] A tag 34 * @return **incref** the tagged item 35 */ 36 cbor_item_t *cbor_tag_item(const cbor_item_t *item); 37 38 /** Get tag value 39 * 40 * @param item[borrow] A tag 41 * @return The tag value. Please consult the tag repository 42 */ 43 uint64_t cbor_tag_value(const cbor_item_t *item); 44 45 /** Set the tagged item 46 * 47 * @param item[borrow] A tag 48 * @param tagged_item[incref] The item to tag 49 */ 50 void cbor_tag_set_item(cbor_item_t *item, cbor_item_t *tagged_item); 51 52 /** Build a new tag 53 * 54 * @param item[incref] The tagee 55 * @param value Tag value 56 * @return **new** tag item 57 */ 58 cbor_item_t *cbor_build_tag(uint64_t value, cbor_item_t *item); 59 60 #ifdef __cplusplus 61 } 62 #endif 63 64 #endif // LIBCBOR_TAGS_H 65