]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc-array.cxx
2 // Array class for the CUPS PPD Compiler.
4 // Copyright 2007-2014 by Apple Inc.
5 // Copyright 2002-2005 by Easy Software Products.
7 // Licensed under Apache License v2.0. See the file "LICENSE" for more information.
11 // Include necessary headers...
14 #include "ppdc-private.h"
18 // 'ppdcArray::ppdcArray()' - Create a new array.
21 ppdcArray::ppdcArray(ppdcArray
*a
)
33 // Make a copy of the array...
34 data
= new ppdcShared
*[count
];
36 memcpy(data
, a
->data
, (size_t)count
* sizeof(ppdcShared
*));
38 for (int i
= 0; i
< count
; i
++)
56 // 'ppdcArray::~ppdcArray()' - Destroy an array.
59 ppdcArray::~ppdcArray()
63 for (int i
= 0; i
< count
; i
++)
72 // 'ppdcArray::add()' - Add an element to an array.
76 ppdcArray::add(ppdcShared
*d
)
84 temp
= new ppdcShared
*[alloc
];
86 memcpy(temp
, data
, (size_t)count
* sizeof(ppdcShared
*));
97 // 'ppdcArray::first()' - Return the first element in the array.
105 if (current
>= count
)
108 return (data
[current
++]);
113 // 'ppdcArray::next()' - Return the next element in the array.
119 if (current
>= count
)
122 return (data
[current
++]);
127 // 'ppdcArray::remove()' - Remove an element from the array.
131 ppdcArray::remove(ppdcShared
*d
) // I - Data element
133 int i
; // Looping var
136 for (i
= 0; i
< count
; i
++)
147 memmove(data
+ i
, data
+ i
+ 1, (size_t)(count
- i
) * sizeof(ppdcShared
*));