]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc-array.cxx
4 // Array class for the CUPS PPD Compiler.
6 // Copyright 2007 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 // ppdcArray::ppdcArray() - Create a new array.
18 // ppdcArray::~ppdcArray() - Destroy an array.
19 // ppdcArray::add() - Add an element to an array.
20 // ppdcArray::first() - Return the first element in the array.
21 // ppdcArray::next() - Return the next element in the array.
22 // ppdcArray::remove() - Remove an element from the array.
26 // Include necessary headers...
33 // 'ppdcArray::ppdcArray()' - Create a new array.
36 ppdcArray::ppdcArray(ppdcArray
*a
)
45 // Make a copy of the array...
46 data
= new ppdcShared
*[count
];
48 memcpy(data
, a
->data
, count
* sizeof(ppdcShared
*));
50 for (int i
= 0; i
< count
; i
++)
68 // 'ppdcArray::~ppdcArray()' - Destroy an array.
71 ppdcArray::~ppdcArray()
73 for (int i
= 0; i
< count
; i
++)
82 // 'ppdcArray::add()' - Add an element to an array.
86 ppdcArray::add(ppdcShared
*d
)
94 temp
= new ppdcShared
*[alloc
];
96 memcpy(temp
, data
, count
* sizeof(ppdcShared
*));
107 // 'ppdcArray::first()' - Return the first element in the array.
115 if (current
>= count
)
118 return (data
[current
++]);
123 // 'ppdcArray::next()' - Return the next element in the array.
129 if (current
>= count
)
132 return (data
[current
++]);
137 // 'ppdcArray::remove()' - Remove an element from the array.
141 ppdcArray::remove(ppdcShared
*d
) // I - Data element
143 int i
; // Looping var
146 for (i
= 0; i
< count
; i
++)
157 memmove(data
+ i
, data
+ i
+ 1, (count
- i
) * sizeof(ppdcShared
*));