]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc-array.cxx
d56b92a33d187ce10c93cfd04dcaec8dc00431c1
2 // Array class for the CUPS PPD Compiler.
4 // Copyright 2007-2014 by Apple Inc.
5 // Copyright 2002-2005 by Easy Software Products.
7 // These coded instructions, statements, and computer programs are the
8 // property of Apple Inc. and are protected by Federal copyright
9 // law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 // which should have been included with this file. If this file is
11 // file is missing or damaged, see the license at "http://www.cups.org/".
15 // Include necessary headers...
18 #include "ppdc-private.h"
22 // 'ppdcArray::ppdcArray()' - Create a new array.
25 ppdcArray::ppdcArray(ppdcArray
*a
)
37 // Make a copy of the array...
38 data
= new ppdcShared
*[count
];
40 memcpy(data
, a
->data
, (size_t)count
* sizeof(ppdcShared
*));
42 for (int i
= 0; i
< count
; i
++)
60 // 'ppdcArray::~ppdcArray()' - Destroy an array.
63 ppdcArray::~ppdcArray()
67 for (int i
= 0; i
< count
; i
++)
76 // 'ppdcArray::add()' - Add an element to an array.
80 ppdcArray::add(ppdcShared
*d
)
88 temp
= new ppdcShared
*[alloc
];
90 memcpy(temp
, data
, (size_t)count
* sizeof(ppdcShared
*));
101 // 'ppdcArray::first()' - Return the first element in the array.
109 if (current
>= count
)
112 return (data
[current
++]);
117 // 'ppdcArray::next()' - Return the next element in the array.
123 if (current
>= count
)
126 return (data
[current
++]);
131 // 'ppdcArray::remove()' - Remove an element from the array.
135 ppdcArray::remove(ppdcShared
*d
) // I - Data element
137 int i
; // Looping var
140 for (i
= 0; i
< count
; i
++)
151 memmove(data
+ i
, data
+ i
+ 1, (size_t)(count
- i
) * sizeof(ppdcShared
*));