]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc-array.cxx
4 // Array class for the CUPS PPD Compiler.
6 // Copyright 2007-2009 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...
29 #include "ppdc-private.h"
33 // 'ppdcArray::ppdcArray()' - Create a new array.
36 ppdcArray::ppdcArray(ppdcArray
*a
)
48 // Make a copy of the array...
49 data
= new ppdcShared
*[count
];
51 memcpy(data
, a
->data
, count
* sizeof(ppdcShared
*));
53 for (int i
= 0; i
< count
; i
++)
71 // 'ppdcArray::~ppdcArray()' - Destroy an array.
74 ppdcArray::~ppdcArray()
78 for (int i
= 0; i
< count
; i
++)
87 // 'ppdcArray::add()' - Add an element to an array.
91 ppdcArray::add(ppdcShared
*d
)
99 temp
= new ppdcShared
*[alloc
];
101 memcpy(temp
, data
, count
* sizeof(ppdcShared
*));
112 // 'ppdcArray::first()' - Return the first element in the array.
120 if (current
>= count
)
123 return (data
[current
++]);
128 // 'ppdcArray::next()' - Return the next element in the array.
134 if (current
>= count
)
137 return (data
[current
++]);
142 // 'ppdcArray::remove()' - Remove an element from the array.
146 ppdcArray::remove(ppdcShared
*d
) // I - Data element
148 int i
; // Looping var
151 for (i
= 0; i
< count
; i
++)
162 memmove(data
+ i
, data
+ i
+ 1, (count
- i
) * sizeof(ppdcShared
*));