1/* 2 * Copyright (c) 2014-2020 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/cbor_export.h" 12#include "cbor/common.h" 13 14#ifdef __cplusplus 15extern "C" { 16#endif 17 18/* 19 * ============================================================================ 20 * Tag manipulation 21 * ============================================================================ 22 */ 23 24/** Create a new tag 25 * 26 * @param value The tag value. Please consult the tag repository 27 * @return **new** tag. Item reference is `NULL`. Returns `NULL` upon 28 * memory allocation failure 29 */ 30_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_new_tag(uint64_t value); 31 32/** Get the tagged item 33 * 34 * @param item[borrow] A tag 35 * @return **incref** the tagged item 36 */ 37_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_tag_item(const cbor_item_t *item); 38 39/** Get tag value 40 * 41 * @param item[borrow] A tag 42 * @return The tag value. Please consult the tag repository 43 */ 44_CBOR_NODISCARD CBOR_EXPORT uint64_t cbor_tag_value(const cbor_item_t *item); 45 46/** Set the tagged item 47 * 48 * @param item[borrow] A tag 49 * @param tagged_item[incref] The item to tag 50 */ 51CBOR_EXPORT void cbor_tag_set_item(cbor_item_t *item, cbor_item_t *tagged_item); 52 53/** Build a new tag 54 * 55 * @param item[incref] The tagee 56 * @param value Tag value 57 * @return **new** tag item 58 */ 59_CBOR_NODISCARD CBOR_EXPORT cbor_item_t *cbor_build_tag(uint64_t value, 60 cbor_item_t *item); 61 62#ifdef __cplusplus 63} 64#endif 65 66#endif // LIBCBOR_TAGS_H 67