ftlist.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /***************************************************************************/
  2. /* */
  3. /* ftlist.h */
  4. /* */
  5. /* Generic list support for FreeType (specification). */
  6. /* */
  7. /* Copyright 1996-2001 by */
  8. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  9. /* */
  10. /* This file is part of the FreeType project, and may only be used, */
  11. /* modified, and distributed under the terms of the FreeType project */
  12. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  13. /* this file you indicate that you have read the license and */
  14. /* understand and accept it fully. */
  15. /* */
  16. /***************************************************************************/
  17. /*************************************************************************/
  18. /* */
  19. /* This file implements functions relative to list processing. Its */
  20. /* data structures are defined in `freetype.h'. */
  21. /* */
  22. /*************************************************************************/
  23. #ifndef __FTLIST_H__
  24. #define __FTLIST_H__
  25. #include <ft2build.h>
  26. #include FT_FREETYPE_H
  27. FT_BEGIN_HEADER
  28. /*************************************************************************/
  29. /* */
  30. /* <Section> */
  31. /* list_processing */
  32. /* */
  33. /* <Title> */
  34. /* List Processing */
  35. /* */
  36. /* <Abstract> */
  37. /* Simple management of lists. */
  38. /* */
  39. /* <Description> */
  40. /* This section contains various definitions related to list */
  41. /* processing using doubly-linked nodes. */
  42. /* */
  43. /* <Order> */
  44. /* FT_List */
  45. /* FT_ListNode */
  46. /* FT_ListRec */
  47. /* FT_ListNodeRec */
  48. /* */
  49. /* FT_List_Add */
  50. /* FT_List_Insert */
  51. /* FT_List_Find */
  52. /* FT_List_Remove */
  53. /* FT_List_Up */
  54. /* FT_List_Iterate */
  55. /* FT_List_Iterator */
  56. /* FT_List_Finalize */
  57. /* FT_List_Destructor */
  58. /* */
  59. /*************************************************************************/
  60. /*************************************************************************/
  61. /* */
  62. /* <Function> */
  63. /* FT_List_Find */
  64. /* */
  65. /* <Description> */
  66. /* Finds the list node for a given listed object. */
  67. /* */
  68. /* <Input> */
  69. /* list :: A pointer to the parent list. */
  70. /* data :: The address of the listed object. */
  71. /* */
  72. /* <Return> */
  73. /* List node. NULL if it wasn't found. */
  74. /* */
  75. FT_EXPORT( FT_ListNode )
  76. FT_List_Find( FT_List list,
  77. void* data );
  78. /*************************************************************************/
  79. /* */
  80. /* <Function> */
  81. /* FT_List_Add */
  82. /* */
  83. /* <Description> */
  84. /* Appends an element to the end of a list. */
  85. /* */
  86. /* <InOut> */
  87. /* list :: A pointer to the parent list. */
  88. /* node :: The node to append. */
  89. /* */
  90. FT_EXPORT( void )
  91. FT_List_Add( FT_List list,
  92. FT_ListNode node );
  93. /*************************************************************************/
  94. /* */
  95. /* <Function> */
  96. /* FT_List_Insert */
  97. /* */
  98. /* <Description> */
  99. /* Inserts an element at the head of a list. */
  100. /* */
  101. /* <InOut> */
  102. /* list :: A pointer to parent list. */
  103. /* node :: The node to insert. */
  104. /* */
  105. FT_EXPORT( void )
  106. FT_List_Insert( FT_List list,
  107. FT_ListNode node );
  108. /*************************************************************************/
  109. /* */
  110. /* <Function> */
  111. /* FT_List_Remove */
  112. /* */
  113. /* <Description> */
  114. /* Removes a node from a list. This function doesn't check whether */
  115. /* the node is in the list! */
  116. /* */
  117. /* <Input> */
  118. /* node :: The node to remove. */
  119. /* */
  120. /* <InOut> */
  121. /* list :: A pointer to the parent list. */
  122. /* */
  123. FT_EXPORT( void )
  124. FT_List_Remove( FT_List list,
  125. FT_ListNode node );
  126. /*************************************************************************/
  127. /* */
  128. /* <Function> */
  129. /* FT_List_Up */
  130. /* */
  131. /* <Description> */
  132. /* Moves a node to the head/top of a list. Used to maintain LRU */
  133. /* lists. */
  134. /* */
  135. /* <InOut> */
  136. /* list :: A pointer to the parent list. */
  137. /* node :: The node to move. */
  138. /* */
  139. FT_EXPORT( void )
  140. FT_List_Up( FT_List list,
  141. FT_ListNode node );
  142. /*************************************************************************/
  143. /* */
  144. /* <FuncType> */
  145. /* FT_List_Iterator */
  146. /* */
  147. /* <Description> */
  148. /* An FT_List iterator function which is called during a list parse */
  149. /* by FT_List_Iterate(). */
  150. /* */
  151. /* <Input> */
  152. /* node :: The current iteration list node. */
  153. /* */
  154. /* user :: A typeless pointer passed to FT_List_Iterate(). */
  155. /* Can be used to point to the iteration's state. */
  156. /* */
  157. typedef FT_Error
  158. (*FT_List_Iterator)( FT_ListNode node,
  159. void* user );
  160. /*************************************************************************/
  161. /* */
  162. /* <Function> */
  163. /* FT_List_Iterate */
  164. /* */
  165. /* <Description> */
  166. /* Parses a list and calls a given iterator function on each element. */
  167. /* Note that parsing is stopped as soon as one of the iterator calls */
  168. /* returns a non-zero value. */
  169. /* */
  170. /* <Input> */
  171. /* list :: A handle to the list. */
  172. /* iterator :: An interator function, called on each node of the */
  173. /* list. */
  174. /* user :: A user-supplied field which is passed as the second */
  175. /* argument to the iterator. */
  176. /* */
  177. /* <Return> */
  178. /* The result (a FreeType error code) of the last iterator call. */
  179. /* */
  180. FT_EXPORT( FT_Error )
  181. FT_List_Iterate( FT_List list,
  182. FT_List_Iterator iterator,
  183. void* user );
  184. /*************************************************************************/
  185. /* */
  186. /* <FuncType> */
  187. /* FT_List_Destructor */
  188. /* */
  189. /* <Description> */
  190. /* An FT_List iterator function which is called during a list */
  191. /* finalization by FT_List_Finalize() to destroy all elements in a */
  192. /* given list. */
  193. /* */
  194. /* <Input> */
  195. /* system :: The current system object. */
  196. /* */
  197. /* data :: The current object to destroy. */
  198. /* */
  199. /* user :: A typeless pointer passed to FT_List_Iterate(). It can */
  200. /* be used to point to the iteration's state. */
  201. /* */
  202. typedef void
  203. (*FT_List_Destructor)( FT_Memory memory,
  204. void* data,
  205. void* user );
  206. /*************************************************************************/
  207. /* */
  208. /* <Function> */
  209. /* FT_List_Finalize */
  210. /* */
  211. /* <Description> */
  212. /* Destroys all elements in the list as well as the list itself. */
  213. /* */
  214. /* <Input> */
  215. /* list :: A handle to the list. */
  216. /* */
  217. /* destroy :: A list destructor that will be applied to each element */
  218. /* of the list. */
  219. /* */
  220. /* memory :: The current memory object which handles deallocation. */
  221. /* */
  222. /* user :: A user-supplied field which is passed as the last */
  223. /* argument to the destructor. */
  224. /* */
  225. FT_EXPORT( void )
  226. FT_List_Finalize( FT_List list,
  227. FT_List_Destructor destroy,
  228. FT_Memory memory,
  229. void* user );
  230. /* */
  231. FT_END_HEADER
  232. #endif /* __FTLIST_H__ */
  233. /* END */