1/**
2 * \file assocdat.h
3 * \brief YASM associated data storage (libyasm internal use)
4 *
5 * \license
6 *  Copyright (C) 2003-2007  Peter Johnson
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
33#ifndef YASM_LIB_DECL
34#define YASM_LIB_DECL
35#endif
36
37/** Associated data container. */
38typedef struct yasm__assoc_data yasm__assoc_data;
39
40/** Create an associated data container. */
41YASM_LIB_DECL
42/*@only@*/ yasm__assoc_data *yasm__assoc_data_create(void);
43
44/** Get associated data for a data callback.
45 * \param assoc_data    container of associated data
46 * \param callback      callback used when adding data
47 * \return Associated data (NULL if none).
48 */
49YASM_LIB_DECL
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.
56 * \param assoc_data    container of associated data
57 * \param callback      callback
58 * \param data          data to associate
59 */
60YASM_LIB_DECL
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. */
67YASM_LIB_DECL
68void yasm__assoc_data_destroy
69    (/*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data);
70
71/** Print all associated data in a container. */
72YASM_LIB_DECL
73void yasm__assoc_data_print(const yasm__assoc_data *assoc_data, FILE *f,
74                            int indent_level);
75
76#endif
77