Changeset 23868 for trunk/ippTools/src/pxtools.h
- Timestamp:
- Apr 14, 2009, 4:50:37 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pxtools.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pxtools.h
r23487 r23868 478 478 } 479 479 480 481 /// Add a primary item to the mirror database 482 /// 483 /// ITEM: Item to add (if it is of the correct type) 484 /// NAME: Name for table, to match item name 485 /// ROWTYPE: Type of the row (type returned by PARSEFUNC) 486 /// PARSEFUNC: Function to parse ITEM and return a ROWTYPE 487 /// IDENTIFIERS: Vector (of type U64) to store identifiers 488 /// IDNAME: Element of the row with U64 identifier 489 /// INSERTFUNC: Function to insert a row into the database 490 /// DATABASE: Database handle 491 /// CLEANUP: Operation(s) to perform to cleanup in case of an error 492 #define PXMIRROR_PRIMARY(ITEM, NAME, ROWTYPE, PARSEFUNC, IDENTIFIERS, IDNAME, INSERTFUNC, DATABASE, CLEANUP) \ 493 if (strcmp((ITEM)->name, NAME) == 0) { \ 494 if ((ITEM)->type != PS_DATA_METADATA) { \ 495 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Entry %s is not of type METADATA", (ITEM)->name); \ 496 CLEANUP; \ 497 return false; \ 498 } \ 499 ROWTYPE *row = PARSEFUNC((ITEM)->data.md); /* Row to insert */ \ 500 if (!row) { \ 501 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate %s row from metadata", (ITEM)->name); \ 502 CLEANUP; \ 503 return false; \ 504 } \ 505 if (!INSERTFUNC(DATABASE, row)) { \ 506 psError(PS_ERR_UNKNOWN, false, "Unable to add %s %" PRIu64, (ITEM)->name, row->IDNAME); \ 507 psFree(row); \ 508 CLEANUP; \ 509 return false; \ 510 } \ 511 psVectorAppend((IDENTIFIERS), row->IDNAME); \ 512 psFree(row); \ 513 } 514 515 /// Add a dependent item to the mirror database 516 /// 517 /// ITEM: Item to add (if it is of the correct type) 518 /// NAME: Name for table, to match item name 519 /// ROWTYPE: Type of the row (type returned by PARSEFUNC) 520 /// PARSEFUNC: Function to parse ITEM and return a ROWTYPE 521 /// IDENTIFIERS: Vector (of type U64) to check identifiers 522 /// IDNAME: Element of the row with U64 identifier 523 /// INSERTFUNC: Function to insert a row into the database 524 /// DATABASE: Database handle 525 /// CLEANUP: Operation(s) to perform to cleanup in case of an error 526 #define PXMIRROR_OTHER(ITEM, NAME, ROWTYPE, PARSEFUNC, IDENTIFIERS, IDNAME, INSERTFUNC, DATABASE, CLEANUP) \ 527 if (strcmp((ITEM)->name, NAME) == 0) { \ 528 if ((ITEM)->type != PS_DATA_METADATA) { \ 529 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Entry %s is not of type METADATA", (ITEM)->name); \ 530 CLEANUP; \ 531 return false; \ 532 } \ 533 ROWTYPE *row = PARSEFUNC(item->data.md); /* Row to insert */ \ 534 if (!row) { \ 535 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate %s row from metadata", (ITEM)->name); \ 536 CLEANUP; \ 537 return false; \ 538 } \ 539 bool found = false; /* Found the identifier? */ \ 540 for (int i = 0; i < (IDENTIFIERS)->n && !found; i++) { \ 541 if (row->IDNAME == (IDENTIFIERS)->data.U64[i]) { \ 542 found = true; \ 543 break; \ 544 } \ 545 } \ 546 if (!found) { \ 547 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Identifier not found for %s %" PRIu64, \ 548 (ITEM)->name, row->IDNAME); \ 549 psFree(row); \ 550 CLEANUP; \ 551 return false; \ 552 } \ 553 if (!INSERTFUNC(DATABASE, row)) { \ 554 psError(PS_ERR_UNKNOWN, false, "Unable to add %s %" PRIu64, (ITEM)->name, row->IDNAME); \ 555 psFree(row); \ 556 CLEANUP; \ 557 return false; \ 558 } \ 559 psFree(row); \ 560 } 561 480 562 #endif // PXTOOLS_H
Note:
See TracChangeset
for help on using the changeset viewer.
