LCOV - code coverage report
Current view: directory - home/even/poppler-git/install/include/poppler/goo - GooList.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 2 2 100.0 %
Date: 2013-03-30 Functions: 2 2 100.0 %

       1                 : //========================================================================
       2                 : //
       3                 : // GooList.h
       4                 : //
       5                 : // Copyright 2001-2003 Glyph & Cog, LLC
       6                 : //
       7                 : //========================================================================
       8                 : 
       9                 : //========================================================================
      10                 : //
      11                 : // Modified under the Poppler project - http://poppler.freedesktop.org
      12                 : //
      13                 : // All changes made under the Poppler project to this file are licensed
      14                 : // under GPL version 2 or later
      15                 : //
      16                 : // Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
      17                 : //
      18                 : // To see a description of the changes please see the Changelog file that
      19                 : // came with your tarball or type make ChangeLog if you are building from git
      20                 : //
      21                 : //========================================================================
      22                 : 
      23                 : #ifndef GLIST_H
      24                 : #define GLIST_H
      25                 : 
      26                 : #ifdef USE_GCC_PRAGMAS
      27                 : #pragma interface
      28                 : #endif
      29                 : 
      30                 : #include "gtypes.h"
      31                 : 
      32                 : //------------------------------------------------------------------------
      33                 : // GooList
      34                 : //------------------------------------------------------------------------
      35                 : 
      36                 : class GooList {
      37                 : public:
      38                 : 
      39                 :   // Create an empty list.
      40                 :   GooList();
      41                 : 
      42                 :   // Create an empty list with space for <size1> elements.
      43                 :   GooList(int sizeA);
      44                 : 
      45                 :   // Destructor - does not free pointed-to objects.
      46                 :   ~GooList();
      47                 : 
      48                 :   //----- general
      49                 : 
      50                 :   // Get the number of elements.
      51              12 :   int getLength() { return length; }
      52                 : 
      53                 :   // Returns a (shallow) copy of this list.
      54                 :   GooList *copy();
      55                 : 
      56                 :   //----- ordered list support
      57                 : 
      58                 :   // Return the <i>th element.
      59                 :   // Assumes 0 <= i < length.
      60              10 :   void *get(int i) { return data[i]; }
      61                 : 
      62                 :   // Replace the <i>th element.
      63                 :   // Assumes 0 <= i < length.
      64                 :   void put(int i, void *p) { data[i] = p; }
      65                 : 
      66                 :   // Append an element to the end of the list.
      67                 :   void append(void *p);
      68                 : 
      69                 :   // Append another list to the end of this one.
      70                 :   void append(GooList *list);
      71                 : 
      72                 :   // Insert an element at index <i>.
      73                 :   // Assumes 0 <= i <= length.
      74                 :   void insert(int i, void *p);
      75                 : 
      76                 :   // Deletes and returns the element at index <i>.
      77                 :   // Assumes 0 <= i < length.
      78                 :   void *del(int i);
      79                 : 
      80                 :   // Sort the list accoring to the given comparison function.
      81                 :   // NB: this sorts an array of pointers, so the pointer args need to
      82                 :   // be double-dereferenced.
      83                 :   void sort(int (*cmp)(const void *ptr1, const void *ptr2));
      84                 : 
      85                 :   // Reverse the list.
      86                 :   void reverse();
      87                 : 
      88                 :   //----- control
      89                 : 
      90                 :   // Set allocation increment to <inc>.  If inc > 0, that many
      91                 :   // elements will be allocated every time the list is expanded.
      92                 :   // If inc <= 0, the list will be doubled in size.
      93                 :   void setAllocIncr(int incA) { inc = incA; }
      94                 : 
      95                 : private:
      96                 :   GooList(const GooList &other);
      97                 :   GooList& operator=(const GooList &other);
      98                 : 
      99                 :   void expand();
     100                 :   void shrink();
     101                 : 
     102                 :   void **data;      // the list elements
     103                 :   int size;     // size of data array
     104                 :   int length;     // number of elements on list
     105                 :   int inc;      // allocation increment
     106                 : };
     107                 : 
     108                 : #define deleteGooList(list, T)                        \
     109                 :   do {                                              \
     110                 :     GooList *_list = (list);                          \
     111                 :     {                                               \
     112                 :       int _i;                                       \
     113                 :       for (_i = 0; _i < _list->getLength(); ++_i) { \
     114                 :         delete (T*)_list->get(_i);                  \
     115                 :       }                                             \
     116                 :       delete _list;                                 \
     117                 :     }                                               \
     118                 :   } while (0)
     119                 : 
     120                 : #endif

Generated by: LCOV version 1.7