]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc-array.cxx
4 // Array class for the CUPS PPD Compiler.
6 // Copyright 2007-2014 by Apple Inc.
7 // Copyright 2002-2005 by Easy Software Products.
9 // These coded instructions, statements, and computer programs are the
10 // property of Apple Inc. and are protected by Federal copyright
11 // law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 // which should have been included with this file. If this file is
13 // file is missing or damaged, see the license at "http://www.cups.org/".
17 // Include necessary headers...
20 #include "ppdc-private.h"
24 // 'ppdcArray::ppdcArray()' - Create a new array.
27 ppdcArray::ppdcArray(ppdcArray
*a
)
39 // Make a copy of the array...
40 data
= new ppdcShared
*[count
];
42 memcpy(data
, a
->data
, (size_t)count
* sizeof(ppdcShared
*));
44 for (int i
= 0; i
< count
; i
++)
62 // 'ppdcArray::~ppdcArray()' - Destroy an array.
65 ppdcArray::~ppdcArray()
69 for (int i
= 0; i
< count
; i
++)
78 // 'ppdcArray::add()' - Add an element to an array.
82 ppdcArray::add(ppdcShared
*d
)
90 temp
= new ppdcShared
*[alloc
];
92 memcpy(temp
, data
, (size_t)count
* sizeof(ppdcShared
*));
103 // 'ppdcArray::first()' - Return the first element in the array.
111 if (current
>= count
)
114 return (data
[current
++]);
119 // 'ppdcArray::next()' - Return the next element in the array.
125 if (current
>= count
)
128 return (data
[current
++]);
133 // 'ppdcArray::remove()' - Remove an element from the array.
137 ppdcArray::remove(ppdcShared
*d
) // I - Data element
139 int i
; // Looping var
142 for (i
= 0; i
< count
; i
++)
153 memmove(data
+ i
, data
+ i
+ 1, (size_t)(count
- i
) * sizeof(ppdcShared
*));