IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 26, 2008, 3:39:54 PM (18 years ago)
Author:
jhoblitt
Message:

consitently handle *_id fields as numeric values instead of converting back of forth between ints and strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/pxtools.h

    r18029 r18336  
    3636#include "pxfake.h"
    3737#include "pxwarp.h"
    38 #include "pxio.h"
    3938#include "pxregister.h"
    4039#include "pxtag.h"
     
    109108type var; \
    110109{ \
    111     bool status; \
    112  \
    113     var = psMetadataLookup##suffix(&status, md, key); \
    114     if (!status) { \
    115         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for %s", key); \
    116         return ret; \
    117     } \
    118  \
    119     if (required && (var == max)) { \
    120         psError(PS_ERR_UNKNOWN, true, "%s is required", key); \
    121         return ret; \
    122     } \
     110    psMetadataItem *item = psMetadataLookup(md, key); \
     111    if (!item) { \
     112        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for %s", key); \
     113        return ret; \
     114    } \
     115    psAssert(item->comment, "metadata item comment should be defined"); \
     116    if (required && (!psStrcasestr(item->comment, "(found)"))) { \
     117        psError(PS_ERR_UNKNOWN, true, "%s is required", key); \
     118        return ret; \
     119    } \
     120 \
     121    var = item->data.suffix; \
     122 \
    123123}
    124124
     
    172172// XXX the PXOPT_COPY_* macros free 'to' on error
    173173
    174 #define PXOPT_COPY_PRIMITIVE(from, to, type, suffix, oldname, newname, comment) \
    175 { \
    176     bool status = false; \
    177     type var = psMetadataLookup##suffix(&status, from, oldname); \
    178     if (!status) { \
    179         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for " oldname); \
     174#define PXOPT_COPY_PRIMITIVE(from, to, type, suffix, oldname, newname, newcomment) \
     175{ \
     176    psMetadataItem *item = psMetadataLookup(from, oldname); \
     177    if (!item) { \
     178        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for %s", oldname); \
    180179        return false; \
    181180    } \
    182     if (!psMetadataAdd##suffix(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, var)) { \
    183         psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
    184         psFree(to); \
    185         return false; \
     181    psAssert(item->comment, "metadata item comment should be defined"); \
     182\
     183    if (psStrcasestr(item->comment, "(found)")) { \
     184        if (!psMetadataAdd##suffix(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, newcomment, item->data.suffix)) { \
     185            psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
     186            psFree(to); \
     187            return false; \
     188        } \
    186189    } \
    187190}
Note: See TracChangeset for help on using the changeset viewer.