Home | History | Annotate | Download | only in freetype
      1 /****************************************************************************
      2  *
      3  * ftlist.h
      4  *
      5  *   Generic list support for FreeType (specification).
      6  *
      7  * Copyright 1996-2018 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   /**************************************************************************
     20    *
     21    * This file implements functions relative to list processing.  Its
     22    * data structures are defined in `freetype.h'.
     23    *
     24    */
     25 
     26 
     27 #ifndef FTLIST_H_
     28 #define FTLIST_H_
     29 
     30 
     31 #include <ft2build.h>
     32 #include FT_FREETYPE_H
     33 
     34 #ifdef FREETYPE_H
     35 #error "freetype.h of FreeType 1 has been loaded!"
     36 #error "Please fix the directory search order for header files"
     37 #error "so that freetype.h of FreeType 2 is found first."
     38 #endif
     39 
     40 
     41 FT_BEGIN_HEADER
     42 
     43 
     44   /**************************************************************************
     45    *
     46    * @section:
     47    *   list_processing
     48    *
     49    * @title:
     50    *   List Processing
     51    *
     52    * @abstract:
     53    *   Simple management of lists.
     54    *
     55    * @description:
     56    *   This section contains various definitions related to list
     57    *   processing using doubly-linked nodes.
     58    *
     59    * @order:
     60    *   FT_List
     61    *   FT_ListNode
     62    *   FT_ListRec
     63    *   FT_ListNodeRec
     64    *
     65    *   FT_List_Add
     66    *   FT_List_Insert
     67    *   FT_List_Find
     68    *   FT_List_Remove
     69    *   FT_List_Up
     70    *   FT_List_Iterate
     71    *   FT_List_Iterator
     72    *   FT_List_Finalize
     73    *   FT_List_Destructor
     74    *
     75    */
     76 
     77 
     78   /**************************************************************************
     79    *
     80    * @function:
     81    *   FT_List_Find
     82    *
     83    * @description:
     84    *   Find the list node for a given listed object.
     85    *
     86    * @input:
     87    *   list ::
     88    *     A pointer to the parent list.
     89    *   data ::
     90    *     The address of the listed object.
     91    *
     92    * @return:
     93    *   List node.  NULL if it wasn't found.
     94    */
     95   FT_EXPORT( FT_ListNode )
     96   FT_List_Find( FT_List  list,
     97                 void*    data );
     98 
     99 
    100   /**************************************************************************
    101    *
    102    * @function:
    103    *   FT_List_Add
    104    *
    105    * @description:
    106    *   Append an element to the end of a list.
    107    *
    108    * @inout:
    109    *   list ::
    110    *     A pointer to the parent list.
    111    *   node ::
    112    *     The node to append.
    113    */
    114   FT_EXPORT( void )
    115   FT_List_Add( FT_List      list,
    116                FT_ListNode  node );
    117 
    118 
    119   /**************************************************************************
    120    *
    121    * @function:
    122    *   FT_List_Insert
    123    *
    124    * @description:
    125    *   Insert an element at the head of a list.
    126    *
    127    * @inout:
    128    *   list ::
    129    *     A pointer to parent list.
    130    *   node ::
    131    *     The node to insert.
    132    */
    133   FT_EXPORT( void )
    134   FT_List_Insert( FT_List      list,
    135                   FT_ListNode  node );
    136 
    137 
    138   /**************************************************************************
    139    *
    140    * @function:
    141    *   FT_List_Remove
    142    *
    143    * @description:
    144    *   Remove a node from a list.  This function doesn't check whether
    145    *   the node is in the list!
    146    *
    147    * @input:
    148    *   node ::
    149    *     The node to remove.
    150    *
    151    * @inout:
    152    *   list ::
    153    *     A pointer to the parent list.
    154    */
    155   FT_EXPORT( void )
    156   FT_List_Remove( FT_List      list,
    157                   FT_ListNode  node );
    158 
    159 
    160   /**************************************************************************
    161    *
    162    * @function:
    163    *   FT_List_Up
    164    *
    165    * @description:
    166    *   Move a node to the head/top of a list.  Used to maintain LRU
    167    *   lists.
    168    *
    169    * @inout:
    170    *   list ::
    171    *     A pointer to the parent list.
    172    *   node ::
    173    *     The node to move.
    174    */
    175   FT_EXPORT( void )
    176   FT_List_Up( FT_List      list,
    177               FT_ListNode  node );
    178 
    179 
    180   /**************************************************************************
    181    *
    182    * @functype:
    183    *   FT_List_Iterator
    184    *
    185    * @description:
    186    *   An FT_List iterator function that is called during a list parse
    187    *   by @FT_List_Iterate.
    188    *
    189    * @input:
    190    *   node ::
    191    *     The current iteration list node.
    192    *
    193    *   user ::
    194    *     A typeless pointer passed to @FT_List_Iterate.
    195    *     Can be used to point to the iteration's state.
    196    */
    197   typedef FT_Error
    198   (*FT_List_Iterator)( FT_ListNode  node,
    199                        void*        user );
    200 
    201 
    202   /**************************************************************************
    203    *
    204    * @function:
    205    *   FT_List_Iterate
    206    *
    207    * @description:
    208    *   Parse a list and calls a given iterator function on each element.
    209    *   Note that parsing is stopped as soon as one of the iterator calls
    210    *   returns a non-zero value.
    211    *
    212    * @input:
    213    *   list ::
    214    *     A handle to the list.
    215    *   iterator ::
    216    *     An iterator function, called on each node of the list.
    217    *   user ::
    218    *     A user-supplied field that is passed as the second
    219    *     argument to the iterator.
    220    *
    221    * @return:
    222    *   The result (a FreeType error code) of the last iterator call.
    223    */
    224   FT_EXPORT( FT_Error )
    225   FT_List_Iterate( FT_List           list,
    226                    FT_List_Iterator  iterator,
    227                    void*             user );
    228 
    229 
    230   /**************************************************************************
    231    *
    232    * @functype:
    233    *   FT_List_Destructor
    234    *
    235    * @description:
    236    *   An @FT_List iterator function that is called during a list
    237    *   finalization by @FT_List_Finalize to destroy all elements in a
    238    *   given list.
    239    *
    240    * @input:
    241    *   system ::
    242    *     The current system object.
    243    *
    244    *   data ::
    245    *     The current object to destroy.
    246    *
    247    *   user ::
    248    *     A typeless pointer passed to @FT_List_Iterate.  It can
    249    *     be used to point to the iteration's state.
    250    */
    251   typedef void
    252   (*FT_List_Destructor)( FT_Memory  memory,
    253                          void*      data,
    254                          void*      user );
    255 
    256 
    257   /**************************************************************************
    258    *
    259    * @function:
    260    *   FT_List_Finalize
    261    *
    262    * @description:
    263    *   Destroy all elements in the list as well as the list itself.
    264    *
    265    * @input:
    266    *   list ::
    267    *     A handle to the list.
    268    *
    269    *   destroy ::
    270    *     A list destructor that will be applied to each element
    271    *     of the list.  Set this to NULL if not needed.
    272    *
    273    *   memory ::
    274    *     The current memory object that handles deallocation.
    275    *
    276    *   user ::
    277    *     A user-supplied field that is passed as the last
    278    *     argument to the destructor.
    279    *
    280    * @note:
    281    *   This function expects that all nodes added by @FT_List_Add or
    282    *   @FT_List_Insert have been dynamically allocated.
    283    */
    284   FT_EXPORT( void )
    285   FT_List_Finalize( FT_List             list,
    286                     FT_List_Destructor  destroy,
    287                     FT_Memory           memory,
    288                     void*               user );
    289 
    290   /* */
    291 
    292 
    293 FT_END_HEADER
    294 
    295 #endif /* FTLIST_H_ */
    296 
    297 
    298 /* END */
    299