1 #include "stdafx.h" 2 #include "MASTER.h" 3 /* 4 ***************************************************************** 5 ***************************************************************** 6 ******* ******** 7 ****** Copyright (C) 1988-2010 Tecplot, Inc. ******* 8 ******* ******** 9 ***************************************************************** 10 ***************************************************************** 11 */ 12 #if !defined ARRLIST_h 13 #define ARRLIST_h 14 15 #if defined EXTERN 16 # undef EXTERN 17 #endif 18 #if defined ARRLISTMODULE 19 # define EXTERN 20 #else 21 # define EXTERN extern 22 #endif 23 24 #if !defined TECPLOTKERNEL 25 typedef struct _ArrayList_s* ArrayList_pa; 26 #endif 27 28 typedef enum 29 { 30 ArrayListType_UnsignedChar, 31 ArrayListType_UnsignedShort, 32 ArrayListType_UnsignedInt, 33 ArrayListType_UnsignedLong, 34 ArrayListType_Int64, 35 ArrayListType_Char, 36 ArrayListType_Short, 37 ArrayListType_Int, 38 ArrayListType_Long, 39 ArrayListType_Float, 40 ArrayListType_Double, 41 ArrayListType_LgIndex, 42 ArrayListType_EntIndex, 43 ArrayListType_SmInteger, 44 ArrayListType_Boolean, 45 ArrayListType_ArbParam, 46 ArrayListType_UnsignedCharPtr, 47 ArrayListType_UnsignedShortPtr, 48 ArrayListType_UnsignedIntPtr, 49 ArrayListType_UnsignedLongPtr, 50 ArrayListType_Int64Ptr, 51 ArrayListType_CharPtr, 52 ArrayListType_ShortPtr, 53 ArrayListType_IntPtr, 54 ArrayListType_LongPtr, 55 ArrayListType_FloatPtr, 56 ArrayListType_DoublePtr, 57 ArrayListType_LgIndexPtr, 58 ArrayListType_EntIndexPtr, 59 ArrayListType_SmIntegerPtr, 60 ArrayListType_BooleanPtr, 61 ArrayListType_ArbParamPtr, 62 ArrayListType_VoidPtr, 63 ArrayListType_FunctionPtr, 64 ArrayListType_Any, 65 END_ArrayListType_e, 66 ArrayListType_Invalid = BadEnumValue 67 } ArrayListType_e; 68 69 typedef union 70 { 71 unsigned char UnsignedChar; 72 unsigned short UnsignedShort; 73 unsigned int UnsignedInt; 74 unsigned long UnsignedLong; 75 Int64_t Int64; 76 char Char; 77 short Short; 78 int Int; 79 long Long; 80 float Float; 81 double Double; 82 LgIndex_t LgIndex; 83 EntIndex_t EntIndex; 84 SmInteger_t SmInteger; 85 Boolean_t BBoolean; /* X-Windows uses Boolean */ 86 ArbParam_t ArbParam; 87 unsigned char* UnsignedCharPtr; 88 unsigned short* UnsignedShortPtr; 89 unsigned int* UnsignedIntPtr; 90 unsigned long* UnsignedLongPtr; 91 Int64_t* Int64Ptr; 92 char* CharPtr; 93 short* ShortPtr; 94 int* IntPtr; 95 long* LongPtr; 96 float* FloatPtr; 97 double* DoublePtr; 98 LgIndex_t* LgIndexPtr; 99 EntIndex_t* EntIndexPtr; 100 SmInteger_t* SmIntegerPtr; 101 Boolean_t* BooleanPtr; 102 ArbParam_t* ArbParamPtr; 103 void* VoidPtr; 104 void (*FunctionPtr)(void); 105 } ArrayListItem_u; 106 107 #if defined TECPLOTKERNEL 108 /* CORE SOURCE CODE REMOVED */ 109 #endif 110 111 /** 112 * Visitor for traversing an array list. An iterator may not perform any 113 * operation that will adjust the size of the list. In other words it may not 114 * insert or delete items from the list. However an iterator may perform a get 115 * operation or a set operation that do not expand the list size. 116 * 117 * param ItemRef 118 * Reference to the array list item visited. 119 * param ClientData 120 * Any client data required for the visitor. 121 * 122 * return 123 * TRUE to continue visiting items, otherwise 124 * FALSE to discontinue visiting 125 */ 126 typedef Boolean_t (*ArrayListItemVisitor_pf)(void* ItemRef, 127 ArbParam_t ClientData); 128 #if 0 /* use this stub as a starting place */ 129 { 130 REQUIRE(VALID_REF(TypeRef)); 131 REQUIRE(VALID_REF(*TypeRef) || *TypeRef == NULL); 132 133 Boolean_t DoContinue = TRUE; 134 <type>* TypeRef = static_cast<<type>*>(ItemRef); 135 136 ENSURE(VALID_BOOLEAN(DoContinue)); 137 return DoContinue; 138 } 139 #endif 140 141 142 /** 143 * Destructor for cleaning up one or more array list items. If a destructor is 144 * not supplied then the array items are simply discarded. 145 * 146 * NOTE: The only change to ArrayListItemVisitor_pf is the policy which 147 * requires that the return value is TRUE. 148 * 149 * param ItemRef 150 * Reference to the array list item to cleanup. 151 * param ClientData 152 * Any client data required for cleanup. 153 * 154 * return 155 * TRUE is a requirement 156 */ 157 typedef ArrayListItemVisitor_pf ArrayListItemDestructor_pf; 158 159 160 /** 161 * Duplicator for copying one or more array list items. If a duplicator is not 162 * supplied then the array items are simply copied. For pointer types this 163 * means by reference. Note that if a duplicator is used the rules for 164 * duplication and subsequent cleanup are defined by the client. 165 * 166 * param TargetItemRef 167 * Reference to the array list to receive the duplicate. 168 * param SourceItemRef 169 * Reference to the array list item to duplicate. 170 * param ClientData 171 * Any client data required for duplication. 172 * 173 * return 174 * TRUE if the duplication was a success 175 * FALSE otherwise. If the duplication failed it 176 * is the client's responsibility to cleanup any 177 * partial duplication 178 */ 179 typedef Boolean_t (*ArrayListItemDuplicator_pf)(void* TargetItemRef, 180 void* SourceItemRef, 181 ArbParam_t ClientData); 182 #if 0 /* use this stub as a starting place */ 183 { 184 REQUIRE(VALID_REF(TargetTypeRef)); 185 REQUIRE(VALID_REF(SourceTypeRef)); 186 REQUIRE(VALID_REF(*SourceTypeRef) || *SourceTypeRef == NULL); 187 188 Boolean_t IsOk = TRUE; 189 <type>* TargetTypeRef = static_cast<<type>*>(TargetItemRef); 190 <type>* SourceTypeRef = static_cast<<type>*>(SourceItemRef); 191 192 ENSURE(VALID_BOOLEAN(IsOk)); 193 return IsOk; 194 } 195 #endif 196 197 198 /** 199 * Adjusts the capacity request as necessary to minimize memory reallocations 200 * for large lists. Unless the request exceeds the maximum the adjusted 201 * capacity will be at least as big as requested however it may be larger if it 202 * is determined that the space requirement is growing faster. If the maximum 203 * is exceeded zero should be returned. 204 * 205 * param ArrayList 206 * Array list requesting the change in capacity. 207 * param CurrentCapacity 208 * Current capacity of the array list. 209 * param RequestedCapacity 210 * Capacity request or zero for default size. 211 * param ClientData 212 * Any client data needed for the adjustment. 213 * 214 * return 215 * Adjusted capacity that is at least as large as the request or zero if 216 * unable to satisfy the requested capacity. 217 */ 218 typedef LgIndex_t (*ArrayListCapacityRequestAdjuster_pf)(ArrayList_pa ArrayList, 219 LgIndex_t CurrentCapacity, 220 LgIndex_t RequestedCapacity, 221 ArbParam_t ClientData); 222 #if 0 /* use this stub as a starting place */ 223 { 224 REQUIRE(ArrayListIsValid(ArrayList)); 225 REQUIRE((RequestedCapacity == 0 && CurrentCapacity == 0) || 226 RequestedCapacity > ArrayList->Capacity); 227 228 LgIndex_t Result; 229 230 ENSURE(Result == 0 || Result >= RequestedCapacity); 231 return Result; 232 } 233 #endif 234 235 236 /* private ArrayList structure: only exposed so STRUTIL can use it */ 237 typedef struct _ArrayList_s 238 { 239 char* Array; /* byte array for holding the items */ 240 ArrayListType_e Type; /* type of array items */ 241 SmInteger_t ItemSize; /* byte size of an individual item */ 242 LgIndex_t Count; /* number of items in the array */ 243 LgIndex_t Capacity; /* maximum holding capacity of the array */ 244 Boolean_t IsVisitingItems; /* indicates if an iteration is in progress */ 245 ArrayListCapacityRequestAdjuster_pf CapacityRequestAdjuster; 246 ArbParam_t CapacityRequestAdjusterClientData; 247 } ArrayList_s; 248 249 250 /** 251 * Compares two array list elements. Note that either string may be 252 * NULL as array lists allow for NULL elements. 253 * 254 * @param Item1 255 * Element to compare against Item2. 256 * @param Item2 257 * Element to compare against Item1. 258 * @param ClientData 259 * Contextual information that was passed to the 'ArrayListQSort' function. 260 * 261 * @return 262 * - A value less than zero if Item1 is less than Item2. 263 * - A value of zero if Item1 is equal to Item2. 264 * - A value greater than zero if Item1 is greater than Item2. 265 */ 266 typedef int (STDCALL *ArrayListItemComparator_pf)(ArrayListItem_u Item1, 267 ArrayListItem_u Item2, 268 ArbParam_t ClientData); 269 270 EXTERN Boolean_t ArrayListIsValid(ArrayList_pa ArrayList); 271 EXTERN ArrayListType_e ArrayListGetType(ArrayList_pa ArrayList); 272 EXTERN Boolean_t ArrayListEnlargeCapacity(ArrayList_pa ArrayList, 273 LgIndex_t RequestedCapacity); 274 EXTERN ArrayList_pa ArrayListAlloc(LgIndex_t EstimatedCapacity, 275 ArrayListType_e Type, 276 ArrayListCapacityRequestAdjuster_pf CapacityRequestAdjuster = 0, 277 ArbParam_t CapacityRequestAdjusterClientData = 0); 278 EXTERN void ArrayListDealloc(ArrayList_pa* ArrayList, 279 ArrayListItemDestructor_pf ItemDestructor = 0, 280 ArbParam_t ClientData = 0); 281 EXTERN void ArrayListClear(ArrayList_pa ArrayList); 282 EXTERN void ArrayListDeleteAllItems(ArrayList_pa ArrayList, 283 ArrayListItemDestructor_pf ItemDestructor = 0, 284 ArbParam_t ClientData = 0); 285 EXTERN void ArrayListDeleteItems(ArrayList_pa ArrayList, 286 LgIndex_t ItemOffset, 287 LgIndex_t Count, 288 ArrayListItemDestructor_pf ItemDestructor = 0, 289 ArbParam_t ClientData = 0); 290 EXTERN void ArrayListDeleteItem(ArrayList_pa ArrayList, 291 LgIndex_t ItemOffset, 292 ArrayListItemDestructor_pf ItemDestructor = 0, 293 ArbParam_t ClientData = 0); 294 EXTERN ArrayList_pa ArrayListRemoveItems(ArrayList_pa ArrayList, 295 LgIndex_t ItemOffset, 296 LgIndex_t Count); 297 EXTERN ArrayListItem_u ArrayListRemoveItem(ArrayList_pa ArrayList, 298 LgIndex_t ItemOffset); 299 EXTERN Boolean_t ArrayListInsertItem(ArrayList_pa ArrayList, 300 LgIndex_t ItemOffset, 301 ArrayListItem_u Item); 302 EXTERN Boolean_t ArrayListInsert(ArrayList_pa Target, 303 LgIndex_t ItemOffset, 304 ArrayList_pa Source); 305 EXTERN Boolean_t ArrayListVisitItems(ArrayList_pa ArrayList, 306 LgIndex_t ItemOffset, 307 LgIndex_t Count, 308 ArrayListItemVisitor_pf ItemVisitor, 309 ArbParam_t ClientData); 310 EXTERN ArrayList_pa ArrayListGetItems(ArrayList_pa ArrayList, 311 LgIndex_t ItemOffset, 312 LgIndex_t Count); 313 EXTERN ArrayListItem_u ArrayListGetItem(ArrayList_pa ArrayList, 314 LgIndex_t ItemOffset); 315 EXTERN Boolean_t ArrayListSetItem(ArrayList_pa ArrayList, 316 LgIndex_t ItemOffset, 317 ArrayListItem_u Item, 318 ArrayListItemDestructor_pf ItemDestructor = 0, 319 ArbParam_t ClientData = 0); 320 EXTERN Boolean_t ArrayListAppendItem(ArrayList_pa ArrayList, 321 ArrayListItem_u Item); 322 EXTERN Boolean_t ArrayListAppend(ArrayList_pa Target, 323 ArrayList_pa Source); 324 EXTERN ArrayList_pa ArrayListCopy(ArrayList_pa ArrayList, 325 ArrayListItemDuplicator_pf ItemDuplicator = 0, 326 ArbParam_t ClientData = 0); 327 EXTERN void* ArrayListToArray(ArrayList_pa ArrayList, 328 ArrayListItemDuplicator_pf ItemDuplicator, 329 ArbParam_t ClientData); 330 EXTERN ArrayList_pa ArrayListFromArray(void* Source, 331 LgIndex_t Count, 332 ArrayListType_e Type, 333 ArrayListItemDuplicator_pf ItemDuplicator = 0, 334 ArbParam_t ClientData = 0); 335 336 #if defined TECPLOTKERNEL 337 /* CORE SOURCE CODE REMOVED */ 338 #endif 339 EXTERN Boolean_t ArrayListBSearch(ArrayList_pa ArrayList, 340 ArrayListItem_u Item, 341 ArrayListItemComparator_pf Comparator, 342 ArbParam_t ClientData, 343 LgIndex_t* ItemIndex = 0); 344 345 #if defined USE_MACROS_FOR_FUNCTIONS 346 /** 347 * Gets the array list's internal buffer representation. 348 * Use ArrayListGetXxx accessors whenever possible as their 349 * implementation in the release build is as fast as using 350 * the array directly anyway. 351 * 352 * WARNING: 353 * Some array list functions modify the internal buffer. 354 * This will invalidate this reference however it is 355 * the client's responsibility not to make further use 356 * of it. In addition, this reference should never be 357 * deallocated directly as the array list assumes the 358 * responsible for the cleanup. 359 * 360 * param ArrayList 361 * Array list for which a reference to the internal 362 * buffer is desired. 363 * 364 * return 365 * Reference to the array list's internal buffer. 366 */ 367 # define ArrayListGetInternalRef ArrayListGetInternalRef_MACRO 368 /** 369 * Gets the item's internal reference at the specified offset in the list. 370 * 371 * WARNING: 372 * Some array list functions modify the internal buffer. 373 * This will invalidate this reference however it is 374 * the client's responsibility not to make further use 375 * of it. In addition, this reference should never be 376 * deallocated directly as the array list assumes the 377 * responsible for the cleanup. 378 * 379 * param ArrayList 380 * Array list containing the desired item. 381 * param ItemOffset 382 * Offset to the item in the list. 383 * 384 * return 385 * The internal reference to the requested item. 386 */ 387 # define ArrayListGetItemInternalRef ArrayListGetItemInternalRef_MACRO 388 # define ArrayListGetCount ArrayListGetCount_MACRO 389 390 # define ArrayListGetUnsignedChar(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned char) 391 # define ArrayListGetUnsignedShort(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned short) 392 # define ArrayListGetUnsignedInt(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned int) 393 # define ArrayListGetUnsignedLong(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned long) 394 # define ArrayListGetInt64(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Int64_t) 395 # define ArrayListGetChar(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, char) 396 # define ArrayListGetShort(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, short) 397 # define ArrayListGetInt(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, int) 398 # define ArrayListGetLong(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, long) 399 # define ArrayListGetFloat(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, float) 400 # define ArrayListGetDouble(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, double) 401 # define ArrayListGetLgIndex(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, LgIndex_t) 402 # define ArrayListGetEntIndex(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, EntIndex_t) 403 # define ArrayListGetSmInteger(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, SmInteger_t) 404 # define ArrayListGetBoolean(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Boolean_t) 405 # define ArrayListGetArbParam(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, ArbParam_t) 406 # define ArrayListGetUnsignedCharPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned char*) 407 # define ArrayListGetUnsignedShortPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned short*) 408 # define ArrayListGetUnsignedIntPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned int*) 409 # define ArrayListGetUnsignedLongPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, unsigned long*) 410 # define ArrayListGetInt64Ptr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Int64_t*) 411 # define ArrayListGetCharPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, char*) 412 # define ArrayListGetShortPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, short*) 413 # define ArrayListGetIntPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, int*) 414 # define ArrayListGetLongPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, long*) 415 # define ArrayListGetFloatPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, float*) 416 # define ArrayListGetDoublePtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, double*) 417 # define ArrayListGetLgIndexPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, LgIndex_t*) 418 # define ArrayListGetEntIndexPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, EntIndex_t*) 419 # define ArrayListGetSmIntegerPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, SmInteger_t*) 420 # define ArrayListGetBooleanPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, Boolean_t*) 421 # define ArrayListGetArbParamPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, ArbParam_t*) 422 # define ArrayListGetVoidPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, void*) 423 # define ArrayListGetFunctionPtr(ArrayList, ItemOffset) ArrayListGetTypedItem(ArrayList, ItemOffset, (**)(void)) 424 #else 425 # define ArrayListGetInternalRef ArrayListGetInternalRef_FUNC 426 # define ArrayListGetItemInternalRef ArrayListGetItemInternalRef_FUNC 427 # define ArrayListGetCount ArrayListGetCount_FUNC 428 429 # define ArrayListGetUnsignedChar(ArrayList, ItemOffset) (*(static_cast<unsigned char*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 430 # define ArrayListGetUnsignedShort(ArrayList, ItemOffset) (*(static_cast<unsigned short*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 431 # define ArrayListGetUnsignedInt(ArrayList, ItemOffset) (*(static_cast<unsigned int*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 432 # define ArrayListGetUnsignedLong(ArrayList, ItemOffset) (*(static_cast<unsigned long*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 433 # define ArrayListGetInt64(ArrayList, ItemOffset) (*(static_cast<Int64_t*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 434 # define ArrayListGetChar(ArrayList, ItemOffset) (*(static_cast<char*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 435 # define ArrayListGetShort(ArrayList, ItemOffset) (*(static_cast<short*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 436 # define ArrayListGetInt(ArrayList, ItemOffset) (*(static_cast<int*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 437 # define ArrayListGetLong(ArrayList, ItemOffset) (*(static_cast<long*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 438 # define ArrayListGetFloat(ArrayList, ItemOffset) (*(static_cast<float*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 439 # define ArrayListGetDouble(ArrayList, ItemOffset) (*(static_cast<double*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 440 # define ArrayListGetLgIndex(ArrayList, ItemOffset) (*(static_cast<LgIndex_t*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 441 # define ArrayListGetEntIndex(ArrayList, ItemOffset) (*(static_cast<EntIndex_t*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 442 # define ArrayListGetSmInteger(ArrayList, ItemOffset) (*(static_cast<SmInteger_t*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 443 # define ArrayListGetBoolean(ArrayList, ItemOffset) (*(static_cast<Boolean_t*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 444 # define ArrayListGetArbParam(ArrayList, ItemOffset) (*(static_cast<ArbParam_t*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 445 # define ArrayListGetUnsignedCharPtr(ArrayList, ItemOffset) (*(static_cast<unsigned char**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 446 # define ArrayListGetUnsignedShortPtr(ArrayList, ItemOffset) (*(static_cast<unsigned short**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 447 # define ArrayListGetUnsignedIntPtr(ArrayList, ItemOffset) (*(static_cast<unsigned int**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 448 # define ArrayListGetUnsignedLongPtr(ArrayList, ItemOffset) (*(static_cast<unsigned long**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 449 # define ArrayListGetInt64Ptr(ArrayList, ItemOffset) (*(static_cast<Int64_t**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 450 # define ArrayListGetCharPtr(ArrayList, ItemOffset) (*(static_cast<char**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 451 # define ArrayListGetShortPtr(ArrayList, ItemOffset) (*(static_cast<short**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 452 # define ArrayListGetIntPtr(ArrayList, ItemOffset) (*(static_cast<int**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 453 # define ArrayListGetLongPtr(ArrayList, ItemOffset) (*(static_cast<long**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 454 # define ArrayListGetFloatPtr(ArrayList, ItemOffset) (*(static_cast<float**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 455 # define ArrayListGetDoublePtr(ArrayList, ItemOffset) (*(static_cast<double**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 456 # define ArrayListGetLgIndexPtr(ArrayList, ItemOffset) (*(static_cast<LgIndex_t**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 457 # define ArrayListGetEntIndexPtr(ArrayList, ItemOffset) (*(static_cast<EntIndex_t**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 458 # define ArrayListGetSmIntegerPtr(ArrayList, ItemOffset) (*(static_cast<SmInteger_t**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 459 # define ArrayListGetBooleanPtr(ArrayList, ItemOffset) (*(static_cast<Boolean_t**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 460 # define ArrayListGetArbParamPtr(ArrayList, ItemOffset) (*(static_cast<ArbParam_t**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 461 # define ArrayListGetVoidPtr(ArrayList, ItemOffset) (*(static_cast<void**>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 462 # define ArrayListGetFunctionPtr(ArrayList, ItemOffset) (*(static_cast<**(void)*>(const_cast<void*>(ArrayListGetItemInternalRef_FUNC(ArrayList, ItemOffset))))) 463 #endif 464 465 #if !defined USE_MACROS_FOR_FUNCTIONS 466 EXTERN void const* ArrayListGetInternalRef_FUNC(ArrayList_pa ArrayList); 467 EXTERN void const* ArrayListGetItemInternalRef_FUNC(ArrayList_pa ArrayList, 468 LgIndex_t ItemOffset); 469 EXTERN LgIndex_t ArrayListGetCount_FUNC(ArrayList_pa ArrayList); 470 #endif 471 472 #define ArrayListGetInternalRef_MACRO(ArrayList) static_cast<void const*>((ArrayList)->Array) 473 #define ArrayListGetItemInternalRef_MACRO(ArrayList, ItemOffset) static_cast<void const*>(&((ArrayList)->Array[(ItemOffset)*(ArrayList)->ItemSize])) 474 #define ArrayListGetCount_MACRO(ArrayList) ((ArrayList)->Count) 475 #define ArrayListGetTypedArrayRef(ArrayList, NativeType) reinterpret_cast<NativeType*>((ArrayList)->Array) 476 #define ArrayListGetTypedItem(ArrayList, ItemOffset, NativeType) (ArrayListGetTypedArrayRef(ArrayList,NativeType)[ItemOffset]) 477 478 /** 479 * Simple macro to determine if the item offset is within the array list 480 * capacity. In the debug or checked builds we also perform a lower bound 481 * assertion check. 482 */ 483 #if defined NO_ASSERTS 484 # define ArrayListOffsetWithinCapacity(ArrayList, ItemOffset) ((ItemOffset) < (ArrayList)->Capacity) 485 #else 486 /** 487 * Using 'assert' rather than 'REQUIRE' because under Windows, REQUIRE (and ASSERT) trickles down to being a 488 * do-while loop, which doesn't jive well with the comma operator. 489 */ 490 # define ArrayListOffsetWithinCapacity(ArrayList, ItemOffset) ((assert((ItemOffset) >= 0),TRUE) && ((ItemOffset) < (ArrayList)->Capacity)) 491 #endif 492 493 /** 494 * Places the item at the specified offset. If the offset is beyond the 495 * end of the list it is sized accordingly and the intervening items 496 * between the last item of the original state and the last item of the 497 * new state are guaranteed to be 0. 498 * 499 * This is the workhorse of the set and append convenience macros that follow. 500 * Please note that unlike ArrayListSetItem no destructor facility is provided 501 * therefore if an item previously occupied 'ItemOffset' it will be replaced. 502 * 503 * param ArrayList 504 * Array list target in which to set the item. 505 * param ItemOffset 506 * Offset of the item. 507 * param Item 508 * Item to set at the specified offset. Its native type must 509 * match 'NativeType' 510 * param NativeType 511 * Native type of 'Item'. 512 * 513 * return 514 * TRUE if sufficient memory permitted the operation, otherwise FALSE. 515 */ 516 #define ArrayListSetTypedItem(ArrayList, ItemOffset, Item, NativeType) \ 517 ((ArrayListOffsetWithinCapacity((ArrayList), (ItemOffset)) || \ 518 ArrayListEnlargeCapacity((ArrayList), (ItemOffset)+1)) \ 519 ? ((void)((ArrayListGetTypedArrayRef((ArrayList),NativeType)[(ItemOffset)]) = (Item)), \ 520 (((ItemOffset)+1 > (ArrayList)->Count) \ 521 ? (((ArrayList)->Count = (ItemOffset)+1), TRUE) \ 522 : (TRUE))) \ 523 : (FALSE)) 524 525 /** 526 * Appends the item to the end of the list. This is similar to ArrayListSetTypedItem however it 527 * needs not perform a bounds check which is always one beyond the end. This macro was added 528 * primarily to remove compiler warnings caused by a comparison of the array list ArrayList->Count+1 529 * always returning true when tested if larger than ArrayList->Count which occurs if you use the 530 * ArrayListSetTypedItem as ArrayListSetTypedItem(ArrayList, (ArrayList)->Count, Item, NativeType). 531 * 532 * This is the workhorse of the append convenience macros that follow. 533 * 534 * param ArrayList 535 * Array list target in which to set the item. 536 * param Item 537 * Item to append to the end of the array. Its native type must 538 * match 'NativeType' 539 * param NativeType 540 * Native type of 'Item'. 541 * 542 * return 543 * TRUE if sufficient memory permitted the operation, otherwise FALSE. 544 */ 545 #define ArrayListAppendTypedItem(ArrayList, Item, NativeType) \ 546 ((ArrayListOffsetWithinCapacity((ArrayList), (ArrayList)->Count) || \ 547 ArrayListEnlargeCapacity((ArrayList), (ArrayList)->Count+1)) \ 548 ? ((void)((ArrayListGetTypedArrayRef((ArrayList),NativeType)[(ArrayList)->Count]) = (Item)), \ 549 (((ArrayList)->Count = (ArrayList)->Count+1), TRUE)) \ 550 : (FALSE)) 551 552 /** 553 * This section provides macros for high speed setting and appending to an 554 * array list of a known type. The only additional overhead incurred versus just 555 * using a simple array is the cost of testing the array list capacity. 556 */ 557 #define ArrayListSetUnsignedChar(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),unsigned char) 558 #define ArrayListSetUnsignedShort(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),unsigned short) 559 #define ArrayListSetUnsignedInt(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),unsigned int) 560 #define ArrayListSetUnsignedLong(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),unsigned long) 561 #define ArrayListSetInt64(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),Int64_t) 562 #define ArrayListSetChar(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),char) 563 #define ArrayListSetShort(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),short) 564 #define ArrayListSetInt(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),int) 565 #define ArrayListSetLong(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),long) 566 #define ArrayListSetFloat(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),float) 567 #define ArrayListSetDouble(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),double) 568 #define ArrayListSetLgIndex(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),LgIndex_t) 569 #define ArrayListSetEntIndex(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),EntIndex_t) 570 #define ArrayListSetSmInteger(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),SmInteger_t) 571 #define ArrayListSetBoolean(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),Boolean_t) 572 #define ArrayListSetArbParam(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),ArbParam_t) 573 #define ArrayListSetUnsignedCharPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),unsigned char*) 574 #define ArrayListSetUnsignedShortPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),unsigned short*) 575 #define ArrayListSetUnsignedIntPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),unsigned int*) 576 #define ArrayListSetUnsignedLongPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),unsigned long*) 577 #define ArrayListSetInt64Ptr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),Int64_t*) 578 #define ArrayListSetCharPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),char*) 579 #define ArrayListSetShortPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),short*) 580 #define ArrayListSetIntPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),int*) 581 #define ArrayListSetLongPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),long*) 582 #define ArrayListSetFloatPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),float*) 583 #define ArrayListSetDoublePtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),double*) 584 #define ArrayListSetLgIndexPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),LgIndex_t*) 585 #define ArrayListSetEntIndexPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),EntIndex_t*) 586 #define ArrayListSetSmIntegerPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),SmInteger_t*) 587 #define ArrayListSetBooleanPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),Boolean_t*) 588 #define ArrayListSetArbParamPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),ArbParam_t*) 589 #define ArrayListSetVoidPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),void*) 590 #define ArrayListSetFunctionPtr(ArrayList, ItemOffset, Item) ArrayListSetTypedItem((ArrayList),(ItemOffset),(Item),(**)(void)) 591 592 #define ArrayListAppendUnsignedChar(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),unsigned char) 593 #define ArrayListAppendUnsignedShort(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),unsigned short) 594 #define ArrayListAppendUnsignedInt(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),unsigned int) 595 #define ArrayListAppendUnsignedLong(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),unsigned long) 596 #define ArrayListAppendInt64(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),Int64_t) 597 #define ArrayListAppendChar(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),char) 598 #define ArrayListAppendShort(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),short) 599 #define ArrayListAppendInt(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),int) 600 #define ArrayListAppendLong(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),long) 601 #define ArrayListAppendFloat(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),float) 602 #define ArrayListAppendDouble(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),double) 603 #define ArrayListAppendLgIndex(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),LgIndex_t) 604 #define ArrayListAppendEntIndex(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),EntIndex_t) 605 #define ArrayListAppendSmInteger(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),SmInteger_t) 606 #define ArrayListAppendBoolean(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),Boolean_t) 607 #define ArrayListAppendArbParam(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),ArbParam_t) 608 #define ArrayListAppendUnsignedCharPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),unsigned char*) 609 #define ArrayListAppendUnsignedShortPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),unsigned short*) 610 #define ArrayListAppendUnsignedIntPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),unsigned int*) 611 #define ArrayListAppendUnsignedLongPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),unsigned long*) 612 #define ArrayListAppendInt64Ptr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),Int64_t*) 613 #define ArrayListAppendCharPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),char*) 614 #define ArrayListAppendShortPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),short*) 615 #define ArrayListAppendIntPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),int*) 616 #define ArrayListAppendLongPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),long*) 617 #define ArrayListAppendFloatPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),float*) 618 #define ArrayListAppendDoublePtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),double*) 619 #define ArrayListAppendLgIndexPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),LgIndex_t*) 620 #define ArrayListAppendEntIndexPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),EntIndex_t*) 621 #define ArrayListAppendSmIntegerPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),SmInteger_t*) 622 #define ArrayListAppendBooleanPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),Boolean_t*) 623 #define ArrayListAppendArbParamPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),ArbParam_t*) 624 #define ArrayListAppendVoidPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),void*) 625 #define ArrayListAppendFunctionPtr(ArrayList, Item) ArrayListAppendTypedItem((ArrayList),(Item),(**)(void)) 626 627 #endif /* ARRLIST_h */ 628