]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc-array.cxx
d06d864fdc240d5beaf7fba4a97419cd59d4caf3
2 // Array class for the CUPS PPD Compiler.
4 // Copyright © 2020-2024 by OpenPrinting.
5 // Copyright 2007-2019 by Apple Inc.
6 // Copyright 2002-2005 by Easy Software Products.
8 // Licensed under Apache License v2.0. See the file "LICENSE" for more information.
12 // Include necessary headers...
15 #include "ppdc-private.h"
19 // 'ppdcArray::ppdcArray()' - Create a new array.
22 ppdcArray::ppdcArray(ppdcArray
*a
)
34 // Make a copy of the array...
35 data
= new ppdcShared
*[count
];
37 memcpy(data
, a
->data
, (size_t)count
* sizeof(ppdcShared
*));
39 for (size_t i
= 0; i
< count
; i
++)
57 // 'ppdcArray::~ppdcArray()' - Destroy an array.
60 ppdcArray::~ppdcArray()
64 for (size_t i
= 0; i
< count
; i
++)
73 // 'ppdcArray::add()' - Add an element to an array.
77 ppdcArray::add(ppdcShared
*d
)
85 temp
= new ppdcShared
*[alloc
];
87 memcpy(temp
, data
, (size_t)count
* sizeof(ppdcShared
*));
98 // 'ppdcArray::first()' - Return the first element in the array.
106 if (current
>= count
)
109 return (data
[current
++]);
114 // 'ppdcArray::next()' - Return the next element in the array.
120 if (current
>= count
)
123 return (data
[current
++]);
128 // 'ppdcArray::remove()' - Remove an element from the array.
132 ppdcArray::remove(ppdcShared
*d
) // I - Data element
134 size_t i
; // Looping var
137 for (i
= 0; i
< count
; i
++)
148 memmove(data
+ i
, data
+ i
+ 1, (size_t)(count
- i
) * sizeof(ppdcShared
*));