Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file assocdat.h |
| 3 | * \brief YASM associated data storage (libyasm internal use) |
| 4 | * |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 5 | * \license |
Peter Johnson | 469e54f | 2007-04-22 05:09:49 +0000 | [diff] [blame] | 6 | * Copyright (C) 2003-2007 Peter Johnson |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * - Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * - Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' |
| 18 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE |
| 21 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 27 | * POSSIBILITY OF SUCH DAMAGE. |
| 28 | * \endlicense |
| 29 | */ |
| 30 | #ifndef YASM_ASSOCDAT_H |
| 31 | #define YASM_ASSOCDAT_H |
| 32 | |
Peter Johnson | eb7b1ad | 2008-05-23 06:46:51 +0000 | [diff] [blame] | 33 | #ifndef YASM_LIB_DECL |
| 34 | #define YASM_LIB_DECL |
| 35 | #endif |
| 36 | |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 37 | /** Associated data container. */ |
| 38 | typedef struct yasm__assoc_data yasm__assoc_data; |
| 39 | |
| 40 | /** Create an associated data container. */ |
Peter Johnson | eb7b1ad | 2008-05-23 06:46:51 +0000 | [diff] [blame] | 41 | YASM_LIB_DECL |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 42 | /*@only@*/ yasm__assoc_data *yasm__assoc_data_create(void); |
| 43 | |
| 44 | /** Get associated data for a data callback. |
Peter Johnson | 00473ca | 2007-04-22 03:32:46 +0000 | [diff] [blame] | 45 | * \param assoc_data container of associated data |
| 46 | * \param callback callback used when adding data |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 47 | * \return Associated data (NULL if none). |
| 48 | */ |
Peter Johnson | eb7b1ad | 2008-05-23 06:46:51 +0000 | [diff] [blame] | 49 | YASM_LIB_DECL |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 50 | /*@dependent@*/ /*@null@*/ void *yasm__assoc_data_get |
| 51 | (/*@null@*/ yasm__assoc_data *assoc_data, |
| 52 | const yasm_assoc_data_callback *callback); |
| 53 | |
| 54 | /** Add associated data to a associated data container. |
| 55 | * \attention Deletes any existing associated data for that data callback. |
Peter Johnson | 00473ca | 2007-04-22 03:32:46 +0000 | [diff] [blame] | 56 | * \param assoc_data container of associated data |
| 57 | * \param callback callback |
| 58 | * \param data data to associate |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 59 | */ |
Peter Johnson | eb7b1ad | 2008-05-23 06:46:51 +0000 | [diff] [blame] | 60 | YASM_LIB_DECL |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 61 | /*@only@*/ yasm__assoc_data *yasm__assoc_data_add |
| 62 | (/*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data, |
| 63 | const yasm_assoc_data_callback *callback, |
| 64 | /*@only@*/ /*@null@*/ void *data); |
| 65 | |
| 66 | /** Destroy all associated data in a container. */ |
Peter Johnson | eb7b1ad | 2008-05-23 06:46:51 +0000 | [diff] [blame] | 67 | YASM_LIB_DECL |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 68 | void yasm__assoc_data_destroy |
| 69 | (/*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data); |
| 70 | |
| 71 | /** Print all associated data in a container. */ |
Peter Johnson | eb7b1ad | 2008-05-23 06:46:51 +0000 | [diff] [blame] | 72 | YASM_LIB_DECL |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 73 | void yasm__assoc_data_print(const yasm__assoc_data *assoc_data, FILE *f, |
Peter Johnson | 00473ca | 2007-04-22 03:32:46 +0000 | [diff] [blame] | 74 | int indent_level); |
Peter Johnson | 55438b7 | 2003-10-02 05:03:50 +0000 | [diff] [blame] | 75 | |
| 76 | #endif |