Skip to content
Snippets Groups Projects
Commit a787010d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Changed if to switch.

parent 2d9cd48a
No related branches found
No related tags found
2 merge requests!34Version 2.2.0,!29M214003/develop
Pipeline #29628 passed
......@@ -430,25 +430,26 @@ printShortinfo(int streamID, int vlistID, int vardis)
// datatype
int datatype = vlistInqVarDatatype(vlistID, varID);
// clang-format off
if (datatype == CDI_DATATYPE_PACK ) strcpy(pstr, "P0");
else if (datatype > 0 && datatype <= 32 ) sprintf(pstr, "P%d", datatype);
else if (datatype == CDI_DATATYPE_CPX32 ) strcpy(pstr, "C32");
else if (datatype == CDI_DATATYPE_CPX64 ) strcpy(pstr, "C64");
else if (datatype == CDI_DATATYPE_FLT32 ) strcpy(pstr, "F32");
else if (datatype == CDI_DATATYPE_FLT64 ) strcpy(pstr, "F64");
else if (datatype == CDI_DATATYPE_INT8 ) strcpy(pstr, "I8");
else if (datatype == CDI_DATATYPE_INT16 ) strcpy(pstr, "I16");
else if (datatype == CDI_DATATYPE_INT32 ) strcpy(pstr, "I32");
else if (datatype == CDI_DATATYPE_UINT8 ) strcpy(pstr, "U8");
else if (datatype == CDI_DATATYPE_UINT16) strcpy(pstr, "U16");
else if (datatype == CDI_DATATYPE_UINT32) strcpy(pstr, "U32");
else strcpy(pstr, "-1");
if (datatype == CDI_DATATYPE_PACK ) strcpy(pstr, "P0");
else if (datatype > 0 && datatype <= 32 ) sprintf(pstr, "P%d", datatype);
else if (datatype == CDI_DATATYPE_CPX32 ) strcpy(pstr, "C32");
else if (datatype == CDI_DATATYPE_CPX64 ) strcpy(pstr, "C64");
else if (datatype == CDI_DATATYPE_FLT32 ) strcpy(pstr, "F32");
else if (datatype == CDI_DATATYPE_FLT64 ) strcpy(pstr, "F64");
else if (datatype == CDI_DATATYPE_INT8 ) strcpy(pstr, "I8");
else if (datatype == CDI_DATATYPE_INT16 ) strcpy(pstr, "I16");
else if (datatype == CDI_DATATYPE_INT32 ) strcpy(pstr, "I32");
else if (datatype == CDI_DATATYPE_UINT8 ) strcpy(pstr, "U8");
else if (datatype == CDI_DATATYPE_UINT16) strcpy(pstr, "U16");
else if (datatype == CDI_DATATYPE_UINT32) strcpy(pstr, "U32");
else strcpy(pstr, "-1");
// clang-format on
fprintf(stdout, " %-3s", pstr);
bool isCompressed = (vlistInqVarCompType(vlistID, varID) != CDI_COMPRESS_NONE);
fprintf(stdout, "%c ", isCompressed ? 'z' : ' ');
int compType = vlistInqVarCompType(vlistID, varID);
bool isCompressed = (compType != CDI_COMPRESS_NONE);
fprintf(stdout, "%c ", isCompressed ? (int) comptype_to_name(compType)[0] : ' ');
// parameter info
fprintf(stdout, ": ");
......
......@@ -50,13 +50,16 @@ time2str(CdiTime time, char *timestr, int maxlen)
}
const char *
comp_name(int comptype)
comptype_to_name(int compType)
{
if (comptype == CDI_COMPRESS_SZIP) return "szip";
if (comptype == CDI_COMPRESS_AEC) return "aec";
if (comptype == CDI_COMPRESS_ZIP) return "zip";
if (comptype == CDI_COMPRESS_JPEG) return "jpeg";
if (comptype == CDI_COMPRESS_FILTER) return "filter";
switch (compType)
{
case CDI_COMPRESS_SZIP: return "szip";
case CDI_COMPRESS_AEC: return "aec";
case CDI_COMPRESS_ZIP: return "zip";
case CDI_COMPRESS_JPEG: return "jpeg";
case CDI_COMPRESS_FILTER: return "filter";
}
return " ";
}
......@@ -66,7 +69,7 @@ printFiletype(int streamID, int vlistID)
int filetype = streamInqFiletype(streamID);
// clang-format off
switch ( filetype )
switch (filetype)
{
case CDI_FILETYPE_GRB: printf("GRIB"); break;
case CDI_FILETYPE_GRB2: printf("GRIB2"); break;
......@@ -82,9 +85,9 @@ printFiletype(int streamID, int vlistID)
default: printf(" File format: unsupported filetype %d" , filetype); break;
}
if ( filetype == CDI_FILETYPE_SRV || filetype == CDI_FILETYPE_EXT || filetype == CDI_FILETYPE_IEG )
if (filetype == CDI_FILETYPE_SRV || filetype == CDI_FILETYPE_EXT || filetype == CDI_FILETYPE_IEG)
{
switch ( streamInqByteorder(streamID) )
switch (streamInqByteorder(streamID))
{
case CDI_BIGENDIAN: printf(" BIGENDIAN"); break;
case CDI_LITTLEENDIAN: printf(" LITTLEENDIAN"); break;
......@@ -102,7 +105,7 @@ printFiletype(int streamID, int vlistID)
int comptype = vlistInqVarCompType(vlistID, varID);
if (comptype == comps[k])
{
printf("%c%s", (kk++ == 0) ? ' ' : '/', comp_name(comptype));
printf("%c%s", (kk++ == 0) ? ' ' : '/', comptype_to_name(comptype));
break;
}
}
......
......@@ -7,7 +7,7 @@ void datetime2str(CdiDateTime dt, char *datetimestr, int maxlen);
void date2str(CdiDate date, char *datestr, int maxlen);
void time2str(CdiTime time, char *timestr, int maxlen);
const char *comp_name(int comptype);
const char *comptype_to_name(int comptype);
void printFiletype(int streamID, int vlistID);
void printGridInfo(int vlistID);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment