2 * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM
4 * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide.
6 * Tecplot hereby grants OpenCFD limited authority to distribute without
7 * alteration the source code to the Tecplot Input/Output library, known
8 * as TecIO, as part of its distribution of OpenFOAM and the
9 * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby
10 * granted access to the TecIO source code, and may redistribute it for the
11 * purpose of maintaining the converter. However, no authority is granted
12 * to alter the TecIO source code in any form or manner.
14 * This limited grant of distribution does not supersede Tecplot, Inc.'s
15 * copyright in TecIO. Contact Tecplot, Inc. for further information.
18 * 3535 Factoria Blvd, Ste. 550
19 * Bellevue, WA 98006, USA
20 * Phone: +1 425 653 1200
21 * http://www.tecplot.com/
25 *****************************************************************
26 *****************************************************************
28 ****** Copyright (C) 1988-2008 Tecplot, Inc. *******
30 *****************************************************************
31 *****************************************************************
33 #if !defined ARRLIST_h
39 #if defined ARRLISTMODULE
42 # define EXTERN extern
47 ArrayListType_UnsignedChar
,
48 ArrayListType_UnsignedShort
,
49 ArrayListType_UnsignedInt
,
50 ArrayListType_UnsignedLong
,
58 ArrayListType_LgIndex
,
59 ArrayListType_EntIndex
,
60 ArrayListType_SmInteger
,
61 ArrayListType_Boolean
,
62 ArrayListType_ArbParam
,
63 ArrayListType_UnsignedCharPtr
,
64 ArrayListType_UnsignedShortPtr
,
65 ArrayListType_UnsignedIntPtr
,
66 ArrayListType_UnsignedLongPtr
,
67 ArrayListType_Int64Ptr
,
68 ArrayListType_CharPtr
,
69 ArrayListType_ShortPtr
,
71 ArrayListType_LongPtr
,
72 ArrayListType_FloatPtr
,
73 ArrayListType_DoublePtr
,
74 ArrayListType_LgIndexPtr
,
75 ArrayListType_EntIndexPtr
,
76 ArrayListType_SmIntegerPtr
,
77 ArrayListType_BooleanPtr
,
78 ArrayListType_ArbParamPtr
,
79 ArrayListType_VoidPtr
,
80 ArrayListType_FunctionPtr
,
83 ArrayListType_Invalid
= BadEnumValue
88 unsigned char UnsignedChar
;
89 unsigned short UnsignedShort
;
90 unsigned int UnsignedInt
;
91 unsigned long UnsignedLong
;
101 SmInteger_t SmInteger
;
102 Boolean_t BBoolean
; /* X-Windows uses Boolean */
104 unsigned char *UnsignedCharPtr
;
105 unsigned short *UnsignedShortPtr
;
106 unsigned int *UnsignedIntPtr
;
107 unsigned long *UnsignedLongPtr
;
115 LgIndex_t
*LgIndexPtr
;
116 EntIndex_t
*EntIndexPtr
;
117 SmInteger_t
*SmIntegerPtr
;
118 Boolean_t
*BooleanPtr
;
119 ArbParam_t
*ArbParamPtr
;
121 void (*FunctionPtr
)(void);
125 * NULL array list item for added convenience of inserting a NULL item without
126 * having to declare and assign one. Can be used as follows:
128 * IsOk = ArrayListInsertItem(SomeArrayList, SomeIndex, ArrayListNumItem);
130 * NOTE: This value must be set to zero before Tecplot uses array lists.
131 * memset(&ArrayListNullItem, 0, sizeof(ArrayListType_Any));
133 EXTERN ArrayListItem_u ArrayListNullItem
;
136 * Visitor for traversing an array list. An iterator may not perform any
137 * operation that will adjust the size of the list. In other words it may not
138 * insert or delete items from the list. However an iterator may perform a get
139 * operation or a set operation that do not expand the list size.
142 * Reference to the array list item visited.
144 * Any client data required for the visitor.
147 * TRUE to continue visiting items, otherwise
148 * FALSE to discontinue visiting
150 typedef Boolean_t (*ArrayListItemVisitor_pf
)(void *ItemRef
,
151 ArbParam_t ClientData
);
152 #if 0 /* use this stub as a starting place */
154 REQUIRE(VALID_REF(TypeRef
));
155 REQUIRE(VALID_REF(*TypeRef
) || *TypeRef
== NULL
);
157 Boolean_t DoContinue
= TRUE
;
158 <type
> *TypeRef
= (<type
> *)ItemRef
;
160 ENSURE(VALID_BOOLEAN(DoContinue
));
167 * Destructor for cleaning up one or more array list items. If a destructor is
168 * not supplied then the array items are simply discarded.
170 * NOTE: The only change to ArrayListItemVisitor_pf is the policy which
171 * requires that the return value is TRUE.
174 * Reference to the array list item to cleanup.
176 * Any client data required for cleanup.
179 * TRUE is a requirement
181 typedef ArrayListItemVisitor_pf ArrayListItemDestructor_pf
;
185 * Duplicator for copying one or more array list items. If a duplicator is not
186 * supplied then the array items are simply copied. For pointer types this
187 * means by reference. Note that if a duplicator is used the rules for
188 * duplication and subsequent cleanup are defined by the client.
190 * param TargetItemRef
191 * Reference to the array list to receive the duplicate.
192 * param SourceItemRef
193 * Reference to the array list item to duplicate.
195 * Any client data required for duplication.
198 * TRUE if the duplication was a success
199 * FALSE otherwise. If the duplication failed it
200 * is the client's responsibility to cleanup any
201 * partial duplication
203 typedef Boolean_t (*ArrayListItemDuplicator_pf
)(void *TargetItemRef
,
205 ArbParam_t ClientData
);
206 #if 0 /* use this stub as a starting place */
208 REQUIRE(VALID_REF(TargetTypeRef
));
209 REQUIRE(VALID_REF(SourceTypeRef
));
210 REQUIRE(VALID_REF(*SourceTypeRef
) || *SourceTypeRef
== NULL
);
212 Boolean_t IsOk
= TRUE
;
213 <type
> *TargetTypeRef
= (<type
> *)TargetItemRef
;
214 <type
> *SourceTypeRef
= (<type
> *)SourceItemRef
;
216 ENSURE(VALID_BOOLEAN(IsOk
));
223 * Adjusts the capacity request as necessary to minimize memory reallocations
224 * for large lists. Unless the request exceeds the maximum the adjusted
225 * capacity will be at least as big as requested however it may be larger if it
226 * is determined that the space requirement is growing faster. If the maximum
227 * is exceeded zero should be returned.
230 * Array list requesting the change in capacity.
231 * param CurrentCapacity
232 * Current capacity of the array list.
233 * param RequestedCapacity
234 * Capacity request or zero for default size.
236 * Any client data needed for the adjustment.
239 * Adjusted capacity that is at least as large as the request or zero if
240 * unable to satisfy the requested capacity.
242 typedef LgIndex_t (*ArrayListCapacityRequestAdjuster_pf
)(ArrayList_pa ArrayList
,
243 LgIndex_t CurrentCapacity
,
244 LgIndex_t RequestedCapacity
,
245 ArbParam_t ClientData
);
246 #if 0 /* use this stub as a starting place */
248 REQUIRE(ArrayListIsValid(ArrayList
));
249 REQUIRE((RequestedCapacity
== 0 && CurrentCapacity
== 0) ||
250 RequestedCapacity
> ArrayList
->Capacity
);
254 ENSURE(Result
== 0 || Result
>= RequestedCapacity
);
260 /* private ArrayList structure: only exposed so STRUTIL can use it */
261 typedef struct _ArrayList_s
263 char *Array
; /* byte array for holding the items */
264 ArrayListType_e Type
; /* type of array items */
265 SmInteger_t ItemSize
; /* byte size of an individual item */
266 LgIndex_t Count
; /* number of items in the array */
267 LgIndex_t Capacity
; /* maximum holding capacity of the array */
268 Boolean_t IsVisitingItems
; /* indicates if an iteration is in progress */
269 ArrayListCapacityRequestAdjuster_pf CapacityRequestAdjuster
;
270 ArbParam_t CapacityRequestAdjusterClientData
;
275 * Compares two array list elements. Note that either string may be
276 * NULL as array lists allow for NULL elements.
279 * Element to compare against Item2.
281 * Element to compare against Item1.
283 * Contextual information that was passed to the 'ArrayListQSort' function.
286 * - A value less than zero if Item1 is less than Item2.
287 * - A value of zero if Item1 is equal to Item2.
288 * - A value greater than zero if Item1 is greater than Item2.
290 typedef int (STDCALL
*ArrayListItemComparator_pf
)(ArrayListItem_u Item1
,
291 ArrayListItem_u Item2
,
292 ArbParam_t ClientData
);
294 EXTERN Boolean_t
ArrayListIsValid(ArrayList_pa ArrayList
);
295 EXTERN ArrayListType_e
ArrayListGetType(ArrayList_pa ArrayList
);
296 EXTERN Boolean_t
ArrayListEnlargeCapacity(ArrayList_pa ArrayList
,
297 LgIndex_t RequestedCapacity
);
298 EXTERN ArrayList_pa
ArrayListAlloc(LgIndex_t EstimatedCapacity
,
299 ArrayListType_e Type
,
300 ArrayListCapacityRequestAdjuster_pf CapacityRequestAdjuster
,
301 ArbParam_t CapacityRequestAdjusterClientData
);
302 EXTERN
void ArrayListDealloc(ArrayList_pa
*ArrayList
,
303 ArrayListItemDestructor_pf ItemDestructor
,
304 ArbParam_t ClientData
);
305 EXTERN
void ArrayListDeleteAllItems(ArrayList_pa ArrayList
,
306 ArrayListItemDestructor_pf ItemDestructor
,
307 ArbParam_t ClientData
);
308 EXTERN
void ArrayListDeleteItems(ArrayList_pa ArrayList
,
309 LgIndex_t ItemOffset
,
311 ArrayListItemDestructor_pf ItemDestructor
,
312 ArbParam_t ClientData
);
313 EXTERN
void ArrayListDeleteItem(ArrayList_pa ArrayList
,
314 LgIndex_t ItemOffset
,
315 ArrayListItemDestructor_pf ItemDestructor
,
316 ArbParam_t ClientData
);
317 EXTERN ArrayList_pa
ArrayListRemoveItems(ArrayList_pa ArrayList
,
318 LgIndex_t ItemOffset
,
320 EXTERN ArrayListItem_u
ArrayListRemoveItem(ArrayList_pa ArrayList
,
321 LgIndex_t ItemOffset
);
322 EXTERN Boolean_t
ArrayListInsertItem(ArrayList_pa ArrayList
,
323 LgIndex_t ItemOffset
,
324 ArrayListItem_u Item
);
325 EXTERN Boolean_t
ArrayListInsert(ArrayList_pa Target
,
326 LgIndex_t ItemOffset
,
327 ArrayList_pa Source
);
328 EXTERN Boolean_t
ArrayListVisitItems(ArrayList_pa ArrayList
,
329 LgIndex_t ItemOffset
,
331 ArrayListItemVisitor_pf ItemVisitor
,
332 ArbParam_t ClientData
);
333 EXTERN ArrayList_pa
ArrayListGetItems(ArrayList_pa ArrayList
,
334 LgIndex_t ItemOffset
,
336 EXTERN ArrayListItem_u
ArrayListGetItem(ArrayList_pa ArrayList
,
337 LgIndex_t ItemOffset
);
338 EXTERN Boolean_t
ArrayListSetItem(ArrayList_pa ArrayList
,
339 LgIndex_t ItemOffset
,
340 ArrayListItem_u Item
,
341 ArrayListItemDestructor_pf ItemDestructor
,
342 ArbParam_t ClientData
);
343 EXTERN Boolean_t
ArrayListAppendItem(ArrayList_pa ArrayList
,
344 ArrayListItem_u Item
);
345 EXTERN Boolean_t
ArrayListAppend(ArrayList_pa Target
,
346 ArrayList_pa Source
);
347 EXTERN ArrayList_pa
ArrayListCopy(ArrayList_pa ArrayList
,
348 ArrayListItemDuplicator_pf ItemDuplicator
,
349 ArbParam_t ClientData
);
350 EXTERN
void *ArrayListToArray(ArrayList_pa ArrayList
,
351 ArrayListItemDuplicator_pf ItemDuplicator
,
352 ArbParam_t ClientData
);
353 EXTERN ArrayList_pa
ArrayListFromArray(void *Source
,
355 ArrayListType_e Type
,
356 ArrayListItemDuplicator_pf ItemDuplicator
,
357 ArbParam_t ClientData
);
359 #if defined TECPLOTKERNEL
360 /* CORE SOURCE CODE REMOVED */
362 EXTERN
void ArrayListQSort(ArrayList_pa ArrayList
,
363 ArrayListItemComparator_pf Comparator
,
364 ArbParam_t ClientData
);
365 EXTERN Boolean_t
ArrayListBSearch(ArrayList_pa ArrayList
,
366 ArrayListItem_u Item
,
367 ArrayListItemComparator_pf Comparator
,
368 ArbParam_t ClientData
,
369 LgIndex_t
*ItemIndex
);
371 #if defined USE_MACROS_FOR_FUNCTIONS
373 * Gets the array list's internal buffer representation.
374 * Use ArrayListGetXxx accessors whenever possible as their
375 * implementation in the release build is as fast as using
376 * the array directly anyway.
379 * Some array list functions modify the internal buffer.
380 * This will invalidate this reference however it is
381 * the client's responsibility not to make further use
382 * of it. In addition, this reference should never be
383 * deallocated directly as the array list assumes the
384 * responsible for the cleanup.
387 * Array list for which a reference to the internal
391 * Reference to the array list's internal buffer.
393 # define ArrayListGetInternalRef ArrayListGetInternalRef_MACRO
395 * Gets the item's internal reference at the specified offset in the list.
398 * Some array list functions modify the internal buffer.
399 * This will invalidate this reference however it is
400 * the client's responsibility not to make further use
401 * of it. In addition, this reference should never be
402 * deallocated directly as the array list assumes the
403 * responsible for the cleanup.
406 * Array list containing the desired item.
408 * Offset to the item in the list.
411 * The internal reference to the requested item.
413 # define ArrayListGetItemInternalRef ArrayListGetItemInternalRef_MACRO
414 # define ArrayListGetCount ArrayListGetCount_MACRO
416 # define ArrayListGetUnsignedChar(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned char)
417 # define ArrayListGetUnsignedShort(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned short)
418 # define ArrayListGetUnsignedInt(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned int)
419 # define ArrayListGetUnsignedLong(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned long)
420 # define ArrayListGetInt64(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Int64_t)
421 # define ArrayListGetChar(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, char)
422 # define ArrayListGetShort(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, short)
423 # define ArrayListGetInt(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, int)
424 # define ArrayListGetLong(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, long)
425 # define ArrayListGetFloat(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, float)
426 # define ArrayListGetDouble(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, double)
427 # define ArrayListGetLgIndex(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, LgIndex_t)
428 # define ArrayListGetEntIndex(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, EntIndex_t)
429 # define ArrayListGetSmInteger(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, SmInteger_t)
430 # define ArrayListGetBoolean(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Boolean_t)
431 # define ArrayListGetArbParam(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, ArbParam_t)
432 # define ArrayListGetUnsignedCharPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned char *)
433 # define ArrayListGetUnsignedShortPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned short *)
434 # define ArrayListGetUnsignedIntPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned int *)
435 # define ArrayListGetUnsignedLongPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned long *)
436 # define ArrayListGetInt64Ptr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Int64_t *)
437 # define ArrayListGetCharPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, char *)
438 # define ArrayListGetShortPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, short *)
439 # define ArrayListGetIntPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, int *)
440 # define ArrayListGetLongPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, long *)
441 # define ArrayListGetFloatPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, float *)
442 # define ArrayListGetDoublePtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, double *)
443 # define ArrayListGetLgIndexPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, LgIndex_t *)
444 # define ArrayListGetEntIndexPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, EntIndex_t *)
445 # define ArrayListGetSmIntegerPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, SmInteger_t *)
446 # define ArrayListGetBooleanPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Boolean_t *)
447 # define ArrayListGetArbParamPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, ArbParam_t *)
448 # define ArrayListGetVoidPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, void *)
449 # define ArrayListGetFunctionPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, (**)(void))
451 # define ArrayListGetInternalRef ArrayListGetInternalRef_FUNC
452 # define ArrayListGetItemInternalRef ArrayListGetItemInternalRef_FUNC
453 # define ArrayListGetCount ArrayListGetCount_FUNC
455 # define ArrayListGetUnsignedChar(ArrayList, ItemOffset) (*((unsigned char *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
456 # define ArrayListGetUnsignedShort(ArrayList, ItemOffset) (*((unsigned short *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
457 # define ArrayListGetUnsignedInt(ArrayList, ItemOffset) (*((unsigned int *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
458 # define ArrayListGetUnsignedLong(ArrayList, ItemOffset) (*((unsigned long *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
459 # define ArrayListGetInt64(ArrayList, ItemOffset) (*((Int64_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
460 # define ArrayListGetChar(ArrayList, ItemOffset) (*((char *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
461 # define ArrayListGetShort(ArrayList, ItemOffset) (*((short *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
462 # define ArrayListGetInt(ArrayList, ItemOffset) (*((int *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
463 # define ArrayListGetLong(ArrayList, ItemOffset) (*((long *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
464 # define ArrayListGetFloat(ArrayList, ItemOffset) (*((float *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
465 # define ArrayListGetDouble(ArrayList, ItemOffset) (*((double *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
466 # define ArrayListGetLgIndex(ArrayList, ItemOffset) (*((LgIndex_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
467 # define ArrayListGetEntIndex(ArrayList, ItemOffset) (*((EntIndex_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
468 # define ArrayListGetSmInteger(ArrayList, ItemOffset) (*((SmInteger_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
469 # define ArrayListGetBoolean(ArrayList, ItemOffset) (*((Boolean_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
470 # define ArrayListGetArbParam(ArrayList, ItemOffset) (*((ArbParam_t *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
471 # define ArrayListGetUnsignedCharPtr(ArrayList, ItemOffset) (*((unsigned char * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
472 # define ArrayListGetUnsignedShortPtr(ArrayList, ItemOffset) (*((unsigned short * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
473 # define ArrayListGetUnsignedIntPtr(ArrayList, ItemOffset) (*((unsigned int * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
474 # define ArrayListGetUnsignedLongPtr(ArrayList, ItemOffset) (*((unsigned long * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
475 # define ArrayListGetInt64Ptr(ArrayList, ItemOffset) (*((Int64_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
476 # define ArrayListGetCharPtr(ArrayList, ItemOffset) (*((char * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
477 # define ArrayListGetShortPtr(ArrayList, ItemOffset) (*((short * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
478 # define ArrayListGetIntPtr(ArrayList, ItemOffset) (*((int * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
479 # define ArrayListGetLongPtr(ArrayList, ItemOffset) (*((long * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
480 # define ArrayListGetFloatPtr(ArrayList, ItemOffset) (*((float * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
481 # define ArrayListGetDoublePtr(ArrayList, ItemOffset) (*((double * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
482 # define ArrayListGetLgIndexPtr(ArrayList, ItemOffset) (*((LgIndex_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
483 # define ArrayListGetEntIndexPtr(ArrayList, ItemOffset) (*((EntIndex_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
484 # define ArrayListGetSmIntegerPtr(ArrayList, ItemOffset) (*((SmInteger_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
485 # define ArrayListGetBooleanPtr(ArrayList, ItemOffset) (*((Boolean_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
486 # define ArrayListGetArbParamPtr(ArrayList, ItemOffset) (*((ArbParam_t * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
487 # define ArrayListGetVoidPtr(ArrayList, ItemOffset) (*((void * *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
488 # define ArrayListGetFunctionPtr(ArrayList, ItemOffset) (*(((**)(void) *)ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset)))
491 #if !defined USE_MACROS_FOR_FUNCTIONS
492 EXTERN
const void *ArrayListGetInternalRef_FUNC(ArrayList_pa ArrayList
);
493 EXTERN
const void *ArrayListGetItemInternalRef_FUNC(ArrayList_pa ArrayList
,
494 LgIndex_t ItemOffset
);
495 EXTERN LgIndex_t
ArrayListGetCount_FUNC(ArrayList_pa ArrayList
);
498 #define ArrayListGetInternalRef_MACRO(ArrayList) ((const void *)((ArrayList)->Array))
499 #define ArrayListGetItemInternalRef_MACRO(ArrayList, ItemOffset) ((const void *)&((ArrayList)->Array[(ItemOffset)*(ArrayList)->ItemSize]))
500 #define ArrayListGetCount_MACRO(ArrayList) ((ArrayList)->Count)
501 #define ArrayListGetTypedArrayRef(ArrayList, NativeType) ((NativeType *)((ArrayList)->Array))
502 #define ArrayListGetTypedItem(ArrayList, ItemOffset, NativeType) (ArrayListGetTypedArrayRef(ArrayList,NativeType)[ItemOffset])
505 * Simple macro to determine if the item offset is within the array list
506 * capacity. In the debug or checked builds we also perform a lower bound
509 #if defined NO_ASSERTS
510 # define ArrayListOffsetWithinCapacity(ArrayList, ItemOffset) ((ItemOffset) < (ArrayList)->Capacity)
513 * Using 'assert' rather than 'REQUIRE' because under Windows, REQUIRE (and ASSERT) trickles down to being a
514 * do-while loop, which doesn't jive well with the comma operator.
516 # define ArrayListOffsetWithinCapacity(ArrayList, ItemOffset) ((assert((ItemOffset) >= 0),TRUE) && ((ItemOffset) < (ArrayList)->Capacity))
520 * Places the item at the specified offset. If the offset is beyond the
521 * end of the list it is sized accordingly and the intervening items
522 * between the last item of the original state and the last item of the
523 * new state are guaranteed to be 0.
525 * This is the workhorse of the set and append convenience macros that follow.
526 * Please note that unlike ArrayListSetItem no destructor facility is provided
527 * therefore if an item previously occupied 'ItemOffset' it will be replaced.
530 * Array list target in which to set the item.
532 * Offset of the item.
534 * Item to set at the specified offset. Its native type must
537 * Native type of 'Item'.
540 * TRUE if sufficient memory permitted the operation, otherwise FALSE.
542 #define ArrayListSetTypedItem(ArrayList, ItemOffset, Item, NativeType) \
543 ((ArrayListOffsetWithinCapacity((ArrayList), (ItemOffset)) || \
544 ArrayListEnlargeCapacity((ArrayList), (ItemOffset)+1)) \
545 ? (((((NativeType *)((ArrayList)->Array))[(ItemOffset)]) = (Item)), \
546 (((ItemOffset)+1 > (ArrayList)->Count) \
547 ? (((ArrayList)->Count = (ItemOffset)+1), TRUE) \
552 * This section provides macros for high speed setting and appending to an
553 * array list of a known type. The only additional overhead incurred versus just
554 * using a simple array is the cost of testing the array list capacity.
556 #define ArrayListSetUnsignedChar(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned char)
557 #define ArrayListSetUnsignedShort(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned short)
558 #define ArrayListSetUnsignedInt(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned int)
559 #define ArrayListSetUnsignedLong(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned long)
560 #define ArrayListSetInt64(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, Int64_t)
561 #define ArrayListSetChar(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, char)
562 #define ArrayListSetShort(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, short)
563 #define ArrayListSetInt(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, int)
564 #define ArrayListSetLong(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, long)
565 #define ArrayListSetFloat(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, float)
566 #define ArrayListSetDouble(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, double)
567 #define ArrayListSetLgIndex(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, LgIndex_t)
568 #define ArrayListSetEntIndex(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, EntIndex_t)
569 #define ArrayListSetSmInteger(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, SmInteger_t)
570 #define ArrayListSetBoolean(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, Boolean_t)
571 #define ArrayListSetArbParam(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, ArbParam_t)
572 #define ArrayListSetUnsignedCharPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned char *)
573 #define ArrayListSetUnsignedShortPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned short *)
574 #define ArrayListSetUnsignedIntPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned int *)
575 #define ArrayListSetUnsignedLongPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, unsigned long *)
576 #define ArrayListSetInt64Ptr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, Int64_t *)
577 #define ArrayListSetCharPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, char *)
578 #define ArrayListSetShortPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, short *)
579 #define ArrayListSetIntPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, int *)
580 #define ArrayListSetLongPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, long *)
581 #define ArrayListSetFloatPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, float *)
582 #define ArrayListSetDoublePtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, double *)
583 #define ArrayListSetLgIndexPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, LgIndex_t *)
584 #define ArrayListSetEntIndexPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, EntIndex_t *)
585 #define ArrayListSetSmIntegerPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, SmInteger_t *)
586 #define ArrayListSetBooleanPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, Boolean_t *)
587 #define ArrayListSetArbParamPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, ArbParam_t *)
588 #define ArrayListSetVoidPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, void *)
589 #define ArrayListSetFunctionPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem(ArrayList, ItemOffset, Item, (**)(void))
591 #define ArrayListAppendUnsignedChar(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned char)
592 #define ArrayListAppendUnsignedShort(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned short)
593 #define ArrayListAppendUnsignedInt(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned int)
594 #define ArrayListAppendUnsignedLong(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned long)
595 #define ArrayListAppendInt64(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, Int64_t)
596 #define ArrayListAppendChar(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, char)
597 #define ArrayListAppendShort(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, short)
598 #define ArrayListAppendInt(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, int)
599 #define ArrayListAppendLong(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, long)
600 #define ArrayListAppendFloat(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, float)
601 #define ArrayListAppendDouble(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, double)
602 #define ArrayListAppendLgIndex(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, LgIndex_t)
603 #define ArrayListAppendEntIndex(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, EntIndex_t)
604 #define ArrayListAppendSmInteger(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, SmInteger_t)
605 #define ArrayListAppendBoolean(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, Boolean_t)
606 #define ArrayListAppendArbParam(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, ArbParam_t)
607 #define ArrayListAppendUnsignedCharPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned char *)
608 #define ArrayListAppendUnsignedShortPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned short *)
609 #define ArrayListAppendUnsignedIntPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned int *)
610 #define ArrayListAppendUnsignedLongPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, unsigned long *)
611 #define ArrayListAppendInt64Ptr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, Int64_t *)
612 #define ArrayListAppendCharPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, char *)
613 #define ArrayListAppendShortPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, short *)
614 #define ArrayListAppendIntPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, int *)
615 #define ArrayListAppendLongPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, long *)
616 #define ArrayListAppendFloatPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, float *)
617 #define ArrayListAppendDoublePtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, double *)
618 #define ArrayListAppendLgIndexPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, LgIndex_t *)
619 #define ArrayListAppendEntIndexPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, EntIndex_t *)
620 #define ArrayListAppendSmIntegerPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, SmInteger_t *)
621 #define ArrayListAppendBooleanPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, Boolean_t *)
622 #define ArrayListAppendArbParamPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, ArbParam_t *)
623 #define ArrayListAppendVoidPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, void *)
624 #define ArrayListAppendFunctionPtr(ArrayList, Item) ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, (**)(void))
626 #endif /* ARRLIST_h */