00001 /***************************************************************************/ 00002 /* */ 00003 /* ftlist.h */ 00004 /* */ 00005 /* Generic list support for FreeType (specification). */ 00006 /* */ 00007 /* Copyright 1996-2001, 2003, 2007 by */ 00008 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 00009 /* */ 00010 /* This file is part of the FreeType project, and may only be used, */ 00011 /* modified, and distributed under the terms of the FreeType project */ 00012 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 00013 /* this file you indicate that you have read the license and */ 00014 /* understand and accept it fully. */ 00015 /* */ 00016 /***************************************************************************/ 00017 00018 00019 /*************************************************************************/ 00020 /* */ 00021 /* This file implements functions relative to list processing. Its */ 00022 /* data structures are defined in `freetype.h'. */ 00023 /* */ 00024 /*************************************************************************/ 00025 00026 00027 #ifndef __FTLIST_H__ 00028 #define __FTLIST_H__ 00029 00030 00031 #include <ft2build.h> 00032 #include FT_FREETYPE_H 00033 00034 #ifdef FREETYPE_H 00035 #error "freetype.h of FreeType 1 has been loaded!" 00036 #error "Please fix the directory search order for header files" 00037 #error "so that freetype.h of FreeType 2 is found first." 00038 #endif 00039 00040 00041 FT_BEGIN_HEADER 00042 00043 00044 /*************************************************************************/ 00045 /* */ 00046 /* <Section> */ 00047 /* list_processing */ 00048 /* */ 00049 /* <Title> */ 00050 /* List Processing */ 00051 /* */ 00052 /* <Abstract> */ 00053 /* Simple management of lists. */ 00054 /* */ 00055 /* <Description> */ 00056 /* This section contains various definitions related to list */ 00057 /* processing using doubly-linked nodes. */ 00058 /* */ 00059 /* <Order> */ 00060 /* FT_List */ 00061 /* FT_ListNode */ 00062 /* FT_ListRec */ 00063 /* FT_ListNodeRec */ 00064 /* */ 00065 /* FT_List_Add */ 00066 /* FT_List_Insert */ 00067 /* FT_List_Find */ 00068 /* FT_List_Remove */ 00069 /* FT_List_Up */ 00070 /* FT_List_Iterate */ 00071 /* FT_List_Iterator */ 00072 /* FT_List_Finalize */ 00073 /* FT_List_Destructor */ 00074 /* */ 00075 /*************************************************************************/ 00076 00077 00078 /*************************************************************************/ 00079 /* */ 00080 /* <Function> */ 00081 /* FT_List_Find */ 00082 /* */ 00083 /* <Description> */ 00084 /* Find the list node for a given listed object. */ 00085 /* */ 00086 /* <Input> */ 00087 /* list :: A pointer to the parent list. */ 00088 /* data :: The address of the listed object. */ 00089 /* */ 00090 /* <Return> */ 00091 /* List node. NULL if it wasn't found. */ 00092 /* */ 00093 FT_EXPORT( FT_ListNode ) 00094 FT_List_Find( FT_List list, 00095 void* data ); 00096 00097 00098 /*************************************************************************/ 00099 /* */ 00100 /* <Function> */ 00101 /* FT_List_Add */ 00102 /* */ 00103 /* <Description> */ 00104 /* Append an element to the end of a list. */ 00105 /* */ 00106 /* <InOut> */ 00107 /* list :: A pointer to the parent list. */ 00108 /* node :: The node to append. */ 00109 /* */ 00110 FT_EXPORT( void ) 00111 FT_List_Add( FT_List list, 00112 FT_ListNode node ); 00113 00114 00115 /*************************************************************************/ 00116 /* */ 00117 /* <Function> */ 00118 /* FT_List_Insert */ 00119 /* */ 00120 /* <Description> */ 00121 /* Insert an element at the head of a list. */ 00122 /* */ 00123 /* <InOut> */ 00124 /* list :: A pointer to parent list. */ 00125 /* node :: The node to insert. */ 00126 /* */ 00127 FT_EXPORT( void ) 00128 FT_List_Insert( FT_List list, 00129 FT_ListNode node ); 00130 00131 00132 /*************************************************************************/ 00133 /* */ 00134 /* <Function> */ 00135 /* FT_List_Remove */ 00136 /* */ 00137 /* <Description> */ 00138 /* Remove a node from a list. This function doesn't check whether */ 00139 /* the node is in the list! */ 00140 /* */ 00141 /* <Input> */ 00142 /* node :: The node to remove. */ 00143 /* */ 00144 /* <InOut> */ 00145 /* list :: A pointer to the parent list. */ 00146 /* */ 00147 FT_EXPORT( void ) 00148 FT_List_Remove( FT_List list, 00149 FT_ListNode node ); 00150 00151 00152 /*************************************************************************/ 00153 /* */ 00154 /* <Function> */ 00155 /* FT_List_Up */ 00156 /* */ 00157 /* <Description> */ 00158 /* Move a node to the head/top of a list. Used to maintain LRU */ 00159 /* lists. */ 00160 /* */ 00161 /* <InOut> */ 00162 /* list :: A pointer to the parent list. */ 00163 /* node :: The node to move. */ 00164 /* */ 00165 FT_EXPORT( void ) 00166 FT_List_Up( FT_List list, 00167 FT_ListNode node ); 00168 00169 00170 /*************************************************************************/ 00171 /* */ 00172 /* <FuncType> */ 00173 /* FT_List_Iterator */ 00174 /* */ 00175 /* <Description> */ 00176 /* An FT_List iterator function which is called during a list parse */ 00177 /* by @FT_List_Iterate. */ 00178 /* */ 00179 /* <Input> */ 00180 /* node :: The current iteration list node. */ 00181 /* */ 00182 /* user :: A typeless pointer passed to @FT_List_Iterate. */ 00183 /* Can be used to point to the iteration's state. */ 00184 /* */ 00185 typedef FT_Error 00186 (*FT_List_Iterator)( FT_ListNode node, 00187 void* user ); 00188 00189 00190 /*************************************************************************/ 00191 /* */ 00192 /* <Function> */ 00193 /* FT_List_Iterate */ 00194 /* */ 00195 /* <Description> */ 00196 /* Parse a list and calls a given iterator function on each element. */ 00197 /* Note that parsing is stopped as soon as one of the iterator calls */ 00198 /* returns a non-zero value. */ 00199 /* */ 00200 /* <Input> */ 00201 /* list :: A handle to the list. */ 00202 /* iterator :: An iterator function, called on each node of the list. */ 00203 /* user :: A user-supplied field which is passed as the second */ 00204 /* argument to the iterator. */ 00205 /* */ 00206 /* <Return> */ 00207 /* The result (a FreeType error code) of the last iterator call. */ 00208 /* */ 00209 FT_EXPORT( FT_Error ) 00210 FT_List_Iterate( FT_List list, 00211 FT_List_Iterator iterator, 00212 void* user ); 00213 00214 00215 /*************************************************************************/ 00216 /* */ 00217 /* <FuncType> */ 00218 /* FT_List_Destructor */ 00219 /* */ 00220 /* <Description> */ 00221 /* An @FT_List iterator function which is called during a list */ 00222 /* finalization by @FT_List_Finalize to destroy all elements in a */ 00223 /* given list. */ 00224 /* */ 00225 /* <Input> */ 00226 /* system :: The current system object. */ 00227 /* */ 00228 /* data :: The current object to destroy. */ 00229 /* */ 00230 /* user :: A typeless pointer passed to @FT_List_Iterate. It can */ 00231 /* be used to point to the iteration's state. */ 00232 /* */ 00233 typedef void 00234 (*FT_List_Destructor)( FT_Memory memory, 00235 void* data, 00236 void* user ); 00237 00238 00239 /*************************************************************************/ 00240 /* */ 00241 /* <Function> */ 00242 /* FT_List_Finalize */ 00243 /* */ 00244 /* <Description> */ 00245 /* Destroy all elements in the list as well as the list itself. */ 00246 /* */ 00247 /* <Input> */ 00248 /* list :: A handle to the list. */ 00249 /* */ 00250 /* destroy :: A list destructor that will be applied to each element */ 00251 /* of the list. */ 00252 /* */ 00253 /* memory :: The current memory object which handles deallocation. */ 00254 /* */ 00255 /* user :: A user-supplied field which is passed as the last */ 00256 /* argument to the destructor. */ 00257 /* */ 00258 FT_EXPORT( void ) 00259 FT_List_Finalize( FT_List list, 00260 FT_List_Destructor destroy, 00261 FT_Memory memory, 00262 void* user ); 00263 00264 00265 /* */ 00266 00267 00268 FT_END_HEADER 00269 00270 #endif /* __FTLIST_H__ */ 00271 00272 00273 /* END */