IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8207


Ignore:
Timestamp:
Aug 6, 2006, 11:33:30 PM (20 years ago)
Author:
jhoblitt
Message:

implement a "simple" output format

Location:
trunk/glueforge/templates/psdb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/glueforge/templates/psdb/printmetadataraw.tt

    r8206 r8207  
    33    PS_ASSERT_PTR_NON_NULL(md, false);
    44
    5     psString str = psMetadataConfigFormat(md);
    6     if (!str) {
    7         psError(PS_ERR_UNKNOWN, false, "failed to format data into a string");
     5    if (mdcf) {
     6        psString str = psMetadataConfigFormat(md);
     7        if (!str) {
     8            psError(PS_ERR_UNKNOWN, false, "failed to format data into a string");
     9            psFree(str);
     10            return false;
     11        }
     12        fprintf(stream, "%s\n", str);
     13        psFree(str);
     14
     15        return true;
    816    }
    9     fprintf(stream, "%s\n", str);
    10     psFree(str);
     17
     18#define METADATAITEM_STRIFY_CASE(ptype, format, type) \
     19case ptype: \
     20    psStringAppend(&str, #format, item->data.type); \
     21    break;
     22
     23    // else
     24    // flatten the metadata into | separated values
     25    psString str = NULL;
     26    psMetadataItem *item = NULL;
     27    psMetadataIterator *iter = psMetadataIteratorAlloc(md, 0, NULL);
     28    while ((item = psMetadataGetAndIncrement(iter))) {
     29        switch (item->type) {
     30            METADATAITEM_STRIFY_CASE(PS_DATA_S8, %d, S8);
     31            METADATAITEM_STRIFY_CASE(PS_DATA_S16, %d, S16);
     32            METADATAITEM_STRIFY_CASE(PS_DATA_S32, %d, S32);
     33            METADATAITEM_STRIFY_CASE(PS_DATA_S64, %lld, S64);
     34            METADATAITEM_STRIFY_CASE(PS_DATA_U8, %u, U8);
     35            METADATAITEM_STRIFY_CASE(PS_DATA_U16, %u, U16);
     36            METADATAITEM_STRIFY_CASE(PS_DATA_U32, %u, U32);
     37            METADATAITEM_STRIFY_CASE(PS_DATA_U64, %llu, U64);
     38            METADATAITEM_STRIFY_CASE(PS_DATA_F32, %f, F32);
     39            METADATAITEM_STRIFY_CASE(PS_DATA_F64, %f, F64);
     40            case PS_DATA_STRING:
     41                psStringAppend(&str, "%s", (char*)(item->data.V));
     42                break;
     43            case PS_DATA_BOOL:
     44                if (item->data.B) {
     45                    psStringAppend(&str, "T");
     46                } else {
     47                    psStringAppend(&str, "F");
     48                }
     49                break;
     50            case PS_DATA_METADATA:
     51                if (![% pkg_namespace %]PrintMetadataRaw(stream, item->data.md, mdcf)) {
     52                    psError(PS_ERR_UNKNOWN, false ,"failed to print nested metadata");
     53                }
     54                // a metadata is a special case. We don't want a | seperating
     55                // the metadata from any other output so we need to skip the
     56                // !->offEnd test
     57                continue;
     58            default:
     59                psError(PS_ERR_UNKNOWN, true,"unsupported psMetadataItem type");
     60                psFree(iter);
     61                psFree(str);
     62                return false;
     63        }
     64        if (!iter->iter->offEnd) {
     65            psStringAppend(&str, "|");
     66        }
     67    }
     68    psFree(iter);
     69
     70    // if we did nothing but handle recursive metadatas str will be NULL
     71    if (str) {
     72        fprintf(stream, "%s\n", str);
     73        psFree(str);
     74    }
    1175
    1276    return true;
  • trunk/glueforge/templates/psdb/printobjects.tt

    r8206 r8207  
    2222    }
    2323
    24     psString str = psMetadataConfigFormat(output);
    25     if (!str) {
    26         psError(PS_ERR_UNKNOWN, false, "failed to format data into a string");
     24    if (![% pkg_namespace %]PrintMetadataRaw(stream, output, mdcf)) {
     25        psError(PS_ERR_UNKNOWN, false, "failed to print metadata");
    2726        psFree(output);
    2827    }
    2928    psFree(output);
    30     fprintf(stream, "%s\n", str);
    31     psFree(str);
    3229
    3330    return true;
Note: See TracChangeset for help on using the changeset viewer.