assocdat.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef YASM_LIB_DECL
  33. #define YASM_LIB_DECL
  34. #endif
  35. /** Associated data container. */
  36. typedef struct yasm__assoc_data yasm__assoc_data;
  37. /** Create an associated data container. */
  38. YASM_LIB_DECL
  39. /*@only@*/ yasm__assoc_data *yasm__assoc_data_create(void);
  40. /** Get associated data for a data callback.
  41. * \param assoc_data container of associated data
  42. * \param callback callback used when adding data
  43. * \return Associated data (NULL if none).
  44. */
  45. YASM_LIB_DECL
  46. /*@dependent@*/ /*@null@*/ void *yasm__assoc_data_get
  47. (/*@null@*/ yasm__assoc_data *assoc_data,
  48. const yasm_assoc_data_callback *callback);
  49. /** Add associated data to a associated data container.
  50. * \attention Deletes any existing associated data for that data callback.
  51. * \param assoc_data container of associated data
  52. * \param callback callback
  53. * \param data data to associate
  54. */
  55. YASM_LIB_DECL
  56. /*@only@*/ yasm__assoc_data *yasm__assoc_data_add
  57. (/*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data,
  58. const yasm_assoc_data_callback *callback,
  59. /*@only@*/ /*@null@*/ void *data);
  60. /** Destroy all associated data in a container. */
  61. YASM_LIB_DECL
  62. void yasm__assoc_data_destroy
  63. (/*@null@*/ /*@only@*/ yasm__assoc_data *assoc_data);
  64. /** Print all associated data in a container. */
  65. YASM_LIB_DECL
  66. void yasm__assoc_data_print(const yasm__assoc_data *assoc_data, FILE *f,
  67. int indent_level);
  68. #endif