MCPcopy Create free account
hub / github.com/KDE/labplot / scanAttrs

Method scanAttrs

src/backend/datasources/filters/NetCDFFilter.cpp:371–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

369}
370
371QString NetCDFFilterPrivate::scanAttrs(int ncid, int varid, int attid, QTreeWidgetItem* parentItem) {
372 char name[NC_MAX_NAME + 1];
373
374 int nattr, nstart = 0;
375 if (attid == -1) {
376 m_status = nc_inq_varnatts(ncid, varid, &nattr);
377 handleError(m_status, QStringLiteral("nc_inq_varnatts"));
378 } else {
379 nstart = attid;
380 nattr = attid + 1;
381 }
382
383 nc_type type;
384 size_t len;
385 QStringList valueString;
386 for (int i = nstart; i < nattr; i++) {
387 valueString.clear();
388 m_status = nc_inq_attname(ncid, varid, i, name);
389 handleError(m_status, QStringLiteral("nc_inq_attname"));
390
391 m_status = nc_inq_att(ncid, varid, name, &type, &len);
392 handleError(m_status, QStringLiteral("nc_inq_att"));
393 QDEBUG(" attr" << i + 1 << "name/type/len =" << name << translateDataType(type) << len);
394
395 // read attribute
396 switch (type) {
397 case NC_BYTE: {
398 NC_GET_ATT(signed char, schar);
399 break;
400 }
401 case NC_UBYTE: {
402 NC_GET_ATT(unsigned char, uchar);
403 break;
404 }
405 case NC_CHAR: { // not number
406 char* value = (char*)malloc((len + 1) * sizeof(char));
407 m_status = nc_get_att_text(ncid, varid, name, value);
408 handleError(m_status, QStringLiteral("nc_get_att_text"));
409 value[len] = 0;
410 valueString << QLatin1String(value);
411 free(value);
412 break;
413 }
414 case NC_SHORT: {
415 NC_GET_ATT(short, short);
416 break;
417 }
418 case NC_USHORT: {
419 NC_GET_ATT(unsigned short, ushort);
420 break;
421 }
422 case NC_INT: {
423 NC_GET_ATT(int, int);
424 break;
425 }
426 case NC_UINT: {
427 NC_GET_ATT(unsigned int, uint);
428 break;

Callers

nothing calls this directly

Calls 4

QStringClass · 0.70
clearMethod · 0.45
setIconMethod · 0.45
addChildMethod · 0.45

Tested by

no test coverage detected