IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42157


Ignore:
Timestamp:
Apr 4, 2022, 3:59:33 PM (4 years ago)
Author:
eugene
Message:

allow subsets of string vectors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20220316/Ohana/src/opihi/cmd.data/subset.c

    r35109 r42157  
    4444  ResetVector (ovec, ivec->type, tvec[0].Nelements);
    4545
    46   // we have four cases: (ivec == flt or int) and (tvec == flt or int)
     46  // we have size cases: (ivec == flt, int, str) and (tvec == flt or int)
    4747  if ((ivec->type == OPIHI_FLT) && (tvec->type == OPIHI_FLT)) {
    4848    opihi_flt *vi = ivec[0].elements.Flt;
     
    8181    }
    8282  }
     83  // XXX if ivec is an existing vector, this step will
     84  // leak (existing elements need to be freed if they
     85  // have been allocated).
     86  if ((ivec->type == OPIHI_STR) && (tvec->type == OPIHI_FLT)) {
     87    opihi_flt *vt = tvec[0].elements.Flt;
     88    for (Npts = i = 0; i < tvec[0].Nelements; i++, vt++) {
     89      if (!*vt) continue;
     90      ovec[0].elements.Str[Npts] = strcreate(ivec[0].elements.Str[i]);
     91      Npts++;
     92    }
     93  }
     94  if ((ivec->type == OPIHI_STR) && (tvec->type == OPIHI_INT)) {
     95    opihi_int *vt = tvec[0].elements.Int;
     96    for (Npts = i = 0; i < tvec[0].Nelements; i++, vt++) {
     97      if (!*vt) continue;
     98      ovec[0].elements.Str[Npts] = strcreate(ivec[0].elements.Str[i]);
     99      Npts++;
     100    }
     101  }
    83102
    84103  // free up unused memory
Note: See TracChangeset for help on using the changeset viewer.