IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16635


Ignore:
Timestamp:
Feb 24, 2008, 10:53:12 AM (18 years ago)
Author:
eugene
Message:

add ability to compare a PS_STRING to a list of PS_STRINGS (PS_DATA_METADATA_MULTI)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psMetadataItemCompare.c

    r15226 r16635  
    6868        TEMPLATE_CASE(F64,  F64, psF64);
    6969    case PS_DATA_STRING:
     70
     71        // for MULTI, try each one & succeed if any match (valid = true is default state)
     72        if (compare->type == PS_DATA_METADATA_MULTI) {
     73            for (int j = 0; j < compare->data.list->n; j++) {
     74                psMetadataItem *entry = psListGet (compare->data.list, j);
     75                if (!entry) continue;
     76                if (entry->type != PS_DATA_STRING) {
     77                  continue;
     78                }
     79                if (template->data.V && !entry->data.V) { // expecting valid data, found NULL
     80                  continue;
     81                }
     82                if (!template->data.V && entry->data.V) { // expecting NULL, found valid data
     83                  continue;
     84                }
     85                // XXX should we return true for both NULL?
     86                if (!template->data.V && !entry->data.V) { // expecting NULL, found NULL
     87                  return true;
     88                }
     89                if (!strcasecmp(compare->data.V, template->data.V)) {
     90                  return true;
     91                }
     92            }
     93            return false;
     94        }
     95
     96        // any other (non-MULTI) is a mis-match
    7097        if (compare->type != PS_DATA_STRING) {
    7198            return false;
     
    76103        }
    77104        return (strcasecmp(compare->data.V, template->data.V) == 0) ? true : false;
     105
    78106    default:
    79107        // Simply don't know how to compare more complex types.
Note: See TracChangeset for help on using the changeset viewer.