27 #include <type_traits>
40 template <
class TypeContained>
54 std::cout <<
"Array::setUpAndCopyFrom: typeInfo=0 before getSizeOfConsitituentObject"
59 char* newLoc = (
char*)toMe.
data;
60 char* data = (
char*)fromMe.
data;
64 uint32_t dataSize = 0;
66 #ifdef DEBUG_DEEP_COPY
71 #ifdef DEBUG_DEEP_COPY
72 PDB_COUT <<
"dataSize=" << dataSize << std::endl;
78 memmove(newLoc, data, dataSize * fromMe.
usedSlots);
80 for (uint32_t i = 0; i < fromMe.
usedSlots; i++) {
86 PDB_COUT <<
"exception in array copy" << std::endl;
95 template <
class TypeContained>
97 setUpAndCopyFrom(
this, &toMe);
100 template <
class TypeContained>
102 typeInfo.setup<TypeContained>();
103 usedSlots = numUsedSlots;
104 numSlots = numSlotsIn;
105 if (typeInfo.descendsFromObject()) {
109 for (uint32_t i = 0; i < numUsedSlots; i++) {
110 new ((
void*)&(((TypeContained*)(data))[i])) TypeContained();
117 bzero(data, numUsedSlots *
sizeof(TypeContained));
120 template <
class TypeContained>
122 typeInfo.setup<TypeContained>();
124 numSlots = numSlotsIn;
127 template <
class TypeContained>
129 return resize(numSlots * 2);
132 template <
class TypeContained>
134 typeInfo.setup<TypeContained>();
135 return usedSlots == numSlots;
138 template <
class TypeContained>
140 typeInfo.setup<TypeContained>();
147 template <
class TypeContained>
149 if (typeInfo.getTypeCode() == 0) {
150 std::cout <<
"Array::~Array: typeInfo = 0 before getSizeOfConstituentObject" << std::endl;
153 if (!typeInfo.descendsFromObject())
157 char* location = (
char*)data;
160 uint32_t objSize = 0;
162 objSize = typeInfo.getSizeOfConstituentObject(location);
165 for (uint32_t i = 0; i < usedSlots; i++) {
166 typeInfo.deleteConstituentObject(location + i * objSize);
170 template <
class TypeContained>
175 makeObjectWithExtraStorage<Array<TypeContained>>(
sizeof(TypeContained) * howMany, howMany);
178 TypeContained* newLoc = (TypeContained*)(tempArray->data);
180 uint32_t max = usedSlots;
184 uint32_t min = usedSlots;
188 tempArray->usedSlots = min;
191 size_t myUsedSlots = usedSlots;
193 for (uint32_t i = 0; i < min || i < myUsedSlots; i++) {
196 new ((
void*)&(newLoc[i])) TypeContained();
197 newLoc[i] = ((TypeContained*)(data))[i];
198 }
else if (i < myUsedSlots) {
199 ((TypeContained*)(data))[i].~TypeContained();
209 template <
class TypeContained>
211 return ((TypeContained*)(data))[which];
214 template <
class TypeContained>
216 if (which > usedSlots) {
217 std::cerr <<
"Bad: you are writing past the end of the vector!\n";
220 ((TypeContained*)(data))[which] = val;
223 template <
class TypeContained>
226 new ((
void*)&(((TypeContained*)(data))[usedSlots])) TypeContained();
227 ((((TypeContained*)(data))[usedSlots])) = val;
232 template <
class TypeContained>
236 new ((
void*)&(((TypeContained*)(data))[usedSlots])) TypeContained();
241 template <
class TypeContained>
243 return ((TypeContained*)(data));
246 template <
class TypeContained>
248 if (usedSlots != 0) {
249 ((TypeContained*)(data))[usedSlots - 1].~TypeContained();
254 template <
class TypeContained>
259 template <
class TypeContained>
264 template <
class TypeContained>
269 template <
class TypeContained>
272 std::cout <<
"Array::getSize: typeInfo = 0 before getSizeOfConstituent" << std::endl;
size_t getSizeOfConstituentObject(void *forMe) const
Handle< Array< TypeContained > > doubleSize()
void deleter(void *deleteMe, ObjType *dummy)
void setUpAndCopyFrom(void *target, void *source) const
TypeContained & getObj(uint32_t which)
int16_t getTypeCode() const
void setUpAndCopyFromConstituentObject(void *target, void *source) const
Handle< Array< TypeContained > > resize(uint32_t howMany)
void assign(uint32_t which, const TypeContained &val)
bool descendsFromObject() const
size_t getSize(void *forMe)
void setUsed(uint32_t toMe)
void deleteObject(void *deleteMe)