foam to Tecplot360 converter
[OpenFOAM-1.6.x.git] / applications / utilities / postProcessing / dataConversion / foamToTecplot360 / tecio / tecsrc / auxdata.cpp
blobc42b2220461b2fea7dc6c5d7aa44ae16be239684
1 /*
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.
17 * Tecplot, Inc.
18 * 3535 Factoria Blvd, Ste. 550
19 * Bellevue, WA 98006, USA
20 * Phone: +1 425 653 1200
21 * http://www.tecplot.com/
24 #include "stdafx.h"
25 #include "MASTER.h"
26 #define TECPLOTENGINEMODULE
29 *****************************************************************
30 *****************************************************************
31 ******* ********
32 ****** Copyright (C) 1988-2008 Tecplot, Inc. ********
33 ******* All Rights Reserved. ********
34 ******* ********
35 *****************************************************************
36 *****************************************************************
39 #define AUXDATAMODULE
40 #include "GLOBAL.h"
41 #include "TASSERT.h"
42 #include "Q_UNICODE.h"
43 #include "ALLOC.h"
44 #include "STRUTIL.h"
45 #include "ARRLIST.h"
46 #include "DATASET.h"
47 #include "STRLIST.h"
48 #if defined TECPLOTKERNEL
49 /* CORE SOURCE CODE REMOVED */
50 #endif
51 #include "SET.h"
52 #include "AUXDATA.h"
54 using namespace tecplot::strutil;
56 /**
57 * Private auxiliary data item structure.
59 typedef struct
61 const char *Name;
62 ArbParam_t Value;
63 AuxDataType_e Type;
64 Boolean_t Retain;
65 } AuxDataItem_s;
67 /**
68 * Private auxiliary data item container structure.
70 typedef struct _AuxData_s
72 /* invariant: ItemList is case-insensitive sorted by AuxDataItem->Name */
73 ArrayList_pa ItemList; /* <AuxDataItem_s *>[dynamic] */
74 } AuxData_s;
76 static Mutex_pa AuxDataMutex = NULL;
79 /**
80 * A valid auxiliary data name character must begin with a '_' or alpha
81 * character and may be followed by one or more '_', '.', alpha or digit
82 * characters.
84 Boolean_t AuxDataIsValidNameChar(char Char,
85 Boolean_t IsLeadChar)
87 Boolean_t IsValidNameChar;
89 REQUIRE("Char can be any value");
90 REQUIRE(VALID_BOOLEAN(IsLeadChar));
92 IsValidNameChar = (Char == '_' ||
93 isalpha(Char));
94 if (!IsLeadChar)
95 IsValidNameChar = (IsValidNameChar ||
96 Char == '.' ||
97 isdigit(Char));
99 ENSURE(VALID_BOOLEAN(IsValidNameChar));
100 return IsValidNameChar;
104 * Indicates if the auxiliary data name is valid. A valid auxiliary data name
105 * must begin with a '_' or alpha character and may be followed by one or
106 * more '_', '.', alpha or digit characters.
108 Boolean_t AuxDataIsValidName(const char *Name)
110 Boolean_t IsValidName;
111 const char *NPtr;
112 REQUIRE(VALID_REF(Name));
114 for (NPtr = Name, IsValidName = AuxDataIsValidNameChar(*NPtr, TRUE);
115 IsValidName && *NPtr != '\0';
116 NPtr++)
118 IsValidName = AuxDataIsValidNameChar(*NPtr, FALSE);
121 ENSURE(VALID_BOOLEAN(IsValidName));
122 return IsValidName;
126 * Deallocates an auxiliary data item and its contents and sets the target to
127 * NULL.
129 * param AuxDataItem
130 * Reference to an auxiliary data item.
132 static void AuxDataItemDealloc(AuxDataItem_s **AuxDataItem)
134 REQUIRE(VALID_REF(AuxDataItem));
135 REQUIRE(VALID_REF(*AuxDataItem) || *AuxDataItem == NULL);
137 if (*AuxDataItem != NULL)
139 char *Name = (char *)(*AuxDataItem)->Name;
140 if (Name != NULL)
141 FREE_ARRAY(Name, "auxiliary name");
143 if ((*AuxDataItem)->Type == AuxDataType_String)
145 char *Value = (char *)(*AuxDataItem)->Value;
146 if (Value != NULL)
147 FREE_ARRAY(Value, "auxiliary value");
149 else
150 CHECK(FALSE);
152 FREE_ITEM(*AuxDataItem, "auxiliary data item");
153 *AuxDataItem = NULL;
156 ENSURE(*AuxDataItem == NULL);
160 * Allocates an auxiliary data item.
162 * NOTE: Copies are made of the name and value.
164 * param Name
165 * Auxiliary data item's name (case insenstive).
166 * param Value
167 * Auxiliary data item's value.
168 * param Type
169 * Auxiliary data item's value type.
170 * param Retain
171 * Indicates if the auxiliary data item should persist. In other words
172 * copied, saved, etc.
174 * return
175 * A new auxiliary data item or NULL if sufficient memory was not
176 * available.
178 static AuxDataItem_s *AuxDataItemAlloc(const char *Name,
179 ArbParam_t Value,
180 AuxDataType_e Type,
181 Boolean_t Retain)
183 AuxDataItem_s *Result;
185 REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name));
186 REQUIRE(IMPLICATION(Type == AuxDataType_String,
187 (VALID_REF((char *)Value) ||
188 (char *)Value == NULL)));
189 REQUIRE(VALID_ENUM(Type, AuxDataType_e));
190 REQUIRE(VALID_BOOLEAN(Retain));
192 Result = ALLOC_ITEM(AuxDataItem_s, "auxiliary data item");
193 if (Result != NULL)
195 Boolean_t IsOk;
196 Result->Type = Type;
197 Result->Retain = Retain;
198 Result->Name = DupString(dontTranslate(Name));
199 IsOk = (Result->Name != NULL);
200 Result->Value = 0; /* to satisfy some compilers' uninitialized warnings */
201 if (IsOk && Type == AuxDataType_String)
203 char *strValue = (char *)Value;
204 if (strValue != NULL)
206 char *strCopy = DupString(dontTranslate(strValue));
207 Result->Value = (ArbParam_t)strCopy;
208 IsOk = (strCopy != NULL);
210 else
211 Result->Value = (ArbParam_t)NULL;
213 else
214 CHECK(FALSE);
216 if (!IsOk)
217 AuxDataItemDealloc(&Result);
220 ENSURE(VALID_REF(Result) || Result == NULL);
221 return Result;
225 * Destroys an auxiliary data item list item. This is an item destructor
226 * callback for ArrayList's private data.
228 * param ItemRef
229 * Reference to the auxiliary data item to cleanup.
230 * param ClientData
231 * Not used.
233 * return
234 * TRUE is a requirement
236 static Boolean_t AuxDataItemListItemDestructor(void *ItemRef,
237 ArbParam_t ClientData)
239 AuxDataItem_s **AuxDataItemRef = (AuxDataItem_s **)ItemRef;
241 REQUIRE(VALID_REF(AuxDataItemRef));
242 REQUIRE(VALID_REF(*AuxDataItemRef) || *AuxDataItemRef == NULL);
244 if (*AuxDataItemRef != NULL)
245 AuxDataItemDealloc(AuxDataItemRef);
247 ENSURE(*AuxDataItemRef == NULL);
248 return TRUE;
252 * Destroys an auxiliary data item. This is an item destructor
253 * callback for ArrayList's private data.
255 * param ItemRef
256 * Reference to the auxiliary data to cleanup.
257 * param ClientData
258 * Not used.
260 * return
261 * TRUE is a requirement
263 Boolean_t AuxDataItemDestructor(void *ItemRef,
264 ArbParam_t ClientData)
266 AuxData_pa *AuxDataRef = (AuxData_pa *)ItemRef;
268 REQUIRE(VALID_REF(AuxDataRef));
269 REQUIRE(VALID_REF(*AuxDataRef) || *AuxDataRef == NULL);
271 if (*AuxDataRef != NULL)
272 AuxDataDealloc(AuxDataRef);
274 ENSURE(*AuxDataRef == NULL);
275 return TRUE;
280 * Duplicates an auxiliary data item if its Retain flag is TRUE or if directed
281 * by the callback data. This is an item duplicator callback for ArrayList.
283 * param TargetItemRef
284 * Reference to the auxiliary data item to receive duplicate.
285 * param SourceItemRef
286 * Reference to the auxiliary data item to duplicate.
287 * param ClientData
288 * Boolean indicating if the Retain flag should be considered.
290 * return
291 * TRUE if the duplication was a success
292 * FALSE otherwise.
294 static Boolean_t AuxDataItemDuplicator(void *TargetItemRef,
295 void *SourceItemRef,
296 ArbParam_t ClientData)
298 Boolean_t IsOk = TRUE;
299 AuxDataItem_s **TargetAuxDataItemRef = (AuxDataItem_s **)TargetItemRef;
300 AuxDataItem_s **SourceAuxDataItemRef = (AuxDataItem_s **)SourceItemRef;
301 Boolean_t ConsiderRetain;
303 REQUIRE(VALID_REF(TargetAuxDataItemRef));
304 REQUIRE(VALID_REF(SourceAuxDataItemRef));
305 REQUIRE(VALID_REF(*SourceAuxDataItemRef) || *SourceAuxDataItemRef == NULL);
306 REQUIRE(VALID_BOOLEAN((Boolean_t)ClientData));
308 ConsiderRetain = (Boolean_t)ClientData;
310 /* duplicate the item */
311 if (*SourceAuxDataItemRef != NULL &&
312 (!ConsiderRetain || (*SourceAuxDataItemRef)->Retain))
314 *TargetAuxDataItemRef = AuxDataItemAlloc((*SourceAuxDataItemRef)->Name,
315 (*SourceAuxDataItemRef)->Value,
316 (*SourceAuxDataItemRef)->Type,
317 (*SourceAuxDataItemRef)->Retain);
318 IsOk = (*TargetAuxDataItemRef != NULL);
320 else
321 *TargetAuxDataItemRef = NULL;
323 ENSURE(VALID_REF(*TargetAuxDataItemRef) || *TargetAuxDataItemRef == NULL);
324 ENSURE(VALID_BOOLEAN(IsOk));
325 return IsOk;
329 * Deallocates an auxiliary data handle and sets the handle to NULL.
331 * param AuxData
332 * Reference to an auxiliary data handle or reference to NULL.
334 void AuxDataDealloc(AuxData_pa *AuxData)
336 REQUIRE(VALID_REF(AuxData));
337 REQUIRE(VALID_REF(*AuxData) || *AuxData == NULL);
339 if (*AuxData != NULL)
341 ArrayListDealloc(&(*AuxData)->ItemList, AuxDataItemListItemDestructor, 0);
342 FREE_ITEM(*AuxData, "auxiliary data container");
343 *AuxData = NULL;
346 ENSURE(*AuxData == NULL);
350 * Allocates an auxiliary data handle.
352 * return
353 * Auxiliary data handle or NULL if sufficient memory was not available.
355 AuxData_pa AuxDataAlloc(void)
357 AuxData_pa Result = ALLOC_ITEM(AuxData_s, "auxiliary data container");
358 if (Result != NULL)
360 Result->ItemList = ArrayListAlloc(0, ArrayListType_VoidPtr, NULL, 0);
361 if (Result->ItemList == NULL)
362 AuxDataDealloc(&Result);
365 ENSURE(VALID_REF(Result) || Result == NULL);
366 return Result;
370 * Copies the auxiliary data and all its members who's Retain flag is TRUE
371 * if the ConsiderRetain flag is TRUE otherwise it copies everything.
373 AuxData_pa AuxDataCopy(AuxData_pa AuxData,
374 Boolean_t ConsiderRetain)
376 AuxData_pa Result;
378 REQUIRE(VALID_REF(AuxData));
379 REQUIRE(VALID_BOOLEAN(ConsiderRetain));
381 Result = ALLOC_ITEM(AuxData_s, "auxiliary data container");
382 if (Result != NULL)
384 Result->ItemList = ArrayListCopy(AuxData->ItemList,
385 AuxDataItemDuplicator,
386 ConsiderRetain);
387 if (Result->ItemList != NULL)
389 if (ConsiderRetain)
392 * Now pass through the array cleaning up the holes left by those
393 * auxiliary data item member who's Retain flag was FALSE and
394 * therefore left a VOID pointer because it was not copied.
396 LgIndex_t ItemOffset = 0;
397 LgIndex_t ItemCount = ArrayListGetCount(Result->ItemList);
398 while (ItemOffset < ItemCount)
400 /* if there is more than one in a row remove them all at once */
401 if (ArrayListGetVoidPtr(Result->ItemList, ItemOffset) == NULL)
403 LgIndex_t BaseOffsetToRemove = ItemOffset;
404 LgIndex_t NumItemsToRemove = 1;
405 while (BaseOffsetToRemove + NumItemsToRemove < ItemCount &&
406 ArrayListGetVoidPtr(Result->ItemList,
407 BaseOffsetToRemove + NumItemsToRemove) == NULL)
408 NumItemsToRemove++;
410 /* delete the NULL items */
411 ArrayListDeleteItems(Result->ItemList,
412 BaseOffsetToRemove,
413 NumItemsToRemove,
414 NULL, 0);
417 * Update ItemCount but leave ItemOffset alone as it is now
418 * indexing the next item to examine.
420 ItemCount = ArrayListGetCount(Result->ItemList);
422 else
423 ItemOffset++;
427 else
428 AuxDataDealloc(&Result);
431 ENSURE(VALID_REF(Result) || Result == NULL);
432 return Result;
436 * Gets the current number of auxiliary data items maintained by the auxiliary.
438 * param AuxData
439 * Handle to auxiliary data.
441 * return
442 * Number of items maintained by the auxiliary data.
444 LgIndex_t AuxDataGetNumItems(AuxData_pa AuxData)
446 LgIndex_t NumItems;
448 REQUIRE(VALID_REF(AuxData));
450 NumItems = ArrayListGetCount(AuxData->ItemList);
452 ENSURE(NumItems >= 0);
453 return NumItems;
457 * Gets the item index of the name if found or if not found the index where an
458 * auxiliary data item could be inserted.
460 * param AuxData
461 * Handle to auxiliary data.
462 * param Name
463 * Name used for the search (case insensitive).
464 * param ItemIndex
465 * Address to hold the index of the found item or the index where an
466 * auxiliary data item could be inserted.
468 * return
469 * TRUE if the named item was found,
470 * FALSE otherwise.
472 Boolean_t AuxDataGetItemIndex(AuxData_pa AuxData,
473 const char *Name,
474 LgIndex_t *ItemIndex)
476 Boolean_t FoundItem = FALSE;
477 LgIndex_t Index;
478 LgIndex_t NumItems;
480 REQUIRE(VALID_REF(AuxData));
481 INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name");
482 REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name));
483 REQUIRE(VALID_REF(ItemIndex));
486 * Note that the current implementation just does a linear search
487 * though the array looking for the index of the item or if not
488 * found the index of the insertion point. This should be replaced
489 * with a binary search.
491 NumItems = AuxDataGetNumItems(AuxData);
493 # if defined DO_LINEAR_SEARCH
495 for (Index = 0; Index < NumItems; Index++)
497 AuxDataItem_s *AuxDataItem =
498 (AuxDataItem_s *)ArrayListGetVoidPtr(AuxData->ItemList, Index);
499 int CompareResult = ustrcmp(AuxDataItem->Name, Name);
500 if (CompareResult >= 0)
502 FoundItem = (CompareResult == 0);
503 break;
507 # else
509 int low, high;
510 low = 0;
511 high = NumItems - 1;
512 Index = 0;
513 while (low <= high)
515 AuxDataItem_s *AuxDataItem;
516 int CompareResult;
517 Index = (low + high) / 2;
518 AuxDataItem = (AuxDataItem_s *)ArrayListGetVoidPtr(AuxData->ItemList, Index);
519 CompareResult = ustrcmp(Name, AuxDataItem->Name);
520 if (CompareResult < 0)
521 high = Index - 1; /* If the new name is "less" than the one we're comparing to,
522 don't change Index since Index is already in the right spot */
523 else if (CompareResult > 0)
524 low = ++Index; /* If the new name it "greater" than the one we're comparing
525 against, we want to make sure its Index is greater than
526 the current name's index as well, that's why we increment Index here. */
527 else
529 FoundItem = TRUE;
530 break;
534 # endif
536 *ItemIndex = Index;
538 ENSURE(VALID_BOOLEAN(FoundItem));
539 ENSURE(0 <= *ItemIndex &&
540 ((FoundItem && *ItemIndex < NumItems) ||
541 (!FoundItem && *ItemIndex <= NumItems)));
542 return FoundItem;
546 * Gets the auxiliary data item at the specified index.
548 * NOTE: The name and value are a references, NOT copies.
550 * param AuxData
551 * Handle to auxiliary data.
552 * param Index
553 * Index of the auxiliary data item of interest.
554 * param Name
555 * Address to hold the auxiliary data item name.
556 * param Value
557 * Address to hold the auxiliary data item value.
558 * param Type
559 * Address to hold the auxiliary data item type.
560 * param Retain
561 * Address to hold the auxiliary data item retain flag.
563 void AuxDataGetItemByIndex(AuxData_pa AuxData,
564 LgIndex_t Index,
565 const char **Name,
566 ArbParam_t *Value,
567 AuxDataType_e *Type,
568 Boolean_t *Retain)
570 AuxDataItem_s *AuxDataItem;
572 REQUIRE(VALID_REF(AuxData));
573 INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name");
574 REQUIRE(0 <= Index && Index < ArrayListGetCount(AuxData->ItemList));
575 REQUIRE(VALID_REF(Name));
576 REQUIRE(VALID_REF(Value));
577 REQUIRE(VALID_REF(Type));
578 REQUIRE(VALID_REF(Retain));
580 AuxDataItem = (AuxDataItem_s *)ArrayListGetVoidPtr(AuxData->ItemList, Index);
581 *Name = AuxDataItem->Name;
582 *Value = AuxDataItem->Value;
583 *Type = AuxDataItem->Type;
584 *Retain = AuxDataItem->Retain;
586 ENSURE(VALID_REF(*Name) && AuxDataIsValidName(*Name));
587 ENSURE(IMPLICATION(*Type == AuxDataType_String,
588 (VALID_REF((char *)(*Value)) ||
589 (char *)(*Value) == NULL)));
590 ENSURE(VALID_ENUM(*Type, AuxDataType_e));
591 ENSURE(VALID_BOOLEAN(*Retain));
595 * Gets the auxiliary data item by the specified name if it exists.
597 * NOTE: The name and value are a references, NOT copies.
599 * param AuxData
600 * Handle to auxiliary data.
601 * param Name
602 * Name used for the search (case insensitive).
603 * param Value
604 * Address to hold the auxiliary data item value.
605 * param Type
606 * Address to hold the auxiliary data item type.
607 * param Retain
608 * Address to hold the auxiliary data item retain flag.
610 * return
611 * TRUE if the an auxilary data item by the specified name was found,
612 * FALSE otherwise.
614 Boolean_t AuxDataGetItemByName(AuxData_pa AuxData,
615 const char *Name,
616 ArbParam_t *Value,
617 AuxDataType_e *Type,
618 Boolean_t *Retain)
620 Boolean_t FoundItem;
621 LgIndex_t ItemIndex;
623 REQUIRE(VALID_REF(AuxData));
624 INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name");
625 REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name));
626 REQUIRE(VALID_REF(Value));
627 REQUIRE(VALID_REF(Type));
628 REQUIRE(VALID_REF(Retain));
630 FoundItem = AuxDataGetItemIndex(AuxData, Name, &ItemIndex);
631 if (FoundItem)
633 const char *SameName;
634 AuxDataGetItemByIndex(AuxData, ItemIndex, &SameName,
635 Value, Type, Retain);
636 CHECK(ustrcmp(Name, SameName) == 0);
639 ENSURE(VALID_BOOLEAN(FoundItem));
640 ENSURE(IMPLICATION(FoundItem,
641 IMPLICATION(*Type == AuxDataType_String,
642 (VALID_REF((char *)(*Value)) ||
643 (char *)(*Value) == NULL))));
644 ENSURE(IMPLICATION(FoundItem,
645 VALID_ENUM(*Type, AuxDataType_e)));
646 ENSURE(IMPLICATION(FoundItem,
647 VALID_BOOLEAN(*Retain)));
648 return FoundItem;
653 * Get a string value from AuxData and convert it to a boolean.
655 Boolean_t AuxDataGetBooleanItemByName(AuxData_pa AuxData, /* IN */
656 const char *Name, /* IN */
657 Boolean_t *Value, /* OUT */
658 AuxDataType_e *Type, /* OUT */
659 Boolean_t *Retain) /* OUT */
661 Boolean_t FoundItem;
663 REQUIRE(VALID_REF(AuxData));
664 INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name");
665 REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name));
666 REQUIRE(VALID_REF(Value));
667 REQUIRE(VALID_REF(Type));
668 REQUIRE(VALID_REF(Retain));
670 ArbParam_t strValue;
671 FoundItem = AuxDataGetItemByName(AuxData,
672 Name,
673 &strValue,
674 Type,
675 Retain);
677 if (FoundItem &&
678 (ustrcmp((char *)strValue, "YES") == 0 ||
679 ustrcmp((char *)strValue, "YEP") == 0 ||
680 ustrcmp((char *)strValue, "Y") == 0 ||
681 ustrcmp((char *)strValue, "TRUE") == 0 ||
682 ustrcmp((char *)strValue, "T") == 0 ||
683 ustrcmp((char *)strValue, "ON") == 0 ||
684 ustrcmp((char *)strValue, "1") == 0))
686 *Value = TRUE;
688 else
690 *Value = FALSE;
693 ENSURE(VALID_BOOLEAN(FoundItem));
694 ENSURE(VALID_BOOLEAN(*Value));
695 return FoundItem;
700 * Adds the auxiliary data item to the auxiliary data or replaces it if one
701 * already exists by the same name.
703 * NOTE: The auxiliary data makes copies of the name and value.
705 * param AuxData
706 * Auxiliary data handle.
707 * param Name
708 * Auxiliary data item's name (case insenstive).
709 * param Value
710 * Auxiliary data item's value.
711 * param Type
712 * Auxiliary data item's value type.
713 * param Retain
714 * Indicates if the auxiliary data item should persist.
716 * return
717 * TRUE if the item was added to the auxiliary data.
719 Boolean_t AuxDataSetItem(AuxData_pa AuxData,
720 const char *Name,
721 ArbParam_t Value,
722 AuxDataType_e Type,
723 Boolean_t Retain)
725 Boolean_t IsOk;
726 AuxDataItem_s *AuxDataItem;
728 REQUIRE(VALID_REF(AuxData));
729 INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name");
730 REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name));
731 REQUIRE(IMPLICATION(Type == AuxDataType_String,
732 (VALID_REF((char *)Value) ||
733 (char *)Value == NULL)));
734 REQUIRE(VALID_ENUM(Type, AuxDataType_e));
735 REQUIRE(VALID_BOOLEAN(Retain));
737 AuxDataItem = AuxDataItemAlloc(Name, Value, Type, Retain);
738 IsOk = (AuxDataItem != NULL);
739 if (IsOk)
741 LgIndex_t ItemIndex;
742 ArrayListItem_u ListItem;
744 /* add or replace the item to the list */
745 ListItem.VoidPtr = (void *)AuxDataItem;
746 if (!AuxDataGetItemIndex(AuxData, Name, &ItemIndex))
747 IsOk = ArrayListInsertItem(AuxData->ItemList, ItemIndex, ListItem);
748 else
749 IsOk = ArrayListSetItem(AuxData->ItemList, ItemIndex, ListItem,
750 AuxDataItemListItemDestructor, 0);
752 if (!IsOk)
753 AuxDataItemDealloc(&AuxDataItem);
756 ENSURE(VALID_BOOLEAN(IsOk));
757 INVARIANT("AuxData->ItemList is case-insensitive sorted by AuxDataItem->Name");
758 return IsOk;
762 * Deletes the auxiliary data item at the specified index.
764 * param AuxData
765 * Auxiliary data handle.
766 * param Index
767 * Index of the auxiliary data item of interest.
769 void AuxDataDeleteItemByIndex(AuxData_pa AuxData,
770 LgIndex_t Index)
772 REQUIRE(VALID_REF(AuxData));
773 REQUIRE(0 <= Index && Index < ArrayListGetCount(AuxData->ItemList));
775 ArrayListDeleteItem(AuxData->ItemList, Index, AuxDataItemListItemDestructor, 0);
779 * Deletes the auxiliary data item by the specified name if it exists.
781 * param AuxData
782 * Auxiliary data handle.
783 * param Name
784 * Name used for the search (case insensitive).
786 * return
787 * TRUE if the an auxilary data item by the specified name was found,
788 * FALSE otherwise.
790 Boolean_t AuxDataDeleteItemByName(AuxData_pa AuxData,
791 const char *Name)
793 Boolean_t FoundItem;
794 LgIndex_t ItemIndex;
796 REQUIRE(VALID_REF(AuxData));
797 REQUIRE(VALID_REF(Name) && AuxDataIsValidName(Name));
799 FoundItem = AuxDataGetItemIndex(AuxData, Name, &ItemIndex);
800 if (FoundItem)
801 AuxDataDeleteItemByIndex(AuxData, ItemIndex);
803 ENSURE(VALID_BOOLEAN(FoundItem));
804 return FoundItem;
807 #if defined TECPLOTKERNEL
808 /* CORE SOURCE CODE REMOVED */
809 #endif /* TECPLOTKERNEL */